Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web: Qualify the vanilla (MVP) WASM module with a name suffix #19229

Merged
merged 1 commit into from
Jan 15, 2025
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
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
13 changes: 5 additions & 8 deletions web/packages/core/src/load-ruffle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import {
signExtensions,
referenceTypes,
} from "wasm-feature-detect";
import type {
RuffleInstanceBuilder,
ZipWriter,
} from "../dist/ruffle_web-wasm_extensions";
import type { RuffleInstanceBuilder, ZipWriter } from "../dist/ruffle_web";
import { setPolyfillsOnLoad } from "./js-polyfills";

import { internalSourceApi } from "./internal/internal-source-api";
Expand Down Expand Up @@ -49,9 +46,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 +65,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
16 changes: 8 additions & 8 deletions web/packages/core/tools/build_wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ if (wasmSource === "cargo_and_store") {
rmSync("../../dist", { recursive: true, force: true });
mkdirSync("../../dist");
}
buildWasm(
"web-wasm-extensions",
"ruffle_web-wasm_extensions",
hasWasmOpt,
true,
wasmSource,
);
buildWasm("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,
);
}
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