Skip to content

Commit 509e644

Browse files
authored
revert default / require guidance
1 parent a3859aa commit 509e644

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

doc/api/esm.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ require() and import can be written:
353353
"main": "./main-require.cjs",
354354
"exports": {
355355
"import": "./main-module.js",
356-
"default": "./main-require.cjs"
356+
"require": "./main-require.cjs"
357357
},
358358
"type": "module"
359359
}
@@ -362,15 +362,13 @@ require() and import can be written:
362362
The conditions supported in Node.js condition matching:
363363

364364
* `"default"` - the generic fallback that will always match. Can be a CommonJS
365-
or ES module file. **This condition should always come last.**
365+
or ES module file. _This condition should always come last._
366366
* `"import"` - matched when the package is loaded via `import` or
367367
`import()`. Can be any module format, this field does not set the type
368368
interpretation.
369369
* `"node"` - matched for any Node.js environment. Can be a CommonJS or ES
370370
module file.
371371
* `"require"` - matched when the package is loaded via `require()`.
372-
_Due to limited support in Node.js 13.x early versions it can be recommended
373-
to avoid using this condition._
374372

375373
Condition matching is applied in object order from first to last within the
376374
`"exports"` object. _The general rule is that conditions should be used
@@ -380,11 +378,6 @@ Other conditions such as `"browser"`, `"electron"`, `"deno"`, `"react-native"`,
380378
etc. could be defined in other runtimes or tools. Further restrictions,
381379
definitions or guidance on condition names may be provided in future.
382380

383-
`"default"` is set to a CommonJS module in the example above since early
384-
versions of Node.js 13.x support `"default"` but not `"import"` or `"require"`
385-
conditions. If `"default"` did not resolve as CommonJS this would break the
386-
use of `require('pkg')` in these Node.js versions when it matches the default.
387-
388381
Using the `"import"` and `"require"` conditions can lead to some hazards,
389382
which are explained further in [the dual mode packages section][].
390383

@@ -494,7 +487,7 @@ CommonJS entry point for `require`.
494487
"main": "./index.cjs",
495488
"exports": {
496489
"import": "./wrapper.mjs",
497-
"default": "./index.cjs"
490+
"require": "./index.cjs"
498491
}
499492
}
500493
```
@@ -574,7 +567,7 @@ CommonJS and ES module entry points directly:
574567
"main": "./index.cjs",
575568
"exports": {
576569
"import": "./index.mjs",
577-
"default": "./index.cjs"
570+
"require": "./index.cjs"
578571
}
579572
}
580573
```

0 commit comments

Comments
 (0)