Open lgarron opened 2 years ago
I think this is still not possible:
npx esbuild --serve --format=esm --bundle --splitting --servedir=test/root/ test/root/**/*.ts
✘ [ERROR] Must use "outdir" when code splitting is enabled
1 error
npx esbuild --serve --format=esm --bundle --splitting --outdir=dist/dev/test/root --servedir=test/root/ test/root/**/*.ts
✘ [ERROR] Output directory "dist/dev/test/root" must be contained in serve directory "test/root"
1 error
Aha!
This doesn't seem to write out files:
npx esbuild --serve --format=esm --bundle --splitting --outdir=test/root --watch --servedir=test/root/ test/root/**/*.ts
This doesn't seem to write out files:
Unfortunately, this does seem to write files to the source dir:
const esbuildOptions = {
target: "es2020",
logLevel: "info",
minify: !options.dev,
sourcemap: true,
format: "esm",
bundle: true,
splitting: true,
...options.esbuildOptions,
entryPoints: [join(options.entryRoot, "**", "*.ts")],
};
if (options.dev) {
esbuildOptions.outdir = options.entryRoot;
currentBuildContext = await esbuild.context(esbuildOptions);
await Promise.all([
// currentBuildContext.watch(),
currentBuildContext.serve({
servedir: options.entryRoot,
}),
]);
} else {
esbuildOptions.outdir = options.outDir;
await esbuild.build(esbuildOptions);
}
https://github.com/evanw/esbuild/issues/3013 has more info.
For example:
npx esbuild --serve --format=esm --bundle --splitting --servedir=src/ src/**/*.ts
--servedir
needs to be swapped out for building todist
, though, and replaced by manual copying.