Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not resolve esbuild entry points

Tags:

esbuild

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.

like image 866
jstarnate Avatar asked Oct 23 '25 04:10

jstarnate


2 Answers

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.

like image 165
constexpr Avatar answered Oct 27 '25 06:10

constexpr


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,
    /* ... */
  });
})();
like image 37
chrisweb Avatar answered Oct 27 '25 05:10

chrisweb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!