esm: use primordials
Converted uses of Object and Map to use frozen built in primordials. PR-URL: https://github.com/nodejs/node/pull/26954 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
parent
6bc2ab19e9
commit
7a547098d5
@ -17,7 +17,12 @@ const { pathToFileURL, fileURLToPath } = require('internal/url');
|
|||||||
const { ERR_ENTRY_TYPE_MISMATCH,
|
const { ERR_ENTRY_TYPE_MISMATCH,
|
||||||
ERR_UNKNOWN_FILE_EXTENSION } = require('internal/errors').codes;
|
ERR_UNKNOWN_FILE_EXTENSION } = require('internal/errors').codes;
|
||||||
|
|
||||||
const realpathCache = new Map();
|
const {
|
||||||
|
Object,
|
||||||
|
SafeMap
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
|
const realpathCache = new SafeMap();
|
||||||
|
|
||||||
// const TYPE_NONE = 0;
|
// const TYPE_NONE = 0;
|
||||||
const TYPE_COMMONJS = 1;
|
const TYPE_COMMONJS = 1;
|
||||||
|
@ -22,6 +22,11 @@ const FunctionBind = Function.call.bind(Function.prototype.bind);
|
|||||||
|
|
||||||
const debug = require('internal/util/debuglog').debuglog('esm');
|
const debug = require('internal/util/debuglog').debuglog('esm');
|
||||||
|
|
||||||
|
const {
|
||||||
|
Object,
|
||||||
|
SafeMap
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
/* A Loader instance is used as the main entry point for loading ES modules.
|
/* A Loader instance is used as the main entry point for loading ES modules.
|
||||||
* Currently, this is a singleton -- there is only one used for loading
|
* Currently, this is a singleton -- there is only one used for loading
|
||||||
* the main module and everything in its dependency graph. */
|
* the main module and everything in its dependency graph. */
|
||||||
@ -35,7 +40,7 @@ class Loader {
|
|||||||
this.moduleMap = new ModuleMap();
|
this.moduleMap = new ModuleMap();
|
||||||
|
|
||||||
// Map of already-loaded CJS modules to use
|
// Map of already-loaded CJS modules to use
|
||||||
this.cjsCache = new Map();
|
this.cjsCache = new SafeMap();
|
||||||
|
|
||||||
// The resolver has the signature
|
// The resolver has the signature
|
||||||
// (specifier : string, parentURL : string, defaultResolve)
|
// (specifier : string, parentURL : string, defaultResolve)
|
||||||
|
@ -13,6 +13,7 @@ const createDynamicModule = require(
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const {
|
const {
|
||||||
SafeMap,
|
SafeMap,
|
||||||
|
JSON
|
||||||
} = primordials;
|
} = primordials;
|
||||||
const { fileURLToPath, URL } = require('url');
|
const { fileURLToPath, URL } = require('url');
|
||||||
const { debuglog } = require('internal/util/debuglog');
|
const { debuglog } = require('internal/util/debuglog');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user