| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,7 +57,7 @@ or when referenced by `import` statements within ES module code: | |||
| 57 | 57 | * Strings passed in as an argument to `--eval` or `--print`, or piped to | |
| 58 | 58 | `node` via `STDIN`, with the flag `--input-type=commonjs`. | |
| 59 | 59 | ||
| 60 | - ### <code>package.json</code> <code>"type"</code> field | ||
| 60 | + ### `package.json` `"type"` field | ||
| 61 | 61 | ||
| 62 | 62 | Files ending with `.js` or `.mjs`, or lacking any extension, | |
| 63 | 63 | will be loaded as ES modules when the nearest parent `package.json` file | |
@@ -159,7 +159,7 @@ package scope: | |||
| 159 | 159 | extension (since both `.js` and `.cjs` files are treated as CommonJS within a | |
| 160 | 160 | `"commonjs"` package scope). | |
| 161 | 161 | ||
| 162 | - ### <code>--input-type</code> flag | ||
| 162 | + ### `--input-type` flag | ||
| 163 | 163 | ||
| 164 | 164 | Strings passed in as an argument to `--eval` or `--print` (or `-e` or `-p`), or | |
| 165 | 165 | 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 | |||
| 190 | 190 | `"exports"`. [Conditional Exports][] can also be used within `"exports"` to | |
| 191 | 191 | define different package entry points per environment. | |
| 192 | 192 | ||
| 193 | - #### <code>package.json</code> <code>"main"</code> | ||
| 193 | + #### `package.json` `"main"` | ||
| 194 | 194 | ||
| 195 | 195 | The `package.json` `"main"` field defines the entry point for a package, | |
| 196 | 196 | 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 | |||
| 710 | 710 | easily updated to use conditional exports by adding conditions to the `"."` | |
| 711 | 711 | path; while keeping `"./module"` for backward compatibility. | |
| 712 | 712 | ||
| 713 | - ## <code>import</code> Specifiers | ||
| 713 | + ## `import` Specifiers | ||
| 714 | 714 | ||
| 715 | 715 | ### Terminology | |
| 716 | 716 | ||
@@ -767,7 +767,7 @@ import 'data:text/javascript,console.log("hello!");'; | |||
| 767 | 767 | import _ from 'data:application/json,"world!"'; | |
| 768 | 768 | ``` | |
| 769 | 769 | ||
| 770 | - ## import.meta | ||
| 770 | + ## `import.meta` | ||
| 771 | 771 | ||
| 772 | 772 | * {Object} | |
| 773 | 773 | ||
@@ -786,12 +786,12 @@ indexes (e.g. `'./startup/index.js'`) must also be fully specified. | |||
| 786 | 786 | This behavior matches how `import` behaves in browser environments, assuming a | |
| 787 | 787 | typically configured server. | |
| 788 | 788 | ||
| 789 | - ### No <code>NODE_PATH</code> | ||
| 789 | + ### No `NODE_PATH` | ||
| 790 | 790 | ||
| 791 | 791 | `NODE_PATH` is not part of resolving `import` specifiers. Please use symlinks | |
| 792 | 792 | if this behavior is desired. | |
| 793 | 793 | ||
| 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` | ||
| 795 | 795 | ||
| 796 | 796 | These CommonJS variables are not available in ES modules. | |
| 797 | 797 | ||
@@ -808,12 +808,12 @@ const __filename = fileURLToPath(import.meta.url); | |||
| 808 | 808 | const __dirname = dirname(__filename); | |
| 809 | 809 | ``` | |
| 810 | 810 | ||
| 811 | - ### No <code>require.extensions</code> | ||
| 811 | + ### No `require.extensions` | ||
| 812 | 812 | ||
| 813 | 813 | `require.extensions` is not used by `import`. The expectation is that loader | |
| 814 | 814 | hooks can provide this workflow in the future. | |
| 815 | 815 | ||
| 816 | - ### No <code>require.cache</code> | ||
| 816 | + ### No `require.cache` | ||
| 817 | 817 | ||
| 818 | 818 | `require.cache` is not used by `import`. It has a separate cache. | |
| 819 | 819 | ||
@@ -835,15 +835,15 @@ For now, only modules using the `file:` protocol can be loaded. | |||
| 835 | 835 | ||
| 836 | 836 | ## Interoperability with CommonJS | |
| 837 | 837 | ||
| 838 | - ### <code>require</code> | ||
| 838 | + ### `require` | ||
| 839 | 839 | ||
| 840 | 840 | `require` always treats the files it references as CommonJS. This applies | |
| 841 | 841 | whether `require` is used the traditional way within a CommonJS environment, or | |
| 842 | 842 | in an ES module environment using [`module.createRequire()`][]. | |
| 843 | 843 | ||
| 844 | 844 | To include an ES module into CommonJS, use [`import()`][]. | |
| 845 | 845 | ||
| 846 | - ### <code>import</code> statements | ||
| 846 | + ### `import` statements | ||
| 847 | 847 | ||
| 848 | 848 | An `import` statement can reference an ES module or a CommonJS module. Other | |
| 849 | 849 | file types such as JSON or Native modules are not supported. For those, use | |
@@ -874,7 +874,7 @@ import packageMain from 'commonjs-package'; // Works | |||
| 874 | 874 | import { method } from 'commonjs-package'; // Errors | |
| 875 | 875 | ``` | |
| 876 | 876 | ||
| 877 | - ### <code>import()</code> expressions | ||
| 877 | + ### `import()` expressions | ||
| 878 | 878 | ||
| 879 | 879 | Dynamic `import()` is supported in both CommonJS and ES modules. It can be used | |
| 880 | 880 | to include ES module files from CommonJS code. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments