Skip to content

Commit 6f99e40

Browse files
committed
Remove terser
Signed-off-by: paulober <[email protected]>
1 parent 5ba7790 commit 6f99e40

File tree

5 files changed

+45
-50
lines changed

5 files changed

+45
-50
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@
646646
"scripts": {
647647
"vscode:uninstall": "node ./dist/vscodeUninstall.mjs",
648648
"vscode:prepublish": "npm run package",
649-
"postinstall": "patch-package && node ./scripts/postinstall.js",
649+
"postinstall": "patch-package && node ./scripts/postinstall.mjs",
650650
"cp-prebuilds": "node -e \"const fs=require('fs');fs.rmSync('prebuilds',{recursive:true,force:true});fs.cpSync('node_modules/@serialport/bindings-cpp/prebuilds','prebuilds',{recursive:true});\"",
651651
"compile-uninstaller": "rollup -c uninstall.rollup.config.mjs --environment BUILD:production",
652652
"compile": "rollup -c && npm run compile-uninstaller",
@@ -664,7 +664,6 @@
664664
"@rollup/plugin-commonjs": "^28.0.6",
665665
"@rollup/plugin-json": "^6.1.0",
666666
"@rollup/plugin-node-resolve": "^16.0.1",
667-
"@rollup/plugin-terser": "^0.4.4",
668667
"@rollup/plugin-typescript": "^12.1.4",
669668
"@serialport/bindings-cpp": "^13.0.1",
670669
"@types/eslint": "^9.6.1",

rollup.config.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import commonjs from '@rollup/plugin-commonjs';
22
import { nodeResolve } from '@rollup/plugin-node-resolve';
3-
import terser from '@rollup/plugin-terser';
43
import typescript from '@rollup/plugin-typescript';
54
import json from '@rollup/plugin-json';
65

@@ -37,7 +36,6 @@ export default {
3736
typescript({
3837
tsconfig: 'tsconfig.json',
3938
}),
40-
isProduction && terser(),
4139
// required by axios and serialport
4240
json(),
4341
],

scripts/postinstall.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

scripts/postinstall.mjs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env node
2+
import { spawnSync } from "node:child_process";
3+
import { existsSync, mkdirSync } from "node:fs";
4+
5+
const PKG = "micropython-rp2-rpi_pico2_w-stubs==1.26.*";
6+
const TARGET = "./mpy_stubs";
7+
8+
if (!existsSync(TARGET)) mkdirSync(TARGET, { recursive: true });
9+
10+
const candidates = [];
11+
if (process.env.PYTHON) candidates.push(process.env.PYTHON);
12+
if (process.platform === "win32") {
13+
candidates.push("py -3", "py", "python", "python3");
14+
} else {
15+
candidates.push("python3", "python");
16+
}
17+
18+
function findPython() {
19+
for (const c of candidates) {
20+
const [exe, ...pre] = c.split(" ");
21+
// has pip?
22+
let r = spawnSync(exe, [...pre, "-m", "pip", "--version"], { encoding: "utf8" });
23+
if (r.status !== 0) continue;
24+
// is Python 3?
25+
r = spawnSync(exe, [...pre, "-c", "import sys; print(sys.version_info.major)"], { encoding: "utf8" });
26+
if (r.status !== 0 || String(r.stdout).trim() !== "3") continue;
27+
return { exe, pre };
28+
}
29+
return null;
30+
}
31+
32+
const py = findPython();
33+
if (!py) {
34+
console.warn("[postinstall] No usable Python 3 with pip found. Tried:", candidates.join(", "));
35+
console.warn('Install Python 3 and ensure it is on PATH (Windows: the "py" launcher is recommended).');
36+
process.exit(0); // change to 1 if you want to fail the install
37+
}
38+
39+
const args = [...py.pre, "-m", "pip", "install", "-U", PKG, "--target", TARGET, "--no-user"];
40+
const run = spawnSync(py.exe, args, { stdio: "inherit" });
41+
if (run.status !== 0) {
42+
console.error("[postinstall] pip install failed.");
43+
process.exit(run.status ?? 1);
44+
}

uninstall.rollup.config.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import commonjs from '@rollup/plugin-commonjs';
22
import { nodeResolve } from '@rollup/plugin-node-resolve';
3-
import terser from '@rollup/plugin-terser';
43

54
export default {
65
input: './vscodeUninstall.mjs',
@@ -15,6 +14,5 @@ export default {
1514
preferBuiltins: true,
1615
}),
1716
commonjs(),
18-
terser(),
1917
],
2018
};

0 commit comments

Comments
 (0)