-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Using globally defined external dependencies with named and default exports #2668
Comments
I'm not going to comment on or investigate plugins written by others. If it's been abandoned then you may not want to use it. Keep in mind that let obj = { default: 'something' }
export default obj and you import it using If you really want to keep importing things using the |
I'm already taking some time to try stuff out and evaluate. In this case it seems that the plugin is at fault, as it doesn't correctly treat default-exports. I'll report back when I have more questions or get stuff working. I actually hoped it would work as Rollups In the meantime another thing: Do you know if star-imports are tree-shakable? |
Usually, yes. Caveats:
If those conditions are met, then esbuild's bundler will automatically convert this: import * as foo from 'foo'
foo.bar() into this during the bundling operation: import { bar } from 'foo'
bar() |
Thanks for the response! We might have some stuff in our codebase, that we can optimize then. |
Closing this issue as this conversation did not receive additional replies. |
Kind of related to #337 - We used Rollup before but I'm currently busy porting everything over to use esbuild.
One thing I struggeled with is the use of external dependencies, that are present on the
window
-object like so:I have prepared my esbuild-config.js to account for the global-externals like so:
Now I need a plugin to tell esbuild to include the variables on
window
in the build. I tried out fal-works/esbuild-plugin-global-externals and a-b-r-o-w-n/esbuild-plugin-globals. The former is more configurable and seems to be better suited for esm-builds which I intend to use like so:The application builds successfully, but now when I try to open one part of the application that relies on the global externals being available, I see this in the browsers console:
When I take a look at it in the debugger, I see that
div
is actually inside ofimport_styled_components2.default.default
. So the plugin didn't resolve thedefault
export correctly. Both of the libraries suffer from this problem; default exports are not usable for me.From my point of view this question would be better handled in a community forum or on the repos of the plugins themselves, but it's been more than a year that they received new commits. An issue that I created there didn't receive any answers.
Can you help me get this to work or point me to a place that's better suited, if this doesn't fit the issues here?
The text was updated successfully, but these errors were encountered: