[next] Bring in stdlib as artifact (#1666)

This commit is contained in:
Andrea Giammarchi
2023-09-01 18:24:49 +02:00
committed by GitHub
parent da3b43abdd
commit ef44df5dda
14 changed files with 144 additions and 66 deletions

View File

@@ -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",

View 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`,
);