Files
oxc/napi/transform/scripts/patch.js
T
BoshenandYuji Sugiura 523a30a016 style(all): apply oxfmt default options (#16091)
Embrace the defaults!

---------

Co-authored-by: Yuji Sugiura <y.sugiura.0316@gmail.com>
2025-11-25 15:56:24 +09:00

21 lines
470 B
JavaScript

import fs from "node:fs";
import { join as pathJoin } from "node:path";
const path = pathJoin(import.meta.dirname, "../index.js");
let data = fs.readFileSync(path, "utf-8");
data = data.replace(
"\nif (!nativeBinding) {",
(s) =>
`
if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) {
try {
nativeBinding = require('./webcontainer-fallback.cjs');
} catch (err) {
loadErrors.push(err)
}
}
` + s,
);
fs.writeFileSync(path, data);