@@ -419,7 +419,7 @@ For example, a package that wants to provide different ES module exports for
419
419
}
420
420
```
421
421
422
- Node.js supports the following conditions:
422
+ Node.js supports the following conditions out of the box :
423
423
424
424
* ` "import" ` - matched when the package is loaded via ` import ` or
425
425
` import() ` . Can reference either an ES module or CommonJS file, as both
@@ -434,18 +434,18 @@ Node.js supports the following conditions:
434
434
* ` "default" ` - the generic fallback that will always match. Can be a CommonJS
435
435
or ES module file. _ This condition should always come last._
436
436
437
- Condition matching is applied in object order from first to last within the
438
- ` "exports" ` object. _ The general rule is that conditions should be used
439
- from most specific to least specific in object order._
437
+ Within the ` "exports" ` object, key order is significant. During condition
438
+ matching, earlier entries have higher priority and take precedence over later
439
+ entries. _ The general rule is that conditions should be from most specific to
440
+ least specific in object order_ .
440
441
441
442
Other conditions such as ` "browser" ` , ` "electron" ` , ` "deno" ` , ` "react-native" ` ,
442
- etc. are ignored by Node.js but may be used by other runtimes or tools.
443
- Further restrictions, definitions or guidance on condition names may be
444
- provided in the future.
443
+ etc. are unknown to, and thus ignored by Node.js. Runtimes or tools other than
444
+ Node.js may use them at their discretion. Further restrictions, definitions, or
445
+ guidance on condition names may occur in the future.
445
446
446
447
Using the ` "import" ` and ` "require" ` conditions can lead to some hazards,
447
- which are explained further in
448
- [ the dual CommonJS/ES module packages section] [ ] .
448
+ which are further explained in [ the dual CommonJS/ES module packages section] [ ] .
449
449
450
450
Conditional exports can also be extended to exports subpaths, for example:
451
451
@@ -1154,10 +1154,11 @@ The `conditions` property on the `context` is an array of conditions for
1154
1154
for looking up conditional mappings elsewhere or to modify the list when calling
1155
1155
the default resolution logic .
1156
1156
1157
- The [current set of Node .js default conditions ][Conditional exports ] will always
1158
- be in the ` context.conditions` list passed to the hook . If the hook wants to
1159
- ensure Node .js - compatible resolution logic , all items from this default
1160
- condition list ** must ** be passed through to the ` defaultResolve` function .
1157
+ The current [package exports conditions ][Conditional Exports ] will always be in
1158
+ the ` context.conditions` array passed into the hook . To guarantee _default
1159
+ Node .js module specifier resolution behavior_ when calling ` defaultResolve` , the
1160
+ ` context.conditions` array passed to it _must_ include _all_ elements of the
1161
+ ` context.conditions` array originally passed into the ` resolve` hook .
1161
1162
1162
1163
` ` ` js
1163
1164
/**
0 commit comments