diff --git a/lib/internal/modules/esm/loader.js b/lib/internal/modules/esm/loader.js index bc36fa2e26b8d0..5d90b5f4c8c8f4 100644 --- a/lib/internal/modules/esm/loader.js +++ b/lib/internal/modules/esm/loader.js @@ -537,7 +537,7 @@ class ModuleLoader { * matching translators. * @param {ModuleSource} source Source of the module to be translated. * @param {boolean} isMain Whether the module to be translated is the entry point. - * @returns {ModuleWrap | Promise} + * @returns {ModuleWrap} */ #translate(url, format, source, isMain) { this.validateLoadResult(url, format); @@ -547,7 +547,9 @@ class ModuleLoader { throw new ERR_UNKNOWN_MODULE_FORMAT(format, url); } - return FunctionPrototypeCall(translator, this, url, source, isMain); + const result = FunctionPrototypeCall(translator, this, url, source, isMain); + assert(result instanceof ModuleWrap); + return result; } /** diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js index b6ac42302a126b..98bdb384269ced 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -494,18 +494,14 @@ translators.set('json', function jsonStrategy(url, source) { * >} [[Instance]] slot proxy for WebAssembly Module Record */ const wasmInstances = new SafeWeakMap(); -translators.set('wasm', async function(url, source) { +translators.set('wasm', function(url, source) { assertBufferSource(source, false, 'load'); debug(`Translating WASMModule ${url}`); let compiled; try { - // TODO(joyeecheung): implement a translator that just uses - // compiled = new WebAssembly.Module(source) to compile it - // synchronously. - compiled = await WebAssembly.compile(source, { - // The ESM Integration auto-enables Wasm JS builtins by default when available. + compiled = new WebAssembly.Module(source, { builtins: ['js-string'], }); } catch (err) {