mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 10:17:23 -05:00
34 lines
1.0 KiB
JavaScript
34 lines
1.0 KiB
JavaScript
const { readdirSync, writeFileSync } = require("node:fs");
|
|
const { join } = require("node:path");
|
|
|
|
const plugins = [""];
|
|
|
|
for (const file of readdirSync(join(__dirname, "..", "src", "plugins"))) {
|
|
if (/\.js$/.test(file)) {
|
|
const name = file.slice(0, -3);
|
|
const key = /^[a-zA-Z0-9$_]+$/.test(name)
|
|
? name
|
|
: `[${JSON.stringify(name)}]`;
|
|
const value = JSON.stringify(`./plugins/${file}`);
|
|
plugins.push(
|
|
// this comment is needed to avoid bundlers eagerly embedding lazy
|
|
// dependencies, causing all sort of issues once in production
|
|
// ⚠️ THIS HAS TO BE LIKE THIS or prettier changes it every single time
|
|
` ${key}: () =>
|
|
import(
|
|
/* webpackIgnore: true */
|
|
${value}
|
|
),`,
|
|
);
|
|
}
|
|
}
|
|
|
|
plugins.push("");
|
|
|
|
writeFileSync(
|
|
join(__dirname, "..", "src", "plugins.js"),
|
|
`// ⚠️ This file is an artifact: DO NOT MODIFY\nexport default {${plugins.join(
|
|
"\n",
|
|
)}};\n`,
|
|
);
|