fix: chunks are analysed multiple times #2541
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In my special case, I have 1500 entry points which will result in every file being analyzed multiple times by the 'vite:import-analysis' plugin. I am still not 100% convinced, that there is no endless loop but I was not able to find it or reproduce it with a smaller example.
You might ask: Why do you have 1500 entry points? That is, because I need to be able to still reference the source files in run-time, as I work on a platform with multiple plugins, that are only present during run-time. Therefore, we do not know, which files might be used by other plugins and therefore we provide any file as an entry point.
You can find an excerpt of our config below:
We collect all the entry points with our own plugin.
Some interesting side-notes: The problem is, that if (and only if) we set the minify option to either 'esbuild' or 'terser', it seems like the build process gets stuck after the "generateChunks" messages. We had it run for like 15 Minutes and then aborted it. I tried to debug, whether there is some kind of endless loop, but I was not able to find it. If we switch off minification, the build runs just fine. If we add this fix, minification works as well.
I am not sure, whether this fix is applicable, but I would appreciate any help, that points me in the right direction.