mirror of
https://github.com/aphrody-labs/oxc.git
synced 2026-10-15 06:39:17 +00:00
## Summary - add threadless `wasm32-wasip1` builds and generated loaders for parser, minify, transform, transform-react, and transform-relay - use the threadless bindings for browser and Cloudflare Workers while preserving threaded WASI and WebContainer fallbacks - build and publish the new target in CI and release workflows Closes #25271 ## Testing - native NAPI builds and package tests: 1,091 passed - parser Chromium browser tests passed - local workerd smoke tests passed for all five packages - deployed Workers using local package tarballs passed for all five packages and reported `wasm32-wasip1` - packed main-package file lists match the published `0.150.0` packages - `just fmt`, `just check`, `just lint`, `just doc`, `just ast`, targeted Oxlint, typos, and `git diff --check` passed - `just ready` reaches three unrelated Oxlint ANSI-color snapshot mismatches in this non-interactive environment; no pending snapshots remain ## AI assistance Codex was used to help implement and test this change. The contributor remains responsible for reviewing and understanding the changes before merge.
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
import fs from "node:fs";
|
|
import { join as pathJoin } from "node:path";
|
|
|
|
import { disableReusedWorkers } from "../../disable-reused-workers.mjs";
|
|
|
|
const packageDir = pathJoin(import.meta.dirname, "..");
|
|
disableReusedWorkers(pathJoin(packageDir, "transform-react.wasi-browser.js"));
|
|
|
|
const path = pathJoin(packageDir, "index.js");
|
|
|
|
let data = fs.readFileSync(path, "utf-8");
|
|
data = data.replace(
|
|
"\nif (!nativeBinding) {",
|
|
(source) =>
|
|
`
|
|
if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) {
|
|
try {
|
|
nativeBinding = require('./webcontainer-fallback.cjs');
|
|
} catch (err) {
|
|
loadErrors.push(err)
|
|
}
|
|
}
|
|
` + source,
|
|
);
|
|
fs.writeFileSync(path, data);
|
|
|
|
const workerPath = pathJoin(packageDir, "wasi-worker-browser.mjs");
|
|
const worker = fs.readFileSync(workerPath, "utf-8").replaceAll(/[ \t]+$/gmu, "");
|
|
fs.writeFileSync(workerPath, worker);
|
|
|
|
const wasip1BrowserPath = pathJoin(packageDir, "transform-react.wasip1-browser.js");
|
|
const wasip1Browser = fs.readFileSync(wasip1BrowserPath, "utf-8").replaceAll(/[ \t]+$/gmu, "");
|
|
fs.writeFileSync(wasip1BrowserPath, wasip1Browser);
|