Files
penpot/frontend/scripts/build-libs.js
Eva Marco e705b6e12c 🎉 Add components library (#10675)
* 🎉 Install react-aria-components

* 🎉 Create modal component in TS using react-aria-component

* 🎉 Create modal ds component

* 🎉 Separate header content and footer components

* 🐛 Remove mf/html macros when not needed

* 🎉 Solve little problems

* ♻️ Format files

* ♻️ Remove ModalCloseBtn

* 🐛 Fix CI

* ♻️ Remove unused files

* 🎉 Make close button not dependant on the modal header

* 🎉 Add footer with two slots

* 🎉 Improvements on modal

* 🐛 Fix package imports and remove login example code

---------

Co-authored-by: Andrey Antukh <niwi@niwi.nz>
2026-07-30 13:05:28 +02:00

73 lines
1.8 KiB
JavaScript

import * as esbuild from "esbuild";
import { readFile } from "node:fs/promises";
import { execSync } from "node:child_process";
execSync("pnpm run build", { cwd: "packages/ui", stdio: "inherit" });
/**
* esbuild plugin to watch a directory recursively
*/
const watchExtraDirPlugin = {
name: "watch-extra-dir",
setup(build) {
build.onLoad(
{ filter: /target\/index.js/, namespace: "file" },
async (args) => {
return {
watchDirs: ["packages/ui/dist"],
};
},
);
},
};
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: "esm",
banner: {
js: '"use strict";\nvar global = globalThis;',
},
outfile: "resources/public/js/libs.js",
plugins: [fixReactVirtualized, rebuildNotify, watchExtraDirPlugin],
};
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);
}