esm: use primordials · nodejs/node@7a54709 (original) (raw)
3 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -17,7 +17,12 @@ const { pathToFileURL, fileURLToPath } = require('internal/url'); | ||
17 | 17 | const { ERR_ENTRY_TYPE_MISMATCH, |
18 | 18 | ERR_UNKNOWN_FILE_EXTENSION } = require('internal/errors').codes; |
19 | 19 | |
20 | -const realpathCache = new Map(); | |
20 | +const { | |
21 | + Object, | |
22 | + SafeMap | |
23 | +} = primordials; | |
24 | + | |
25 | +const realpathCache = new SafeMap(); | |
21 | 26 | |
22 | 27 | // const TYPE_NONE = 0; |
23 | 28 | const TYPE_COMMONJS = 1; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -22,6 +22,11 @@ const FunctionBind = Function.call.bind(Function.prototype.bind); | ||
22 | 22 | |
23 | 23 | const debug = require('internal/util/debuglog').debuglog('esm'); |
24 | 24 | |
25 | +const { | |
26 | + Object, | |
27 | + SafeMap | |
28 | +} = primordials; | |
29 | + | |
25 | 30 | /* A Loader instance is used as the main entry point for loading ES modules. |
26 | 31 | * Currently, this is a singleton -- there is only one used for loading |
27 | 32 | * the main module and everything in its dependency graph. */ |
@@ -35,7 +40,7 @@ class Loader { | ||
35 | 40 | this.moduleMap = new ModuleMap(); |
36 | 41 | |
37 | 42 | // Map of already-loaded CJS modules to use |
38 | -this.cjsCache = new Map(); | |
43 | +this.cjsCache = new SafeMap(); | |
39 | 44 | |
40 | 45 | // The resolver has the signature |
41 | 46 | // (specifier : string, parentURL : string, defaultResolve) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -13,6 +13,7 @@ const createDynamicModule = require( | ||
13 | 13 | const fs = require('fs'); |
14 | 14 | const { |
15 | 15 | SafeMap, |
16 | +JSON | |
16 | 17 | } = primordials; |
17 | 18 | const { fileURLToPath, URL } = require('url'); |
18 | 19 | const { debuglog } = require('internal/util/debuglog'); |