-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Code splitting is more broken with esbuild 0.10.1 #1081
Comments
This comment has been minimized.
This comment has been minimized.
Wait, sorry – this has actually started happening earlier, with 0.10.1. 0.10.0 works correctly. (I reproduced the first issue with 0.10.1. The second one is likely present there as well, but I haven’t had a chance to check yet.) |
I'm guessing this is the removal of the file splitting optimization, which is sort of a fundamental shift to how the bundler works. It's a bummer that I won't have a way to reproduce this. Unfortunately I don't think I'll be able to fix this without one. I've looked over that code a few times now and nothing stands out. And it doesn't seem to be an issue for any of the projects in my test set. I'll keep trying. |
Got it, thank you for checking this on your side! Added this to my to-do list; if all goes as planned, will get back with a repro later this month. |
I'm having the same issue Made a reproducation here: https://github.com/zandaqo/esbuild_chunk |
That's amazing! Thank you so much. I can reproduce it too, so I should be able to fix this. |
No, thank you for the great tool, support, and overall experience here, the least we can do is complain about the inevitable bugs. |
A fully-reduced test case for the repo above is as follows:
When you build this with This bug is caused by |
Can you verify that version 0.11.5 fixes this issue? |
@evanw All good here, 0.11.5 fixes it. |
Likely related to #399.
This is JFYI. I remember that code splitting is not fully supported, but with
0.11.00.10.1, it seems to be even more broken. On the Framer codebase, it generatesa) cyclic dependencies between chunks that lead to
undefined is not a function
errorsExample
If I upgrade to esbuild 0.11.0 and try to run Framer, I’ll get the following error:
The error happens because, in
chunk-PLL4RMKF.js
, Sentry tries to call__extends
fromtslib
, and__extends
is undefined:But why is it undefined? If we search by
__extends
, we’ll find that it’s imported from another chunk calledchunk-EZ2R6UVJ.js
:That chunk exports
__extends
absolutely correctly:but what it also does is it imports a few symbols from the first chunk (
chunk-PLL4RMKF.js
):So, ultimately, the following happens:
chunk-EZ2R6UVJ.js
chunk-PLL4RMKF.js
chunk-PLL4RMKF.js
initializes and tries to call__extends
fromchunk-EZ2R6UVJ.js
chunk-EZ2R6UVJ.js
haven’t initialized yet,__extends
is undefined.Here’s the contents of chunk
chunk-EZ2R6UVJ.js
:Here’s the contents of chunk
chunk-PLL4RMKF.js
:In
chunk-EZ2R6UVJ.js
,src/environment/index.ts
depends on Sentry fromchunk-PLL4RMKF.js
. Inchunk-PLL4RMKF.js
, Sentry depends on tslib fromchunk-EZ2R6UVJ.js
.If
src/environment/index.ts
was bundled separately from other modules inchunk-EZ2R6UVJ.js
, this issue wouldn’t happen.b) dependencies between chunks and other entrypoints
This one feels very incorrect – chunks should never import other entrypoints.
Example
If I work around the following error (by tuning/reshuffling a few imports), I’ll get a different error:
If I set a breakpoint inside that React function, I’ll see that the function is called from
projects.debug.js
:This is super weird.
projects.debug.js
is an entrypoint, and it’s a different entrypoint. This file shouldn’t be loaded on this page at all.Then why is it loaded? This is why:
(
format
is a function fromdate-fns/esm/format/index.js
)This feels very incorrect. Entrypoints include top-level code with concrete side effects. That code should be called only when it’s supposed to be called.
In our case,
projects.debug.js
callsReactDOM.render(..., document.querySelector('#root'))
– and#root
doesn’t exist on the page because it’s not the right page!Sorry for no repro! I’m not working with Framer this week so this is the best I can come up with in a limited time. I’ll be able to invest more time in a proper repro in a couple weeks if it’s needed.
The text was updated successfully, but these errors were encountered: