fix: remove effect packages from optimizePackageImports
list
#80761
+0
−20
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.
The feature for
optimizeModuleImports
seems to originate hereThe effect packages were first introduced here.
The original intent seems to have been to optimise performance during development time. But it has questionable side effects outside of this intent.
The way aliases are generated here is problematic for at least two reasons:
a) multiple versions of the same package now have their root entrypoint aliased to the same package without taking proper module resolution into consideration
b) it only targets exact matches on root entrypoints - the module exports of these packages are still resolved with the normal module resolution algorithm
This combination means that we get completely undefined runtime behavior.
This PR removes the
effect
packages from this list to circumvent this problem as a last resort, but I'd suggest to fix this behavior more sustainably instead(!) as it has the potential to generate incredibly difficult to debug runtime behavior that differs between development & production. It makes it easy to ship application versions into production that are broken in ways that are not surfaced during development.The good intention to cirumvent the the module traversal and scanning performance impact in case of barrel file imports during development time is noble but it should not have the unintended side effects with these server path alias rewrites as observed.
NOTE: The negative impact of this behavior goes beyond
effect
and would equally apply to some of the other packages in that list with potentially worse outcomes. Instead of explicitly breaking on load it would cause undefined runtime behavior for most other packages.