| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -364,12 +364,15 @@ For example, a package that wants to provide different ES module exports for | |||
| 364 | 364 | Node.js supports the following conditions out of the box: | |
| 365 | 365 | ||
| 366 | 366 | * `"import"` - matched when the package is loaded via `import` or | |
| 367 | - `import()`. Can reference either an ES module or CommonJS file, as both | ||
| 368 | - `import` and `import()` can load either ES module or CommonJS sources. | ||
| 369 | - _Always matched when the `"require"` condition is not matched._ | ||
| 370 | - * `"require"` - matched when the package is loaded via `require()`. | ||
| 371 | - As `require()` only supports CommonJS, the referenced file must be CommonJS. | ||
| 372 | - _Always matched when the `"import"` condition is not matched._ | ||
| 367 | + `import()`, or via any top-level import or resolve operation by the | ||
| 368 | + ECMAScript module loader. Applies regardless of the module format of the | ||
| 369 | + target file. _Always mutually exclusive with `"require"`._ | ||
| 370 | + * `"require"` - matched when the package is loaded via `require()`. The | ||
| 371 | + referenced file should be loadable with `require()` although the condition | ||
| 372 | + will be matched regardless of the module format of the target file. Expected | ||
| 373 | + formats include CommonJS, JSON, and native addons but not ES modules as | ||
| 374 | + `require()` doesn't support them. _Always mutually exclusive with | ||
| 375 | + `"import"`._ | ||
| 373 | 376 | * `"node"` - matched for any Node.js environment. Can be a CommonJS or ES | |
| 374 | 377 | module file. _This condition should always come after `"import"` or | |
| 375 | 378 | `"require"`._ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments