Skip to content
Merged
Changes from 1 commit
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
Next Next commit
esm: mark importAssertions as required
We already always specify a value, and failing to do so would likely be
a bug.
  • Loading branch information
aduh95 committed Jan 10, 2023
commit 0b65872e983b3b84220d74d74119973ae7704adb
16 changes: 4 additions & 12 deletions lib/internal/modules/esm/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,21 +295,15 @@ class ESMLoader {
* @param {string} originalSpecifier The specified URL path of the module to
* be resolved.
* @param {string} [parentURL] The URL path of the module's parent.
* @param {ImportAssertions} [importAssertions] Assertions from the import
* @param {ImportAssertions} importAssertions Assertions from the import
* statement or expression.
* @returns {Promise<{ format: string, url: URL['href'] }>}
*/
async resolve(
originalSpecifier,
parentURL,
importAssertions = { __proto__: null },
) {
async resolve(originalSpecifier, parentURL, importAssertions) {
if (this.#hooks) {
return this.#hooks.resolve(originalSpecifier, parentURL, importAssertions);
}
if (!this.#defaultResolve) {
this.#defaultResolve = require('internal/modules/esm/resolve').defaultResolve;
}
this.#defaultResolve ??= require('internal/modules/esm/resolve').defaultResolve;
Comment thread
aduh95 marked this conversation as resolved.
Outdated
const context = {
__proto__: null,
conditions: this.#defaultConditions,
Expand All @@ -332,9 +326,7 @@ class ESMLoader {
if (this.#hooks) {
loadResult = await this.#hooks.load(url, context);
} else {
if (!this.#defaultLoad) {
this.#defaultLoad = require('internal/modules/esm/load').defaultLoad;
}
this.#defaultLoad ??= require('internal/modules/esm/load').defaultLoad;
Comment thread
aduh95 marked this conversation as resolved.
Outdated
loadResult = await this.#defaultLoad(url, context);
}

Expand Down