-
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
Import isn't getting imported with code splitting / chunks enabled #2208
Comments
I don't understand. Can you provide some example code to demonstrate what's wrong and what's your expected behavior? e.g. repl link |
I edited my comment to make it a little clearer what's happening. Also, now the bug has disappeared. I changed something but I don't know what exactly caused it to disappear. However, I've also found a commit where I can reproduce the behavior if you'd like to take a look at this esbuild-bug branch in our project. To test you'll need to clone the project and use that branch, then To enable the hack/fix, in the file import '~/shared/domains/chelonia/chelonia.js' To: import { GIMessage } from '~/shared/domains/chelonia/chelonia.js' And then uncomment lines 26-27: // HACK: work around esbuild code splitting / chunking bug: https://github.com/evanw/esbuild/issues/399
// console.debug('esbuild import hack', GIMessage && '') Then save the file and wait a few seconds, and refresh the page. |
Technically the line |
Although I didn't successfully narrow down your project to a minimal reproduction, it looks really like 399 where common chunks may change their execution order. Your The correct way to solve this problem involves a big refactoring to the bundler to carefully capture side effects in each files and replay them in the correct order. That's exactly what parcel2's hoisting does (at the end of its hoisting doc, although not very obvious, it requires you to config splitting thresholds in package.json and manually add dummy codes to enlarge the file). Evan has thought of it but still lack of time to do this. |
Thanks for looking into this @hyrious! I admit I don't really understand what you're saying, and it's confusing to me why esbuild can't simply build a graph of sorts of the order in which files are included and include them in that order. We definitely need code-splitting because of the size of the project (the site would take too long to load on a slow connection otherwise). But anyway, just wanted to say thanks again for looking into this, hopefully Evan or someone else can figure this out. esbuild is a great project, we're mostly very happy with it, and we're very grateful for the speed improvement it gives. |
We have a rather large project using esbuild 0.14.38 and the esbuild-sass-plugin, and when
splitting
is enabled using the following config, esbuild fails to import files when it should:Specifically, I have a fileB that looks like this:
I have a fileA that looks like this:
When fileA is loaded, fileB is loaded, but inside of it, it thinks that fileC isn't loaded.
The hack we've been forced to use is to import something from that file. In fileB:
Then things work.
I'm not sure if this issue is related to #399 or not.
The text was updated successfully, but these errors were encountered: