Skip to content
Merged
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
6 changes: 4 additions & 2 deletions lib/internal/modules/esm/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModuleWrap>}
* @returns {ModuleWrap}
*/
#translate(url, format, source, isMain) {
this.validateLoadResult(url, format);
Expand All @@ -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;
}

/**
Expand Down
8 changes: 2 additions & 6 deletions lib/internal/modules/esm/translators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading