2024-05-14 09:00:05 +02:00
|
|
|
import dts from "bun-plugin-dts";
|
|
|
|
|
import ora from "ora";
|
|
|
|
|
|
2024-07-22 23:10:12 +02:00
|
|
|
const entrypoints = {
|
2024-09-22 17:15:19 +02:00
|
|
|
federation: ["index.ts", "validators.ts", "types.ts"],
|
2024-07-22 23:10:12 +02:00
|
|
|
client: ["index.ts", "types.ts"],
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-07 09:31:49 +02:00
|
|
|
for (const pkg of ["federation", "client"]) {
|
|
|
|
|
const subSpinner = ora(`Building ${pkg} module`).start();
|
2024-05-14 09:00:05 +02:00
|
|
|
|
2024-06-07 09:31:49 +02:00
|
|
|
await Bun.build({
|
2024-07-22 23:10:12 +02:00
|
|
|
entrypoints: entrypoints[pkg as "federation" | "client"].map(
|
|
|
|
|
(entrypoint) => `${pkg}/${entrypoint}`,
|
|
|
|
|
),
|
2024-06-07 09:31:49 +02:00
|
|
|
outdir: `${pkg}/dist`,
|
|
|
|
|
format: "esm",
|
2024-07-23 00:02:39 +02:00
|
|
|
minify: false,
|
2024-06-07 09:31:49 +02:00
|
|
|
sourcemap: "external",
|
|
|
|
|
splitting: true,
|
|
|
|
|
target: "browser",
|
2024-07-23 00:02:39 +02:00
|
|
|
plugins: [
|
|
|
|
|
dts({
|
|
|
|
|
output: {
|
|
|
|
|
noBanner: true,
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
],
|
2024-06-07 09:31:49 +02:00
|
|
|
}).then((output) => {
|
|
|
|
|
if (!output.success) {
|
|
|
|
|
subSpinner.fail(`Failed to build ${pkg} module`);
|
|
|
|
|
console.error(output.logs);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-05-14 09:00:05 +02:00
|
|
|
|
2024-06-07 09:31:49 +02:00
|
|
|
subSpinner.succeed(`Built ${pkg} module`);
|
|
|
|
|
}
|