| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,7 +60,7 @@ or when referenced by `import` statements within ES module code: | |||
| 60 | 60 | * Strings passed in as an argument to `--eval` or `--print`, or piped to | |
| 61 | 61 | `node` via `STDIN`, with the flag `--input-type=commonjs`. | |
| 62 | 62 | ||
| 63 | - ### <code>package.json</code> <code>"type"</code> field | ||
| 63 | + ### `package.json` `"type"` field | ||
| 64 | 64 | ||
| 65 | 65 | Files ending with `.js` or `.mjs`, or lacking any extension, | |
| 66 | 66 | will be loaded as ES modules when the nearest parent `package.json` file | |
@@ -162,7 +162,7 @@ package scope: | |||
| 162 | 162 | extension (since both `.js` and `.cjs` files are treated as CommonJS within a | |
| 163 | 163 | `"commonjs"` package scope). | |
| 164 | 164 | ||
| 165 | - ### <code>--input-type</code> flag | ||
| 165 | + ### `--input-type` flag | ||
| 166 | 166 | ||
| 167 | 167 | Strings passed in as an argument to `--eval` or `--print` (or `-e` or `-p`), or | |
| 168 | 168 | 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: | |||
| 358 | 358 | Since `"not:valid"` is not a supported target, `"./submodule.js"` is used | |
| 359 | 359 | instead as the fallback, as if it were the only target. | |
| 360 | 360 | ||
| 361 | - ## <code>import</code> Specifiers | ||
| 361 | + ## `import` Specifiers | ||
| 362 | 362 | ||
| 363 | 363 | ### Terminology | |
| 364 | 364 | ||
@@ -415,7 +415,7 @@ import 'data:text/javascript,console.log("hello!");'; | |||
| 415 | 415 | import _ from 'data:application/json,"world!"'; | |
| 416 | 416 | ``` | |
| 417 | 417 | ||
| 418 | - ## import.meta | ||
| 418 | + ## `import.meta` | ||
| 419 | 419 | ||
| 420 | 420 | * {Object} | |
| 421 | 421 | ||
@@ -434,12 +434,12 @@ indexes (e.g. `'./startup/index.js'`) must also be fully specified. | |||
| 434 | 434 | This behavior matches how `import` behaves in browser environments, assuming a | |
| 435 | 435 | typically configured server. | |
| 436 | 436 | ||
| 437 | - ### No <code>NODE_PATH</code> | ||
| 437 | + ### No `NODE_PATH` | ||
| 438 | 438 | ||
| 439 | 439 | `NODE_PATH` is not part of resolving `import` specifiers. Please use symlinks | |
| 440 | 440 | if this behavior is desired. | |
| 441 | 441 | ||
| 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` | ||
| 443 | 443 | ||
| 444 | 444 | These CommonJS variables are not available in ES modules. | |
| 445 | 445 | ||
@@ -456,12 +456,12 @@ const __filename = fileURLToPath(import.meta.url); | |||
| 456 | 456 | const __dirname = dirname(__filename); | |
| 457 | 457 | ``` | |
| 458 | 458 | ||
| 459 | - ### No <code>require.extensions</code> | ||
| 459 | + ### No `require.extensions` | ||
| 460 | 460 | ||
| 461 | 461 | `require.extensions` is not used by `import`. The expectation is that loader | |
| 462 | 462 | hooks can provide this workflow in the future. | |
| 463 | 463 | ||
| 464 | - ### No <code>require.cache</code> | ||
| 464 | + ### No `require.cache` | ||
| 465 | 465 | ||
| 466 | 466 | `require.cache` is not used by `import`. It has a separate cache. | |
| 467 | 467 | ||
@@ -483,15 +483,15 @@ For now, only modules using the `file:` protocol can be loaded. | |||
| 483 | 483 | ||
| 484 | 484 | ## Interoperability with CommonJS | |
| 485 | 485 | ||
| 486 | - ### <code>require</code> | ||
| 486 | + ### `require` | ||
| 487 | 487 | ||
| 488 | 488 | `require` always treats the files it references as CommonJS. This applies | |
| 489 | 489 | whether `require` is used the traditional way within a CommonJS environment, or | |
| 490 | 490 | in an ES module environment using [`module.createRequire()`][]. | |
| 491 | 491 | ||
| 492 | 492 | To include an ES module into CommonJS, use [`import()`][]. | |
| 493 | 493 | ||
| 494 | - ### <code>import</code> statements | ||
| 494 | + ### `import` statements | ||
| 495 | 495 | ||
| 496 | 496 | An `import` statement can reference an ES module, a CommonJS module, or JSON. | |
| 497 | 497 | Other file types such as Native modules are not supported. For those, | |
@@ -523,7 +523,7 @@ import { sin, cos } from 'geometry/trigonometry-functions.mjs'; | |||
| 523 | 523 | > | |
| 524 | 524 | > There are ongoing efforts to make the latter code possible. | |
| 525 | 525 | ||
| 526 | - ### <code>import()</code> expressions | ||
| 526 | + ### `import()` expressions | ||
| 527 | 527 | ||
| 528 | 528 | Dynamic `import()` is supported in both CommonJS and ES modules. It can be used | |
| 529 | 529 | to include ES module files from CommonJS code. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments