Change first level build target of bin
This commit is contained in:
parent
dae1053ca8
commit
58892cbb56
@ -52,7 +52,25 @@ transformCodebase({
|
|||||||
|
|
||||||
fs.rmSync(join("dist", "ncc_out"), { recursive: true });
|
fs.rmSync(join("dist", "ncc_out"), { recursive: true });
|
||||||
|
|
||||||
patchDeprecatedBufferApiUsage(join("dist", "bin", "main.js"));
|
{
|
||||||
|
let hasBeenPatched = false;
|
||||||
|
|
||||||
|
fs.readdirSync(join("dist", "bin")).forEach(fileBasename => {
|
||||||
|
if (fileBasename !== "main.js" && !fileBasename.endsWith(".index.js")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { hasBeenPatched: hasBeenPatched_i } = patchDeprecatedBufferApiUsage(
|
||||||
|
join("dist", "bin", fileBasename)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hasBeenPatched_i) {
|
||||||
|
hasBeenPatched = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert(hasBeenPatched);
|
||||||
|
}
|
||||||
|
|
||||||
fs.chmodSync(
|
fs.chmodSync(
|
||||||
join("dist", "bin", "main.js"),
|
join("dist", "bin", "main.js"),
|
||||||
@ -93,6 +111,10 @@ run(
|
|||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
fs.readdirSync(join("dist", "ncc_out")).forEach(fileBasename =>
|
||||||
|
assert(!fileBasename.endsWith(".index.js"))
|
||||||
|
);
|
||||||
|
|
||||||
transformCodebase({
|
transformCodebase({
|
||||||
srcDirPath: join("dist", "ncc_out"),
|
srcDirPath: join("dist", "ncc_out"),
|
||||||
destDirPath: join("dist", "vite-plugin"),
|
destDirPath: join("dist", "vite-plugin"),
|
||||||
@ -105,7 +127,13 @@ transformCodebase({
|
|||||||
|
|
||||||
fs.rmSync(join("dist", "ncc_out"), { recursive: true });
|
fs.rmSync(join("dist", "ncc_out"), { recursive: true });
|
||||||
|
|
||||||
patchDeprecatedBufferApiUsage(join("dist", "vite-plugin", "index.js"));
|
{
|
||||||
|
const { hasBeenPatched } = patchDeprecatedBufferApiUsage(
|
||||||
|
join("dist", "vite-plugin", "index.js")
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(hasBeenPatched);
|
||||||
|
}
|
||||||
|
|
||||||
fs.rmSync(join("dist", "src"), { recursive: true, force: true });
|
fs.rmSync(join("dist", "src"), { recursive: true, force: true });
|
||||||
|
|
||||||
@ -127,7 +155,9 @@ function patchDeprecatedBufferApiUsage(filePath: string) {
|
|||||||
`var buffer = Buffer.allocUnsafe ? Buffer.allocUnsafe(toRead) : new Buffer(toRead);`
|
`var buffer = Buffer.allocUnsafe ? Buffer.allocUnsafe(toRead) : new Buffer(toRead);`
|
||||||
);
|
);
|
||||||
|
|
||||||
assert(after !== before, `Patch failed for ${relative(process.cwd(), filePath)}`);
|
|
||||||
|
|
||||||
fs.writeFileSync(filePath, Buffer.from(after, "utf8"));
|
fs.writeFileSync(filePath, Buffer.from(after, "utf8"));
|
||||||
|
|
||||||
|
const hasBeenPatched = after !== before;
|
||||||
|
|
||||||
|
return { hasBeenPatched };
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"extends": "../../tsproject.json",
|
"extends": "../../tsproject.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "CommonJS",
|
"module": "ES2020",
|
||||||
"target": "ES5",
|
"target": "ES2017",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"lib": ["es2015", "DOM", "ES2019.Object"],
|
"lib": ["es2015", "ES2019.Object"],
|
||||||
|
"moduleResolution": "node",
|
||||||
"outDir": "../../dist/bin",
|
"outDir": "../../dist/bin",
|
||||||
"rootDir": "."
|
"rootDir": "."
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user