Skip to content
Merged
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
11 changes: 8 additions & 3 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,20 +490,25 @@ async function getWasmBinary(binaryFile) {
var splitModuleProxyHandler = {
get(target, moduleName, receiver) {
if (moduleName.startsWith('placeholder')) {
let secondaryFile;
if (moduleName == 'placeholder') { // old format
secondaryFile = wasmBinaryFile.slice(0, -5) + '.deferred.wasm';
Comment on lines +494 to +495
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case I wasn't clear, the plan is to remove this special old format handling after WebAssembly/binaryen#7975 lands.

} else { // new format
let moduleID = moduleName.split('.')[1];
secondaryFile = wasmBinaryFile.slice(0, -5) + '.' + moduleID + '.wasm';
}
return new Proxy({}, {
get(target, base, receiver) {
return (...args) => {
#if ASYNCIFY == 2
throw new Error('Placeholder function "' + base + '" should not be called when using JSPI.');
#else
// TODO: Implement multi-split module loading
#if RUNTIME_DEBUG
dbg(`placeholder function called: ${base}`);
#endif
var imports = {'primary': wasmExports};
// Replace '.wasm' suffix with '.deferred.wasm'.
var deferred = wasmBinaryFile.slice(0, -5) + '.deferred.wasm'
loadSplitModule(deferred, imports, base);
loadSplitModule(secondaryFile, imports, base);
#if RUNTIME_DEBUG
dbg('instantiated deferred module, continuing');
#endif
Expand Down