mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
[next] Bring in stdlib as artifact (#1666)
This commit is contained in:
committed by
GitHub
parent
da3b43abdd
commit
ef44df5dda
@@ -3,14 +3,8 @@
|
||||
|
||||
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
||||
import terser from "@rollup/plugin-terser";
|
||||
import { string } from "rollup-plugin-string";
|
||||
|
||||
const plugins = [
|
||||
string({
|
||||
// Required to be specified
|
||||
include: "**/*.py",
|
||||
}),
|
||||
];
|
||||
const plugins = [];
|
||||
|
||||
export default {
|
||||
input: "./src/core.js",
|
||||
|
||||
29
pyscript.core/rollup/stdlib.cjs
Normal file
29
pyscript.core/rollup/stdlib.cjs
Normal file
@@ -0,0 +1,29 @@
|
||||
const {
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
statSync,
|
||||
writeFileSync,
|
||||
} = require("node:fs");
|
||||
const { join } = require("node:path");
|
||||
|
||||
const crawl = (path, json) => {
|
||||
for (const file of readdirSync(path)) {
|
||||
const full = join(path, file);
|
||||
if (/\.py$/.test(file)) json[file] = readFileSync(full).toString();
|
||||
else if (statSync(full).isDirectory() && !file.endsWith("_"))
|
||||
crawl(full, (json[file] = {}));
|
||||
}
|
||||
};
|
||||
|
||||
const json = {};
|
||||
|
||||
crawl(join(__dirname, "..", "src", "stdlib"), json);
|
||||
|
||||
writeFileSync(
|
||||
join(__dirname, "..", "src", "stdlib", "pyscript.js"),
|
||||
`// ⚠️ This file is an artifact: DO NOT MODIFY\nexport default ${JSON.stringify(
|
||||
json,
|
||||
null,
|
||||
" ",
|
||||
)};\n`,
|
||||
);
|
||||
Reference in New Issue
Block a user