Skip to content

Commit

Permalink
web: Qualify the vanilla (MVP) WASM module with a name suffix
Browse files Browse the repository at this point in the history
Instead of the one with extensions enabled.
  • Loading branch information
torokati44 committed Jan 15, 2025
1 parent becce39 commit b793be9
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[target.'cfg(all())']
# NOTE that the web build overrides this setting in package.json via the RUSTFLAGS environment variable
# NOTE that the web build overrides this setting in tools/build_wasm.ts via the RUSTFLAGS environment variable
rustflags = [
# We need to specify this flag for all targets because Clippy checks all of our code against all targets
# and our web code does not compile without this flag
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ opt-level = 3
[profile.dev.package.nihav_duck]
opt-level = 3

# TODO: Set rustflags here instead of in web/core/package.json, when that
# TODO: Set rustflags here instead of in tools/build_wasm.ts, when that
# feature becomes stable. See: https://github.com/rust-lang/cargo/issues/10271
# Until then, these custom profiles let cargo keep the build cache alive
# across "dual-wasm" builds, separating it for the two .wasm modules.
[profile.web-vanilla-wasm]
[profile.web-wasm-mvp]
inherits = "release"

[profile.web-wasm-extensions]
Expand Down
2 changes: 1 addition & 1 deletion web/packages/core/src/internal/builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RuffleInstanceBuilder } from "../../dist/ruffle_web-wasm_extensions";
import type { RuffleInstanceBuilder } from "../../dist/ruffle_web";
import { BaseLoadOptions, Duration, SecsDuration } from "../public/config";

/**
Expand Down
2 changes: 1 addition & 1 deletion web/packages/core/src/internal/player/inner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RuffleHandle, ZipWriter } from "../../../dist/ruffle_web-wasm_extensions";
import type { RuffleHandle, ZipWriter } from "../../../dist/ruffle_web";
import {
AutoPlay,
ContextMenu,
Expand Down
10 changes: 5 additions & 5 deletions web/packages/core/src/load-ruffle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import type {

Check failure on line 12 in web/packages/core/src/load-ruffle.ts

View workflow job for this annotation

GitHub Actions / Test Node.js 22 / ubuntu-24.04

Replace `⏎····RuffleInstanceBuilder,⏎····ZipWriter,⏎` with `·RuffleInstanceBuilder,·ZipWriter·`

Check failure on line 12 in web/packages/core/src/load-ruffle.ts

View workflow job for this annotation

GitHub Actions / Test Node.js 23 / ubuntu-24.04

Replace `⏎····RuffleInstanceBuilder,⏎····ZipWriter,⏎` with `·RuffleInstanceBuilder,·ZipWriter·`
RuffleInstanceBuilder,
ZipWriter,
} from "../dist/ruffle_web-wasm_extensions";
} from "../dist/ruffle_web";
import { setPolyfillsOnLoad } from "./js-polyfills";

import { internalSourceApi } from "./internal/internal-source-api";
Expand Down Expand Up @@ -49,9 +49,9 @@ async function fetchRuffle(
).every(Boolean);

// @ts-expect-error TS2367 %FALLBACK_WASM% gets replaced in set_version.ts.
// %FALLBACK_WASM% is "ruffle_web" if this is a dual-wasm build.
// %FALLBACK_WASM% is "ruffle_web-wasm_mvp" if this is a dual-wasm build.
// We don't say we're falling back if we have only an extension build.
if (!extensionsSupported && "%FALLBACK_WASM%" === "ruffle_web") {
if (!extensionsSupported && "%FALLBACK_WASM%" === "ruffle_web-wasm_mvp") {
console.log(
"Some WebAssembly extensions are NOT available, falling back to the vanilla WebAssembly module",
);
Expand All @@ -68,12 +68,12 @@ async function fetchRuffle(
RuffleInstanceBuilder,
ZipWriter,
} = await (extensionsSupported
? import("../dist/ruffle_web-wasm_extensions")
? import("../dist/ruffle_web")
: // @ts-expect-error TS2307 TypeScript compiler is trying to do the import.
import("../dist/%FALLBACK_WASM%"));
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/%FALLBACK_WASM%_bg.wasm", import.meta.url);
const wasmResponse = await fetch(wasmUrl);
// The Pale Moon browser lacks full support for ReadableStream.
Expand Down
4 changes: 2 additions & 2 deletions web/packages/core/tools/build_wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ if (wasmSource === "cargo_and_store") {
}
buildWasm(

Check failure on line 163 in web/packages/core/tools/build_wasm.ts

View workflow job for this annotation

GitHub Actions / Test Node.js 22 / ubuntu-24.04

Replace `⏎····"web-wasm-extensions",⏎····"ruffle_web",⏎····hasWasmOpt,⏎····true,⏎····wasmSource,⏎` with `"web-wasm-extensions",·"ruffle_web",·hasWasmOpt,·true,·wasmSource`

Check failure on line 163 in web/packages/core/tools/build_wasm.ts

View workflow job for this annotation

GitHub Actions / Test Node.js 23 / ubuntu-24.04

Replace `⏎····"web-wasm-extensions",⏎····"ruffle_web",⏎····hasWasmOpt,⏎····true,⏎····wasmSource,⏎` with `"web-wasm-extensions",·"ruffle_web",·hasWasmOpt,·true,·wasmSource`
"web-wasm-extensions",
"ruffle_web-wasm_extensions",
"ruffle_web",
hasWasmOpt,
true,
wasmSource,
);
if (buildWasmMvp) {
buildWasm("web-vanilla-wasm", "ruffle_web", hasWasmOpt, false, wasmSource);
buildWasm("web-wasm-mvp", "ruffle_web-wasm_mvp", hasWasmOpt, false, wasmSource);

Check failure on line 171 in web/packages/core/tools/build_wasm.ts

View workflow job for this annotation

GitHub Actions / Test Node.js 22 / ubuntu-24.04

Replace `"web-wasm-mvp",·"ruffle_web-wasm_mvp",·hasWasmOpt,·false,·wasmSource` with `⏎········"web-wasm-mvp",⏎········"ruffle_web-wasm_mvp",⏎········hasWasmOpt,⏎········false,⏎········wasmSource,⏎····`

Check failure on line 171 in web/packages/core/tools/build_wasm.ts

View workflow job for this annotation

GitHub Actions / Test Node.js 23 / ubuntu-24.04

Replace `"web-wasm-mvp",·"ruffle_web-wasm_mvp",·hasWasmOpt,·false,·wasmSource` with `⏎········"web-wasm-mvp",⏎········"ruffle_web-wasm_mvp",⏎········hasWasmOpt,⏎········false,⏎········wasmSource,⏎····`
}
4 changes: 2 additions & 2 deletions web/packages/core/tools/set_version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ if (process.env["ENABLE_VERSION_SEAL"] === "true") {

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

const options = {
files: "dist/**",
Expand Down

0 comments on commit b793be9

Please sign in to comment.