From 4b3b0e3f98e6073f00e2d1cda0c1fca7324d2f0c Mon Sep 17 00:00:00 2001 From: Maksim Sinik Date: Thu, 20 Aug 2020 15:44:38 +0200 Subject: [PATCH] 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 Reviewed-By: Matteo Collina Reviewed-By: Rich Trott --- doc/api/esm.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/api/esm.md b/doc/api/esm.md index 18efdb3c8b7ec1..2c860c710c6ac4 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -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';