Skip to content

Commit

Permalink
web: Don't unnecessarily duplicate the module for single WASM builds
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhjacobs committed Jan 13, 2025
1 parent 8bb90c0 commit 23ed90e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 3 additions & 2 deletions web/packages/core/src/load-ruffle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ async function fetchRuffle(
ZipWriter,
} = await (extensionsSupported
? import("../dist/ruffle_web-wasm_extensions")
: import("../dist/ruffle_web"));
: // @ts-expect-error TypeScript compiler is trying to do the import
import("../dist/%WASM_MVP%"));
let response;
const wasmUrl = extensionsSupported
? new URL("../dist/ruffle_web-wasm_extensions_bg.wasm", import.meta.url)
: new URL("../dist/ruffle_web_bg.wasm", import.meta.url);
: new URL("../dist/%WASM_MVP%_bg.wasm", import.meta.url);
const wasmResponse = await fetch(wasmUrl);
// The Pale Moon browser lacks full support for ReadableStream.
// However, ReadableStream itself is defined.
Expand Down
15 changes: 14 additions & 1 deletion web/packages/core/tools/set_version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ if (process.env["ENABLE_VERSION_SEAL"] === "true") {
}
}

const wasmMvpName =
process.env["BUILD_WASM_MVP"] === "true"
? "ruffle_web"
: "ruffle_web-wasm_extensions";

const options = {
files: "dist/**",
from: [
Expand All @@ -72,8 +77,16 @@ const options = {
/%VERSION_CHANNEL%/g,
/%BUILD_DATE%/g,
/%COMMIT_HASH%/g,
/%WASM_MVP%/g,
],
to: [
versionNumber,
versionName,
versionChannel,
buildDate,
commitHash,
wasmMvpName,
],
to: [versionNumber, versionName, versionChannel, buildDate, commitHash],
};

replaceInFileSync(options);

0 comments on commit 23ed90e

Please sign in to comment.