Skip to content

Commit 07c89af

Browse files
committed
Instrument CI to build minified python
1 parent c791c74 commit 07c89af

File tree

9 files changed

+117
-105
lines changed

9 files changed

+117
-105
lines changed

.github/workflows/node.js.yml

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ jobs:
2121
with:
2222
node-version: ${{ matrix.node-version }}
2323
cache: 'npm'
24+
- run: python -m venv env
25+
- run: source env/bin/activate
26+
- run: pip install --upgrade pip
27+
- run: pip install --ignore-requires-python python-minifier
28+
- run: pip install setuptools
2429
- run: npm ci
2530
- run: npx playwright install
2631
- run: npm run build

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.

docs/zip-BIfA-Q-T.js.map

-1
This file was deleted.

docs/zip-BIfA-Q-T.js renamed to docs/zip-DrwYHuF9.js

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

docs/zip-DrwYHuF9.js.map

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

package-lock.json

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

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@
4242
"@playwright/test": "^1.46.1",
4343
"@rollup/plugin-node-resolve": "^15.2.3",
4444
"@rollup/plugin-terser": "^0.4.4",
45-
"@zip.js/zip.js": "^2.7.51",
45+
"@zip.js/zip.js": "^2.7.52",
4646
"c8": "^10.1.2",
4747
"chokidar": "^3.6.0",
4848
"eslint": "^9.9.1",
4949
"linkedom": "^0.18.4",
50-
"rollup": "^4.21.1",
50+
"rollup": "^4.21.2",
5151
"static-handler": "^0.4.3",
5252
"typescript": "^5.5.4"
5353
},
@@ -86,6 +86,6 @@
8686
"to-json-callback": "^0.1.1"
8787
},
8888
"worker": {
89-
"blob": "sha256-QDmhtpGRALCZn/gNlUmUSRUiiNDmiCk9Pn61k6Addho="
89+
"blob": "sha256-n5bp7XbiMOC5xSM8r1BjWIl0efV5DHH41AoMDzRWNdg="
9090
}
9191
}

rollup/build_python.cjs

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
// ⚠️ This file creates Python modules as JS TextEncoder().encode results
22

33
const { join, resolve } = require('node:path');
4-
const { readdirSync, readFileSync, writeFileSync } = require('node:fs');
4+
const { readdirSync, 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 full = join(PYTHON_DIR, file);
14+
const {
15+
output: [error, result],
16+
} = spawnSync("pyminify", [
17+
"--remove-literal-statements",
18+
full,
19+
]);
20+
if (error) process.exit(1);
21+
const python = stringify(result.toString());
1522
writeFileSync(
1623
join(PYTHON_JS_DIR, file.replace(/\.py$/, '.js')),
1724
`// ⚠️ DO NOT MODIFY - SOURCE FILE: "../../python/${file}"

0 commit comments

Comments
 (0)