Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esm: use primordials #26954

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/internal/modules/esm/default_resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ const { pathToFileURL, fileURLToPath } = require('internal/url');
const { ERR_ENTRY_TYPE_MISMATCH,
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_COMMONJS = 1;
Expand Down
7 changes: 6 additions & 1 deletion lib/internal/modules/esm/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ const FunctionBind = Function.call.bind(Function.prototype.bind);

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.
* Currently, this is a singleton -- there is only one used for loading
* the main module and everything in its dependency graph. */
Expand All @@ -35,7 +40,7 @@ class Loader {
this.moduleMap = new ModuleMap();

// Map of already-loaded CJS modules to use
this.cjsCache = new Map();
this.cjsCache = new SafeMap();

// The resolver has the signature
// (specifier : string, parentURL : string, defaultResolve)
Expand Down
1 change: 1 addition & 0 deletions lib/internal/modules/esm/translators.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const createDynamicModule = require(
const fs = require('fs');
const {
SafeMap,
JSON
} = primordials;
const { fileURLToPath, URL } = require('url');
const { debuglog } = require('internal/util/debuglog');
Expand Down