Files
Nathan Rajlich 1fa6397241 Move swc-playground-wasm into workbench/swc-playground (#1704)
* move swc-playground-wasm into workbench/swc-playground

Move the Rust/WASM source from packages/swc-playground-wasm into
workbench/swc-playground/wasm/ so it is no longer built as part of
the packages/* turbo filter in CI. The WASM build now runs as part
of the playground's own prebuild/dev scripts, avoiding Rust toolchain
failures in unrelated CI jobs.

* fix: ensure default rustup toolchain in wasm build

The Vercel build environment has rustup installed but no default
toolchain configured. Add a check for this and install stable
if needed. Also check for VERCEL env var in addition to CI.

* fix: ensure cargo bin dir is in PATH on Vercel

After cargo install wasm-pack, the binary lives in $CARGO_HOME/bin
which may not be in PATH on the Vercel build environment. Always
add the cargo bin directory to PATH after ensuring the toolchain.
2026-04-13 12:30:30 -07:00

27 lines
813 B
JavaScript

/**
* Copies the WASM build artifacts from wasm/pkg/
* into public/wasm/ so they can be served as static assets.
*/
import { copyFileSync, existsSync, mkdirSync } from 'node:fs';
const pkgDir = new URL('../wasm/pkg/', import.meta.url);
if (!existsSync(pkgDir)) {
console.error(
`WASM package not found at ${pkgDir}.\n` + 'Run "pnpm build:wasm" first.'
);
process.exit(1);
}
const publicWasmDir = new URL('../public/wasm/', import.meta.url);
mkdirSync(publicWasmDir, { recursive: true });
// Copy the .wasm binary and JS glue to public/ (served as static assets via CDN)
const files = ['swc_playground_wasm_bg.wasm', 'swc_playground_wasm.js'];
for (const file of files) {
copyFileSync(new URL(file, pkgDir), new URL(file, publicWasmDir));
}
console.log('WASM artifacts copied successfully.');