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

Plugin-resolved entrypoints have their names escaped #588

Closed
iamakulov opened this issue Dec 9, 2020 · 1 comment
Closed

Plugin-resolved entrypoints have their names escaped #588

iamakulov opened this issue Dec 9, 2020 · 1 comment

Comments

@iamakulov
Copy link

I’m trying to make ESBuild generate entry points with a custom name (that doesn’t match the name of an entry point file). Until #553 or #518 are implemented, I’m trying to do that with a custom onResolve + onLoad ESBuild plugin.

The problem is that when I’m using the plugin to resolve an entry point, ESBuild escapes the entry point name. As a result, if I have an entry point called my-app.debug.js, and I resolve it to some custom code using a plugin, the generated bundle would be called my_app_debug.js.

This doesn’t happen when the resolution process doesn’t go through a plugin. So if my-app.debug.js actually existed on the file system, and the plugin wasn’t used, the bundle name would still be my-app.debug.js.

Steps to reproduce

  1. Clone https://github.com/iamakulov/esbuild-entrypoint-repro
  2. Run yarn install
  3. Run node esbuild.config.js

Expected result

The build should generate a file called dist/virtual-entrypoint.debug.js. (This is what it would generate if virtual-entrypoint.debug.js was an actual entry point file present somewhere in the file system.)

Actual result

The build generates a file called dist/virtual_entrypoint_debug.js

@iamakulov iamakulov changed the title Plugin-generated entrypoints have escaped names Plugin-resolved entrypoints have their names escaped Dec 9, 2020
@evanw
Copy link
Owner

evanw commented Dec 10, 2020

The naming scheme for virtual modules is somewhat arbitrary because esbuild doesn't assume that a module's path is a file system path if it's not in the file namespace. Technically it's using the auto-generated "human-friendly identifier" for the virtual module which is why it's replacing non-identifier characters with _.

I can definitely derive virtual module paths differently. That shouldn't be too hard to change, and I don't see why not.

@evanw evanw closed this as completed in d81392f Dec 11, 2020
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

2 participants