doc: fix ESM/CJS wrapper example

PR-URL: https://github.com/nodejs/node/pull/34853
Refs: https://github.com/nodejs/node/issues/34714
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Maksim Sinik authored and Anna Henningsen committed 2020-09-22 19:56:01 +02:00
1 parent 3ea7e03ae4
commit da150f4e1e
1 file changed
+6
+6
View File
@@ -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';