From da150f4e1ec47b594824edb637fee16f1cd69af8 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 c9cc4e88c7c2bb..4381f66d1a4b93 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -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';