From 1fd1395ee93690c6a6ba70805ac9401a6a514483 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 6 Feb 2018 11:19:04 +0200 Subject: [PATCH] lib,doc: revert format name to cjs over commonjs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/18596 Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: Myles Borins Reviewed-By: Ruben Bridgewater --- doc/api/esm.md | 2 +- lib/internal/loader/DefaultResolve.js | 2 +- lib/internal/loader/Translators.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/esm.md b/doc/api/esm.md index 4792dd624ac9eb..8da841d6c053d4 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -133,7 +133,7 @@ module. This can be one of the following: | `format` | Description | | --- | --- | | `"esm"` | Load a standard JavaScript module | -| `"commonjs"` | Load a node-style CommonJS module | +| `"cjs"` | Load a node-style CommonJS module | | `"builtin"` | Load a node builtin CommonJS module | | `"json"` | Load a JSON file | | `"addon"` | Load a [C++ Addon][addons] | diff --git a/lib/internal/loader/DefaultResolve.js b/lib/internal/loader/DefaultResolve.js index faadf0bc99ef95..69dd9537c18c2d 100644 --- a/lib/internal/loader/DefaultResolve.js +++ b/lib/internal/loader/DefaultResolve.js @@ -44,7 +44,7 @@ const extensionFormatMap = { '.mjs': 'esm', '.json': 'json', '.node': 'addon', - '.js': 'commonjs' + '.js': 'cjs' }; function resolve(specifier, parentURL) { diff --git a/lib/internal/loader/Translators.js b/lib/internal/loader/Translators.js index f1db8334dd5eea..d2f28774177fd6 100644 --- a/lib/internal/loader/Translators.js +++ b/lib/internal/loader/Translators.js @@ -32,7 +32,7 @@ translators.set('esm', async (url) => { // Strategy for loading a node-style CommonJS module const isWindows = process.platform === 'win32'; const winSepRegEx = /\//g; -translators.set('commonjs', async (url) => { +translators.set('cjs', async (url) => { debug(`Translating CJSModule ${url}`); const pathname = internalURLModule.getPathFromURL(new URL(url)); const module = CJSModule._cache[