8000 Implemented pyminify for our stdlib · pyscript/pyscript@b56d7b7 · GitHub
[go: up one dir, main page]

Skip to content

Commit b56d7b7

Browse files
committed
Implemented pyminify for our stdlib
1 parent 7166c32 commit b56d7b7

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

pyscript.core/rollup/stdlib.cjs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,24 @@ const {
44
statSync,
55
writeFileSync,
66
} = require("node:fs");
7+
8+
9+
const { spawnSync } = require("node:child_process");
10+
711
const { join } = require("node:path");
812

913
const crawl = (path, json) => {
1014
for (const file of readdirSync(path)) {
1115
const full = join(path, file);
12-
if (/\.py$/.test(file)) json[file] = readFileSync(full).toString();
16+
if (/\.py$/.test(file)) {
17+
if (process.env.NO_MIN)
18+
json[file] = readFileSync(full).toString();
19+
else {
20+
const { output: [error, result] } = spawnSync('pyminify', [full]);
21+
if (error) process.exit(1);
22+
json[file] = result.toString();
23+
}
24+
}
1325
else if (statSync(full).isDirectory() && !file.endsWith("_"))
1426
crawl(full, (json[file] = {}));
1527
}

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ micropip==0.5.0
1111
toml==0.10.2
1212
numpy==1.26.4
1313
pillow==10.3.0
14+
python-minifier==2.9.0
15+
setuptools=72.1.0

0 commit comments

Comments
 (0)
0