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 <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
fox1t authored and addaleax committed Sep 22, 2020
1 parent 3ea7e03 commit da150f4
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 da150f4

Please sign in to comment.