mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Implemented pyminify for our stdlib (#2140)
* Implemented pyminify for our stdlib * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
7166c32384
commit
f4c4edeb29
644
pyscript.core/package-lock.json
generated
644
pyscript.core/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pyscript/core",
|
"name": "@pyscript/core",
|
||||||
"version": "0.5.3",
|
"version": "0.5.5",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "PyScript",
|
"description": "PyScript",
|
||||||
"module": "./index.js",
|
"module": "./index.js",
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
"@codemirror/language": "^6.10.2",
|
"@codemirror/language": "^6.10.2",
|
||||||
"@codemirror/state": "^6.4.1",
|
"@codemirror/state": "^6.4.1",
|
||||||
"@codemirror/view": "^6.30.0",
|
"@codemirror/view": "^6.30.0",
|
||||||
"@playwright/test": "^1.45.3",
|
"@playwright/test": "1.45.3",
|
||||||
"@rollup/plugin-commonjs": "^26.0.1",
|
"@rollup/plugin-commonjs": "^26.0.1",
|
||||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||||
"@rollup/plugin-terser": "^0.4.4",
|
"@rollup/plugin-terser": "^0.4.4",
|
||||||
|
|||||||
Binary file not shown.
@@ -4,13 +4,27 @@ const {
|
|||||||
statSync,
|
statSync,
|
||||||
writeFileSync,
|
writeFileSync,
|
||||||
} = require("node:fs");
|
} = require("node:fs");
|
||||||
|
|
||||||
|
const { spawnSync } = require("node:child_process");
|
||||||
|
|
||||||
const { join } = require("node:path");
|
const { join } = require("node:path");
|
||||||
|
|
||||||
const crawl = (path, json) => {
|
const crawl = (path, json) => {
|
||||||
for (const file of readdirSync(path)) {
|
for (const file of readdirSync(path)) {
|
||||||
const full = join(path, file);
|
const full = join(path, file);
|
||||||
if (/\.py$/.test(file)) json[file] = readFileSync(full).toString();
|
if (/\.py$/.test(file)) {
|
||||||
else if (statSync(full).isDirectory() && !file.endsWith("_"))
|
if (process.env.NO_MIN) json[file] = readFileSync(full).toString();
|
||||||
|
else {
|
||||||
|
const {
|
||||||
|
output: [error, result],
|
||||||
|
} = spawnSync("pyminify", [
|
||||||
|
"--remove-literal-statements",
|
||||||
|
full,
|
||||||
|
]);
|
||||||
|
if (error) process.exit(1);
|
||||||
|
json[file] = result.toString();
|
||||||
|
}
|
||||||
|
} else if (statSync(full).isDirectory() && !file.endsWith("_"))
|
||||||
crawl(full, (json[file] = {}));
|
crawl(full, (json[file] = {}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,3 +11,5 @@ micropip==0.5.0
|
|||||||
toml==0.10.2
|
toml==0.10.2
|
||||||
numpy==1.26.4
|
numpy==1.26.4
|
||||||
pillow==10.3.0
|
pillow==10.3.0
|
||||||
|
python-minifier==2.9.0
|
||||||
|
setuptools==72.1.0
|
||||||
|
|||||||
Reference in New Issue
Block a user