forked from Codex-/await-remote-run
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.config.mjs
35 lines (31 loc) · 937 Bytes
/
esbuild.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import chalk from "chalk";
import { analyzeMetafile, build } from "esbuild";
(async () => {
try {
const startTime = Date.now();
console.info(
chalk.bold(`🚀 ${chalk.blueBright("await-remote-run")} Build\n`)
);
const result = await build({
entryPoints: ["./src/main.ts"],
outfile: "dist/index.js",
metafile: true,
bundle: true,
platform: "node",
target: ["node16"],
sourcemap: "external",
treeShaking: true,
});
const analysis = await analyzeMetafile(result.metafile);
console.info(`📝 Bundle Analysis:${analysis}`);
console.info(
`${chalk.bold.green("✔ Bundled successfully!")} (${
Date.now() - startTime
}ms)`
);
} catch (error) {
console.error(`🧨 ${chalk.red.bold("Failed:")} ${error.message}`);
console.debug(`📚 ${chalk.blueBright.bold("Stack:")} ${error.stack}`);
process.exit(1);
}
})();