Skip to content

Commit 0a32fbc

Browse files
committed
Added Python minification
1 parent 32b920c commit 0a32fbc

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pyscript.js
1111
!esm/custom/pyscript.js
1212
esm/worker/xworker.js
1313
esm/worker/__template.js
14+
env/
1415
types/
1516
esm/python/
1617
esm/3rd-party/*.js

docs/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,6 @@
8686
"to-json-callback": "^0.1.1"
8787
},
8888
"worker": {
89-
"blob": "sha256-Iw1wZsJMQwzFnKCO2gnLnjBJgJPmV0yMVne4B+uDK3I="
89+
"blob": "sha256-vUQw9WQdmhNh505apJbhfwWaPJRRi2P9WxMeR1cKArY="
9090
}
9191
}

rollup/build_python.cjs

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@
22

33
const { join, resolve } = require('node:path');
44
const { readdirSync, readFileSync, writeFileSync } = require('node:fs');
5+
const { spawnSync } = require("node:child_process");
56

67
const PYTHON_DIR = resolve(join(__dirname, '..', 'python'));
78
const PYTHON_JS_DIR = resolve(join(__dirname, '..', 'esm', 'python'));
89

910
const { stringify } = JSON;
1011

1112
for (const file of readdirSync(PYTHON_DIR)) {
12-
const python = stringify(
13-
readFileSync(join(PYTHON_DIR, file)).toString()
14-
);
13+
const {
14+
output: [error, result],
15+
} = spawnSync('pyminify', [
16+
'--remove-literal-statements',
17+
join(PYTHON_DIR, file),
18+
]);
19+
if (error) process.exit(1);
20+
const python = stringify(result.toString());
1521
writeFileSync(
1622
join(PYTHON_JS_DIR, file.replace(/\.py$/, '.js')),
1723
`// ⚠️ DO NOT MODIFY - SOURCE FILE: "../../python/${file}"

0 commit comments

Comments
 (0)