From c6ab449d1b2cc68c9f47cc868c66b2e97b6ab0f3 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Tue, 13 Dec 2022 22:24:28 +0100 Subject: [PATCH] modules: move modules/cjs/helpers.js to modules/helpers.js The helpers are actually shared by the two loaders, so move them under modules/ directly. PR-URL: https://github.com/nodejs/node/pull/45849 Reviewed-By: Geoffrey Booth Reviewed-By: Chengzhong Wu --- lib/internal/main/eval_string.js | 2 +- lib/internal/modules/cjs/loader.js | 2 +- lib/internal/modules/esm/translators.js | 2 +- lib/internal/modules/{cjs => }/helpers.js | 0 lib/internal/source_map/source_map_cache.js | 2 +- lib/internal/util/inspector.js | 2 +- lib/repl.js | 2 +- test/parallel/test-bootstrap-modules.js | 2 +- test/parallel/test-util-inspect.js | 2 +- 9 files changed, 8 insertions(+), 8 deletions(-) rename lib/internal/modules/{cjs => }/helpers.js (100%) diff --git a/lib/internal/main/eval_string.js b/lib/internal/main/eval_string.js index e92e088b8e0ceb..e8ecf9f1dae9cf 100644 --- a/lib/internal/main/eval_string.js +++ b/lib/internal/main/eval_string.js @@ -14,7 +14,7 @@ const { markBootstrapComplete } = require('internal/process/pre_execution'); const { evalModule, evalScript } = require('internal/process/execution'); -const { addBuiltinLibsToObject } = require('internal/modules/cjs/helpers'); +const { addBuiltinLibsToObject } = require('internal/modules/helpers'); const { getOptionValue } = require('internal/options'); diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 36efb48fc574cb..466c160506e669 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -103,7 +103,7 @@ const { makeRequireFunction, normalizeReferrerURL, stripBOM, -} = require('internal/modules/cjs/helpers'); +} = require('internal/modules/helpers'); const { getOptionValue } = require('internal/options'); const preserveSymlinks = getOptionValue('--preserve-symlinks'); const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main'); diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js index 38fa41e47603dd..2007b8d5ab063d 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -30,7 +30,7 @@ const { hasEsmSyntax, loadBuiltinModule, stripBOM, -} = require('internal/modules/cjs/helpers'); +} = require('internal/modules/helpers'); const { Module: CJSModule, cjsParseCache diff --git a/lib/internal/modules/cjs/helpers.js b/lib/internal/modules/helpers.js similarity index 100% rename from lib/internal/modules/cjs/helpers.js rename to lib/internal/modules/helpers.js diff --git a/lib/internal/source_map/source_map_cache.js b/lib/internal/source_map/source_map_cache.js index 1eb5c69bd3ff93..8699c4e9509681 100644 --- a/lib/internal/source_map/source_map_cache.js +++ b/lib/internal/source_map/source_map_cache.js @@ -27,7 +27,7 @@ const { getOptionValue } = require('internal/options'); const { IterableWeakMap } = require('internal/util/iterable_weak_map'); const { normalizeReferrerURL, -} = require('internal/modules/cjs/helpers'); +} = require('internal/modules/helpers'); const { validateBoolean } = require('internal/validators'); const { setMaybeCacheGeneratedSourceMap } = internalBinding('errors'); diff --git a/lib/internal/util/inspector.js b/lib/internal/util/inspector.js index c7f18ffdb61a33..3a589423b2d280 100644 --- a/lib/internal/util/inspector.js +++ b/lib/internal/util/inspector.js @@ -66,7 +66,7 @@ function installConsoleExtensions(commandLineApi) { if (commandLineApi.require) { return; } const { tryGetCwd } = require('internal/process/execution'); const CJSModule = require('internal/modules/cjs/loader').Module; - const { makeRequireFunction } = require('internal/modules/cjs/helpers'); + const { makeRequireFunction } = require('internal/modules/helpers'); const consoleAPIModule = new CJSModule(''); const cwd = tryGetCwd(); consoleAPIModule.paths = ArrayPrototypeConcat( diff --git a/lib/repl.js b/lib/repl.js index 6edd0c5b2601bd..ec940cf697109d 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -101,7 +101,7 @@ const { BuiltinModule } = require('internal/bootstrap/loaders'); const { makeRequireFunction, addBuiltinLibsToObject -} = require('internal/modules/cjs/helpers'); +} = require('internal/modules/helpers'); const { isIdentifierStart, isIdentifierChar diff --git a/test/parallel/test-bootstrap-modules.js b/test/parallel/test-bootstrap-modules.js index d3111513424182..bf2ca2e935c70f 100644 --- a/test/parallel/test-bootstrap-modules.js +++ b/test/parallel/test-bootstrap-modules.js @@ -53,7 +53,7 @@ const expectedModules = new Set([ 'NativeModule internal/fs/utils', 'NativeModule internal/idna', 'NativeModule internal/linkedlist', - 'NativeModule internal/modules/cjs/helpers', + 'NativeModule internal/modules/helpers', 'NativeModule internal/modules/cjs/loader', 'NativeModule internal/modules/esm/assert', 'NativeModule internal/modules/esm/formats', diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 57f8dd064005c6..2e0d726d3dcecb 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -2832,7 +2832,7 @@ assert.strictEqual( ' at Function.Module._load (node:internal/modules/cjs/loader:621:3)', // This file is not an actual Node.js core file. ' at Module.require [as weird/name] (node:internal/aaaaa/loader:735:19)', - ' at require (node:internal/modules/cjs/helpers:14:16)', + ' at require (node:internal/modules/helpers:14:16)', ' at Array.forEach ()', ` at ${process.cwd()}/test/parallel/test-util-inspect.js:2760:12`, ` at Object. (${process.cwd()}/node_modules/hyper_module/folder/file.js:2753:10)`,