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

Is it possible to customize the [dir] in entryNames? #3702

Open
ryanto opened this issue Mar 15, 2024 · 0 comments
Open

Is it possible to customize the [dir] in entryNames? #3702

ryanto opened this issue Mar 15, 2024 · 0 comments

Comments

@ryanto
Copy link

ryanto commented Mar 15, 2024

First thank you so much for esbuild. It is an absolute joy to work with!

Issue

I'm running into an issue where I need to bundle some files from a directory in node_modules.

await build({
  entryPoints: [
    './src/**/*.page.js',
    './node_modules/some-module/files/**/*.page.js'
  ], 
  bundle: true,
  entryNames: '[dir]/[name]',
  outbase: "./",
  outdir: './dist',
  platform: 'node',
  format: 'esm',
});

This code works, but the output in ./dist ends up containing a folder called node_modules/, which causes node to think that files under that path are actual node modules. Since that output directory doesn't contain a package.json, node thinks it's a CommonJS module and gets confused to why there's an ESM file in there.

Minimal reproduction

https://github.com/ryanto/esbuild-entrynames-dir

Temp fix I'm using

As a temporary fix, I have dropped [dir] from entryNames so that no folder named node_modules will end up in ./dist. I am using entryNames: [name]-[hash], but I am worried I am going to get a collision due to the large number of files I'm building with similar names. I would love to add [dir] back because it makes debugging and viewing build output easier for me.

It would be great if I could customize the name of the output file to ensure that there's no node_modules name in it's path. I think this might be possibility related to the onEmit plugin API mentioned in #553

Again thank you so much for esbuild!

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

1 participant