The following esbuild CLI command works:
esbuild server/**/* --platform=node --tsconfig=tsconfig.server.json --outdir=dist
But if I create a config file and execute it with node esbuild.js command, it's not working. The error says that it could not resolve server/**/*.
esbuild.js
esbuild.build({
entryPoints: ['server/**/*'],
platform: 'node',
tsconfig: 'tsconfig.server.json',
outdir: 'dist'
}).catch({
process.exit(1);
})
I don't understand why it isn't working like the CLI command does.
Your shell is the thing that expands the server/**/* syntax before the command-line arguments are passed to the esbuild command. Expanding globs is not a feature of esbuild itself. If you need to perform this expansion in JavaScript you'll need to use a library such as https://github.com/isaacs/node-glob#globsyncpattern-options.
esbuild entrypoints does not support glob patterns
example using external tool called tiny-glob from the esbuild issue "entryPoints does not support glob patterns #381" (not mine)
const { build } = require("esbuild");
const glob = require("tiny-glob");
(async () => {
let entryPoints = await glob("./src/*.ts");
await build({
entryPoints,
/* ... */
});
})();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With