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

Build-in support to create aliases to import or require modules would be very helpful #2191

Closed
doberkofler opened this issue Apr 19, 2022 · 5 comments

Comments

@doberkofler
Copy link

doberkofler commented Apr 19, 2022

I currently evaluating the migration of a very very lange and complex webpack configuration to esbuild.
I have found some esbuild plugins but was not able to get things working and believe that build-in support for aliases similar to resolve.alias in webpack or paths in TypeScript would be a very helpful addition.

@evanw
Copy link
Owner

evanw commented Apr 19, 2022

Yes, I agree. However, esbuild actually does support paths in tsconfig.json. It's respected in both TypeScript and JavaScript files while bundling.

@doberkofler
Copy link
Author

@evanw Interesting, but I'm not sure I fully understand. I would prefer to just rely use the build-in features but noticed, that esbuild did automatically resolve the TypeScript modules but not the css modules. Is this this the expected behavior or should also the css modules be resolved? Please also note, that I created a separate SR #2192 that specifically focuses on the module resolution when chaining plugins. Thank you for your awesome work.

@doberkofler
Copy link
Author

I also noticed that for example the dataurl loader needed to import image resources does not resolve accordingto the paths in tsconfig.json and does also not observe the alias set in the plugin esbuild-plugin-alias.

@maor-benami77
Copy link

It it supported only when bundling?
What about using esm without bundling?
The paths stay the same

@jsejcksn
Copy link

jsejcksn commented Nov 27, 2022

I just saw this mentioned in the latest release notes.

@evanw How is it different from / advantageous over supporting standard import maps?

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