mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
b937e3e2f1
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Adoption](https://docs.renovatebot.com/merge-confidence/) | [Passing](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | Type | Update | |---|---|---|---|---|---|---|---| | [@napi-rs/cli](https://napi.rs/) ([source](https://redirect.github.com/napi-rs/napi-rs)) | [`3.7.4` → `3.8.2`](https://renovatebot.com/diffs/npm/@napi-rs%2fcli/3.7.4/3.8.2) |  |  |  |  | pnpm.catalog.default | minor | | [napi](https://redirect.github.com/napi-rs/napi-rs) | `3.11.0` → `3.12.0` |  |  |  |  | workspace.dependencies | minor | | [napi-build](https://redirect.github.com/napi-rs/napi-rs) | `2.3.2` → `2.4.0` |  |  |  |  | workspace.dependencies | minor | | [napi-derive](https://redirect.github.com/napi-rs/napi-rs) | `3.6.0` → `3.6.2` |  |  |  |  | workspace.dependencies | patch | --- ### Release Notes <details> <summary>napi-rs/napi-rs (@​napi-rs/cli)</summary> ### [`v3.8.2`](https://redirect.github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.8.1...@napi-rs/cli@3.8.2) [Compare Source](https://redirect.github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.8.1...@napi-rs/cli@3.8.2) ### [`v3.8.1`](https://redirect.github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.8.0...@napi-rs/cli@3.8.1) [Compare Source](https://redirect.github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.8.0...@napi-rs/cli@3.8.1) ### [`v3.8.0`](https://redirect.github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.7.4...@napi-rs/cli@3.8.0) [Compare Source](https://redirect.github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.7.4...@napi-rs/cli@3.8.0) </details> --- ### Configuration 📅 **Schedule**: (in timezone Asia/Shanghai) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/oxc-project/oxc). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yODAuMCIsInVwZGF0ZWRJblZlciI6IjQ0LjMuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Cameron <cameron.clark@hey.com>
75 lines
1.8 KiB
JavaScript
75 lines
1.8 KiB
JavaScript
import fs from "node:fs";
|
|
import { createRequire } from "node:module";
|
|
import { parse } from "node:path";
|
|
import { WASI } from "node:wasi";
|
|
import { parentPort, Worker } from "node:worker_threads";
|
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
const {
|
|
instantiateNapiModuleSync,
|
|
MessageHandler,
|
|
getDefaultContext,
|
|
emnapiAsyncWorkPlugin,
|
|
emnapiTSFNPlugin,
|
|
} = require("@napi-rs/wasm-runtime");
|
|
|
|
if (parentPort) {
|
|
parentPort.on("message", (data) => {
|
|
globalThis.onmessage({ data });
|
|
});
|
|
}
|
|
|
|
Object.assign(globalThis, {
|
|
self: globalThis,
|
|
require,
|
|
Worker,
|
|
importScripts: function (f) {
|
|
;(0, eval)(fs.readFileSync(f, "utf8") + "//# sourceURL=" + f);
|
|
},
|
|
postMessage: function (msg) {
|
|
if (parentPort) {
|
|
parentPort.postMessage(msg);
|
|
}
|
|
},
|
|
});
|
|
|
|
const emnapiContext = getDefaultContext();
|
|
|
|
const __rootDir = parse(process.cwd()).root;
|
|
|
|
const handler = new MessageHandler({
|
|
onLoad({ wasmModule, wasmMemory }) {
|
|
const wasi = new WASI({
|
|
version: 'preview1',
|
|
env: process.env,
|
|
preopens: {
|
|
[__rootDir]: __rootDir,
|
|
},
|
|
});
|
|
|
|
return instantiateNapiModuleSync(wasmModule, {
|
|
childThread: true,
|
|
wasi,
|
|
context: emnapiContext,
|
|
// The wasm links a "basic" emnapi archive (no C async-work /
|
|
// threadsafe-function implementations), so every thread that
|
|
// instantiates it must provide the JavaScript implementations
|
|
// through the emnapi plugins.
|
|
plugins: [emnapiAsyncWorkPlugin, emnapiTSFNPlugin],
|
|
overwriteImports(importObject) {
|
|
importObject.env = {
|
|
...importObject.env,
|
|
...importObject.napi,
|
|
...importObject.emnapi,
|
|
memory: wasmMemory
|
|
};
|
|
},
|
|
});
|
|
},
|
|
});
|
|
|
|
globalThis.onmessage = function (e) {
|
|
handler.handle(e);
|
|
};
|