Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9cddfe2

Browse filesBrowse files
TrottMylesBorins
authored andcommitted
doc,esm: use code markup/markdown in headers
Backport-PR-URL: #31108 PR-URL: #31086 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent bde2625 commit 9cddfe2
Copy full SHA for 9cddfe2

File tree

Expand file treeCollapse file tree

1 file changed

+11
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-11
lines changed
Open diff view settings
Collapse file

‎doc/api/esm.md‎

Copy file name to clipboardExpand all lines: doc/api/esm.md
+11-11Lines changed: 11 additions & 11 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ or when referenced by `import` statements within ES module code:
6060
* Strings passed in as an argument to `--eval` or `--print`, or piped to
6161
`node` via `STDIN`, with the flag `--input-type=commonjs`.
6262

63-
### <code>package.json</code> <code>"type"</code> field
63+
### `package.json` `"type"` field
6464

6565
Files ending with `.js` or `.mjs`, or lacking any extension,
6666
will be loaded as ES modules when the nearest parent `package.json` file
@@ -162,7 +162,7 @@ package scope:
162162
extension (since both `.js` and `.cjs` files are treated as CommonJS within a
163163
`"commonjs"` package scope).
164164

165-
### <code>--input-type</code> flag
165+
### `--input-type` flag
166166

167167
Strings passed in as an argument to `--eval` or `--print` (or `-e` or `-p`), or
168168
piped to `node` via `STDIN`, will be treated as ES modules when the
@@ -358,7 +358,7 @@ in order to be forward-compatible with fallback workflows in future:
358358
Since `"not:valid"` is not a supported target, `"./submodule.js"` is used
359359
instead as the fallback, as if it were the only target.
360360

361-
## <code>import</code> Specifiers
361+
## `import` Specifiers
362362

363363
### Terminology
364364

@@ -415,7 +415,7 @@ import 'data:text/javascript,console.log("hello!");';
415415
import _ from 'data:application/json,"world!"';
416416
```
417417

418-
## import.meta
418+
## `import.meta`
419419

420420
* {Object}
421421

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

437-
### No <code>NODE_PATH</code>
437+
### No `NODE_PATH`
438438

439439
`NODE_PATH` is not part of resolving `import` specifiers. Please use symlinks
440440
if this behavior is desired.
441441

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

444444
These CommonJS variables are not available in ES modules.
445445

@@ -456,12 +456,12 @@ const __filename = fileURLToPath(import.meta.url);
456456
const __dirname = dirname(__filename);
457457
```
458458
459-
### No <code>require.extensions</code>
459+
### No `require.extensions`
460460
461461
`require.extensions` is not used by `import`. The expectation is that loader
462462
hooks can provide this workflow in the future.
463463
464-
### No <code>require.cache</code>
464+
### No `require.cache`
465465
466466
`require.cache` is not used by `import`. It has a separate cache.
467467
@@ -483,15 +483,15 @@ For now, only modules using the `file:` protocol can be loaded.
483483
484484
## Interoperability with CommonJS
485485
486-
### <code>require</code>
486+
### `require`
487487
488488
`require` always treats the files it references as CommonJS. This applies
489489
whether `require` is used the traditional way within a CommonJS environment, or
490490
in an ES module environment using [`module.createRequire()`][].
491491
492492
To include an ES module into CommonJS, use [`import()`][].
493493
494-
### <code>import</code> statements
494+
### `import` statements
495495
496496
An `import` statement can reference an ES module, a CommonJS module, or JSON.
497497
Other file types such as Native modules are not supported. For those,
@@ -523,7 +523,7 @@ import { sin, cos } from 'geometry/trigonometry-functions.mjs';
523523
>
524524
> There are ongoing efforts to make the latter code possible.
525525
526-
### <code>import()</code> expressions
526+
### `import()` expressions
527527
528528
Dynamic `import()` is supported in both CommonJS and ES modules. It can be used
529529
to include ES module files from CommonJS code.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.