Skip to content

Commit

Permalink
doc: fix ESM/CJS wrapper example
Browse files Browse the repository at this point in the history
PR-URL: #34853
Refs: #34714
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
fox1t authored and addaleax committed Sep 22, 2020
1 parent eb95c6a commit 500b737
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,12 @@ CommonJS entry point for `require`.
}
```

The above example uses explicit extensions `.mjs` and `.cjs`.
If your files use the `.js` extension, `"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](#esm_enabling).

```js
// ./node_modules/pkg/index.cjs
exports.name = 'value';
Expand Down

0 comments on commit 500b737

Please sign in to comment.