esbuild
esbuild copied to clipboard
ESBuild onEnd Callback: `outputFiles` is undefined.
Here is my setup
await esbuild.build({
format: "cjs",
target: "es2019",
sourcemap: false,
bundle: true,
minify: true,
plugins: [react18Plugin()],
entryPoints: await glob("../esbuild-plugin-react18-example/src/**/*.*"),
publicPath: "https://my.domain/static/",
external: ["react", "react-dom"],
outdir: "./dist/default",
metafile: true,
});
// plugin snippet
build.onEnd(result => {
console.log("onEnd -- start", result);
...
}
outputFiles: undefined
outputFiles
gets an array when I pass write: false
in options. However, there is no output in that case.
outputFiles
gets an array when I passwrite: false
in options. However, there is no output in that case.
Yes, you have 2 choices:
-
Set
write: false
, then write them out by yourself.I did that before: https://github.com/hyrious/esbuild-repl/blob/f6a2783c9d0108a3b1596408634718bf89feaffc/scripts/plugins/emits.ts#L67-L71
-
Let esbuild writes them out, and you can analyze the output directory and the metafile.
Add this in the beginning of setup function.
const write = build.initialOptions.write;
build.initialOptions.write = false;
You need to manually write to the files in onEnd
if write was true initially.