Skip to content

Commit

Permalink
doc: fix ESM/CJS wrapper example
Browse files Browse the repository at this point in the history
PR-URL: nodejs#34853
Refs: nodejs#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 Trott committed Aug 22, 2020
1 parent 44e6a6a commit ac3049d
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 @@ -689,6 +689,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 ac3049d

Please sign in to comment.