mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 02:16:38 +02:00
🐛 Fix some issues with vendored libraries and build process
related to how package.json is defined and how modules are exported
This commit is contained in:
parent
6014612046
commit
0cd446421d
9 changed files with 1002 additions and 3066 deletions
49
frontend/scripts/build-libs.js
Normal file
49
frontend/scripts/build-libs.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
import * as esbuild from "esbuild";
|
||||
import { readFile } from "node:fs/promises";
|
||||
|
||||
const filter =
|
||||
/react-virtualized[/\\]dist[/\\]es[/\\]WindowScroller[/\\]utils[/\\]onScroll\.js$/;
|
||||
|
||||
const fixReactVirtualized = {
|
||||
name: "esbuild-plugin-react-virtualized",
|
||||
setup({ onLoad }) {
|
||||
onLoad({ filter }, async ({ path }) => {
|
||||
const code = await readFile(path, "utf8");
|
||||
const broken = `import { bpfrpt_proptype_WindowScroller } from "../WindowScroller.js";`;
|
||||
return { contents: code.replace(broken, "") };
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const rebuildNotify = {
|
||||
name: "rebuild-notify",
|
||||
setup(build) {
|
||||
build.onEnd((result) => {
|
||||
// console.log(result);
|
||||
// [:main] Build completed. (1003 files, 1 compiled, 0 warnings, 9.06s)
|
||||
console.log(
|
||||
`[:libs] Build completed. (${result.errors.length} warnings, ${result.errors.length} errors)`,
|
||||
);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const config = {
|
||||
entryPoints: ["target/index.js"],
|
||||
bundle: true,
|
||||
format: "iife",
|
||||
outfile: "resources/public/js/libs.js",
|
||||
plugins: [fixReactVirtualized, rebuildNotify],
|
||||
};
|
||||
|
||||
async function watch() {
|
||||
let ctx = await esbuild.context(config);
|
||||
return ctx.watch();
|
||||
}
|
||||
|
||||
if (process.argv.includes("--watch")) {
|
||||
await watch();
|
||||
} else {
|
||||
const localConfig = { ...config, minify: true };
|
||||
await esbuild.build(localConfig);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue