♻️ Refactor bundle mechanism

Mainly leave shadow-cljs for build cljs stuff and use esbuild
for bundle all js dependencies, completly avoiding all possible
incompatibility issues between js libraries and google closure
compiler.
This commit is contained in:
Andrey Antukh 2024-10-31 16:43:20 +01:00
parent 366bca5f93
commit 607deb31dc
45 changed files with 2833 additions and 257 deletions

View file

@ -180,12 +180,21 @@ export async function watch(baseDir, predicate, callback) {
});
}
async function readManifestFile(path) {
const manifestPath = "resources/public/js/manifest.json";
let content = await fs.readFile(manifestPath, { encoding: "utf8" });
return JSON.parse(content);
}
async function readShadowManifest() {
const ts = Date.now();
try {
const manifestPath = "resources/public/js/manifest.json";
let content = await fs.readFile(manifestPath, { encoding: "utf8" });
content = JSON.parse(content);
const content1 = await readManifestFile(
"resources/public/js/manifest.json",
);
const content2 = await readManifestFile(
"resources/public/js/worker/manifest.json",
);
const index = {
ts: ts,
@ -193,10 +202,14 @@ async function readShadowManifest() {
polyfills: "js/polyfills.js?ts=" + ts,
};
for (let item of content) {
for (let item of content1) {
index[item.name] = "js/" + item["output-name"];
}
for (let item of content2) {
index["worker_" + item.name] = "js/worker/" + item["output-name"];
}
return index;
} catch (cause) {
return {
@ -205,7 +218,7 @@ async function readShadowManifest() {
polyfills: "js/polyfills.js?ts=" + ts,
main: "js/main.js?ts=" + ts,
shared: "js/shared.js?ts=" + ts,
worker: "js/worker.js?ts=" + ts,
worker_main: "js/worker/main.js?ts=" + ts,
rasterizer: "js/rasterizer.js?ts=" + ts,
};
}