Skip to content

Commit fbb217a

Browse files
TrottBridgeAR
authored andcommitted
doc,esm: use code markup/markdown in headers
PR-URL: #31086 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 665a662 commit fbb217a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

doc/api/esm.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ or when referenced by `import` statements within ES module code:
5757
* Strings passed in as an argument to `--eval` or `--print`, or piped to
5858
`node` via `STDIN`, with the flag `--input-type=commonjs`.
5959

60-
### <code>package.json</code> <code>"type"</code> field
60+
### `package.json` `"type"` field
6161

6262
Files ending with `.js` or `.mjs`, or lacking any extension,
6363
will be loaded as ES modules when the nearest parent `package.json` file
@@ -159,7 +159,7 @@ package scope:
159159
extension (since both `.js` and `.cjs` files are treated as CommonJS within a
160160
`"commonjs"` package scope).
161161

162-
### <code>--input-type</code> flag
162+
### `--input-type` flag
163163

164164
Strings passed in as an argument to `--eval` or `--print` (or `-e` or `-p`), or
165165
piped to `node` via `STDIN`, will be treated as ES modules when the
@@ -190,7 +190,7 @@ defined in `"exports"`. If package entry points are defined in both `"main"` and
190190
`"exports"`. [Conditional Exports][] can also be used within `"exports"` to
191191
define different package entry points per environment.
192192

193-
#### <code>package.json</code> <code>"main"</code>
193+
#### `package.json` `"main"`
194194

195195
The `package.json` `"main"` field defines the entry point for a package,
196196
whether the package is included into CommonJS via `require` or into an ES
@@ -710,7 +710,7 @@ If the `--experimental-conditional-exports` flag is dropped and therefore
710710
easily updated to use conditional exports by adding conditions to the `"."`
711711
path; while keeping `"./module"` for backward compatibility.
712712

713-
## <code>import</code> Specifiers
713+
## `import` Specifiers
714714

715715
### Terminology
716716

@@ -767,7 +767,7 @@ import 'data:text/javascript,console.log("hello!");';
767767
import _ from 'data:application/json,"world!"';
768768
```
769769

770-
## import.meta
770+
## `import.meta`
771771

772772
* {Object}
773773

@@ -786,12 +786,12 @@ indexes (e.g. `'./startup/index.js'`) must also be fully specified.
786786
This behavior matches how `import` behaves in browser environments, assuming a
787787
typically configured server.
788788

789-
### No <code>NODE_PATH</code>
789+
### No `NODE_PATH`
790790

791791
`NODE_PATH` is not part of resolving `import` specifiers. Please use symlinks
792792
if this behavior is desired.
793793

794-
### No <code>require</code>, <code>exports</code>, <code>module.exports</code>, <code>\_\_filename</code>, <code>\_\_dirname</code>
794+
### No `require`, `exports`, `module.exports`, `__filename`, `__dirname`
795795

796796
These CommonJS variables are not available in ES modules.
797797

@@ -808,12 +808,12 @@ const __filename = fileURLToPath(import.meta.url);
808808
const __dirname = dirname(__filename);
809809
```
810810

811-
### No <code>require.extensions</code>
811+
### No `require.extensions`
812812

813813
`require.extensions` is not used by `import`. The expectation is that loader
814814
hooks can provide this workflow in the future.
815815

816-
### No <code>require.cache</code>
816+
### No `require.cache`
817817

818818
`require.cache` is not used by `import`. It has a separate cache.
819819

@@ -835,15 +835,15 @@ For now, only modules using the `file:` protocol can be loaded.
835835

836836
## Interoperability with CommonJS
837837

838-
### <code>require</code>
838+
### `require`
839839

840840
`require` always treats the files it references as CommonJS. This applies
841841
whether `require` is used the traditional way within a CommonJS environment, or
842842
in an ES module environment using [`module.createRequire()`][].
843843

844844
To include an ES module into CommonJS, use [`import()`][].
845845

846-
### <code>import</code> statements
846+
### `import` statements
847847

848848
An `import` statement can reference an ES module or a CommonJS module. Other
849849
file types such as JSON or Native modules are not supported. For those, use
@@ -874,7 +874,7 @@ import packageMain from 'commonjs-package'; // Works
874874
import { method } from 'commonjs-package'; // Errors
875875
```
876876

877-
### <code>import()</code> expressions
877+
### `import()` expressions
878878

879879
Dynamic `import()` is supported in both CommonJS and ES modules. It can be used
880880
to include ES module files from CommonJS code.

0 commit comments

Comments
 (0)