Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reverts wrapper snippet and adds a warning note
  • Loading branch information
fox1t committed Aug 21, 2020
commit f38a85e089581be807a0c80a660c5f60381b8865
11 changes: 7 additions & 4 deletions doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -665,13 +665,15 @@ CommonJS entry point for `require`.
```js
// ./node_modules/pkg/package.json
{
"main": "./index.js",
"type": "module",
"main": "./index.cjs",
"exports": {
"import": "./wrapper.mjs",
"require": "./index.js"
"require": "./index.cjs"
}
}
```
Note that the above example uses explicit extensions `.mjs` and `.cjs`. If your files use the `.js` extension, note that `"type": "module"` will cause such files to be treated as ES modules, just as `"type": "commonjs"` would cause them to be treated as CommonJS. See [Enabling](https://nodejs.org/api/esm.html#esm_enabling).

```js
// ./node_modules/pkg/index.cjs
Expand Down Expand Up @@ -726,9 +728,10 @@ stateless):
```js
// ./node_modules/pkg/package.json
{
"main": "./index.js",
"type": "module",
"main": "./index.cjs",
"exports": {
".": "./index.js",
".": "./index.cjs",
"./module": "./wrapper.mjs"
}
}
Expand Down