mirror of
https://github.com/vercel/workflow.git
synced 2026-09-14 19:59:43 +08:00
1fa6397241
* 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.
27 lines
813 B
JavaScript
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.');
|