Skip to content

Commit 3743406

Browse files
JakobJingleheimerdanielleadams
authored andcommittedOct 12, 2021
esm: consolidate ESM loader hooks
doc: update ESM hook examples esm: fix unsafe primordial doc: fix ESM example linting esm: allow source of type ArrayBuffer doc: update ESM hook changelog to include resolve format esm: allow all ArrayBuffers and TypedArrays for load hook source doc: tidy code & API docs doc: convert ESM source table header from Title Case to Sentence case doc: add detailed explanation for getPackageType esm: add caveat that ESMLoader::import() must NOT be renamed esm: tidy code declaration of getFormat protocolHandlers doc: correct ESM doc link (bad conflict resolution) doc: update ESM hook limitation for CJS esm: tweak preload description doc: update ESM getPackageType() example explanation PR-URL: #37468 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
1 parent 1ef2cf8 commit 3743406

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+971
-545
lines changed
 

‎doc/api/esm.md

+163-149
Large diffs are not rendered by default.

‎lib/internal/modules/cjs/loader.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -981,14 +981,14 @@ Module.prototype.load = function(filename) {
981981
Module._extensions[extension](this, filename);
982982
this.loaded = true;
983983

984-
const ESMLoader = asyncESM.ESMLoader;
984+
const esmLoader = asyncESM.esmLoader;
985985
// Create module entry at load time to snapshot exports correctly
986986
const exports = this.exports;
987987
// Preemptively cache
988988
if ((module?.module === undefined ||
989989
module.module.getStatus() < kEvaluated) &&
990-
!ESMLoader.cjsCache.has(this))
991-
ESMLoader.cjsCache.set(this, exports);
990+
!esmLoader.cjsCache.has(this))
991+
esmLoader.cjsCache.set(this, exports);
992992
};
993993

994994

@@ -1022,7 +1022,7 @@ function wrapSafe(filename, content, cjsModuleInstance) {
10221022
lineOffset: 0,
10231023
displayErrors: true,
10241024
importModuleDynamically: async (specifier) => {
1025-
const loader = asyncESM.ESMLoader;
1025+
const loader = asyncESM.esmLoader;
10261026
return loader.import(specifier, normalizeReferrerURL(filename));
10271027
},
10281028
});
@@ -1037,7 +1037,7 @@ function wrapSafe(filename, content, cjsModuleInstance) {
10371037
], {
10381038
filename,
10391039
importModuleDynamically(specifier) {
1040-
const loader = asyncESM.ESMLoader;
1040+
const loader = asyncESM.esmLoader;
10411041
return loader.import(specifier, normalizeReferrerURL(filename));
10421042
},
10431043
});

0 commit comments

Comments
 (0)
Please sign in to comment.