Skip to content

Commit f14de1d

Browse files
feat(Output): Add ESBuild configuration for Output component
Add Source/ESBuild/Output.js with comprehensive ESBuild build configuration: - Environment-driven settings via Clean, Meta, On flags - ESM format output targeting Node platform - Conditional logging, minification, source maps based on environment - Custom Target plugin for recursive directory cleaning - Optional Rest plugin integration via createRestPluginIfEnabled() - File loaders for .json and .sh assets - Output to Configuration directory This configuration enables the Output component to leverage ESBuild as part of the dual-compiler build system alongside Rest (OXC-based bundler), supporting the Cocoon extension host runtime.
1 parent 106d10c commit f14de1d

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

Source/ESBuild/Output.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { createRestPluginIfEnabled } from "./RestPlugin.js";
2+
export const Clean = process.env["Clean"] === "true";
3+
export const Meta = process.env["Meta"] === "true";
4+
export const On = process.env["NODE_ENV"] === "development" ||
5+
process.env["TAURI_ENV_DEBUG"] === "true";
6+
/**
7+
* @module ESBuild
8+
*
9+
*/
10+
export default {
11+
color: true,
12+
format: "esm",
13+
logLevel: On ? "debug" : "silent",
14+
metafile: Meta,
15+
minify: !On,
16+
outdir: "Configuration",
17+
platform: "node",
18+
target: "esnext",
19+
tsconfig: "tsconfig.json",
20+
write: true,
21+
legalComments: On ? "inline" : "none",
22+
bundle: false,
23+
assetNames: "Asset/[name]-[hash]",
24+
sourcemap: On,
25+
drop: On ? [] : ["debugger"],
26+
ignoreAnnotations: !On,
27+
keepNames: On,
28+
plugins: [
29+
{
30+
name: "Target",
31+
// @ts-ignore
32+
setup({ onStart, initialOptions: { outdir } }) {
33+
switch (true) {
34+
case Clean === true:
35+
onStart(async () => {
36+
try {
37+
outdir
38+
? await (await import("node:fs/promises")).rm(outdir, {
39+
recursive: true,
40+
})
41+
: {};
42+
}
43+
catch (_Error) {
44+
console.log(_Error);
45+
}
46+
});
47+
break;
48+
default:
49+
break;
50+
}
51+
},
52+
},
53+
// Conditionally add Rest plugin when Compiler=Rest
54+
...(createRestPluginIfEnabled() ? [createRestPluginIfEnabled()] : []),
55+
].filter((plugin) => plugin !== null),
56+
loader: {
57+
".json": "copy",
58+
".sh": "copy",
59+
},
60+
};
61+
export const { sep, posix } = await import("node:path");

0 commit comments

Comments
 (0)