Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config file couldn't resolve entry point folder with ** glob syntax #976

Closed
vtereshyn opened this issue Mar 15, 2021 · 5 comments
Closed

Comments

@vtereshyn
Copy link

Hey,

I have js config for esbuild which looks like:

const { resolve } = require('path');
const { build } = require('esbuild');

build({
  entryPoints: ['./src/**'],
  minify: true,
  outdir: resolve(process.cwd('dist'))
}).catch(err => {
  process.stderr.write(err.stderr);
  process.exit(1);
});

When I run it I am getting an error:

 > error: Could not resolve "./src/**"

However when I use inline script

"build": "esbuild ./src/** --outdir=dist --sourcemap --sources-content=false --loader:.tsx=tsx --loader:.ts=ts && tsc --emitDeclarationOnly --outDir dist",

everything works as expected and no errors there.

I use React with Typescript.

I don't need bundling or things like that, I only need dist folder with js files.

Thank you in advance

@susiwen8
Copy link
Contributor

You should do this
entryPoints: [path.resolve(__dirname, './src/**')]

@vtereshyn
Copy link
Author

vtereshyn commented Mar 15, 2021

@susiwen8 , I tried to make it this way, but I am getting error with specified path:

 > error: Could not resolve "/Users/../../../../packages/../../src/**"

@evanw
Copy link
Owner

evanw commented Mar 15, 2021

This is a duplicate of #875. The ** syntax is something specific to your shell. It's not something that esbuild interprets. Different shells interpret ** differently so it's not even clear what this syntax means. If you want to use this syntax you can use a library such as https://www.npmjs.com/package/glob.

@zaydek
Copy link

zaydek commented Mar 16, 2021

There are some useful conventions around *, **/*, and */**.{js,jsx}, etc. but they are also just as easily confusing. The other confusing bit is whether * should interpret hidden files or not. We’re probably better off not expecting this from esbuild because the syntax can be too subtle / powerful. That being said, it wouldn’t be hard to use readdir and filter as a one-liner replacement without relying on externals:

const every = fs.readdirSync("src").filter(src => src.endsWith(".js"))
// ...

Or something like that.

@evanw
Copy link
Owner

evanw commented Mar 16, 2021

Closing this because this is out of scope. The next release will mention globs in the error message:

$ ./esbuild './src/**'
 > error: Could not resolve "./src/**" (glob syntax must be expanded first before passing the paths to esbuild)

1 error

@evanw evanw closed this as completed Mar 16, 2021
@evanw evanw changed the title Config file couldn't resolve entry point folder Config file couldn't resolve entry point folder with ** glob syntax Mar 16, 2021
This was referenced Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants