mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
59e8d5fb91
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.9.0` → `3.9.1`](https://renovatebot.com/diffs/npm/@napi-rs%2fcli/3.9.0/3.9.1) |  |  |  |  | pnpm.catalog.default | patch | | [napi](https://redirect.github.com/napi-rs/napi-rs) | `3.12.2` → `3.12.3` |  |  |  |  | workspace.dependencies | patch | | [napi-derive](https://redirect.github.com/napi-rs/napi-rs) | `3.6.3` → `3.6.4` |  |  |  |  | workspace.dependencies | patch | --- ### Release Notes <details> <summary>napi-rs/napi-rs (@​napi-rs/cli)</summary> ### [`v3.9.1`](https://redirect.github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.9.0...@napi-rs/cli@3.9.1) [Compare Source](https://redirect.github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.9.0...@napi-rs/cli@3.9.1) </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:eyJjcmVhdGVkSW5WZXIiOiI0NC43MS4wIiwidXBkYXRlZEluVmVyIjoiNDQuNzEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Cameron Clark <cameron.clark@hey.com>
83 lines
2.1 KiB
JavaScript
83 lines
2.1 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, workerData } 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) {
|
|
// oxlint-disable-next-line no-eval -- WASI importScripts polyfill
|
|
;(0, eval)(fs.readFileSync(f, 'utf8') + '//# sourceURL=' + f)
|
|
},
|
|
postMessage: function (msg) {
|
|
if (parentPort) {
|
|
parentPort.postMessage(msg)
|
|
}
|
|
},
|
|
})
|
|
|
|
const emnapiContext = getDefaultContext()
|
|
|
|
const __cwd = process.cwd()
|
|
const __rootDir =
|
|
(workerData && typeof workerData.rootDir === 'string' && workerData.rootDir) ||
|
|
parse(__cwd).root
|
|
const __hostRoot =
|
|
(workerData && typeof workerData.hostRoot === 'string' && workerData.hostRoot) ||
|
|
(process.platform === 'android' ? __cwd : __rootDir)
|
|
|
|
const handler = new MessageHandler({
|
|
onLoad({ wasmModule, wasmMemory }) {
|
|
const wasi = new WASI({
|
|
version: 'preview1',
|
|
env: process.env,
|
|
preopens: {
|
|
[__rootDir]: __hostRoot,
|
|
[__hostRoot]: __hostRoot,
|
|
},
|
|
})
|
|
|
|
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)
|
|
}
|