You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Treat dynamic imports as chunks, not entry points #2407
As mentioned in #2406 (comment), dynamic imports aren't necessarily entry points from a user perspective.
There are significant code splitting optimizations to be found in removing the facade and chunking constraints of treating dynamic imports as entry points as well.
Feature Proposal
We treat dynamic imports as entry points because that was the easiest way to add them to the chunking colouring algorithm, but it would actually be an improvement to the chunking algorithm if we could work out the common base dependencies of a given dynamic import (the intersection of the static dependency graph of all modules that use this dynamic import) as that would result in fewer chunks and a significant optimization to the algorithm overall.
The other side of this is that dynamic imports also shouldn't need to maintain their facades. We could do this the same way we handle namespaces for other modules, creating the namespace internally as a JS object in the chunk and then exporting that. So this would effectively do (import('x').then(x => ...) -> import('chunk-x').then(x => x.dynamicX).then(x => ...) sort of thing. This would be important to allow chunk grouping with dynamic module chunks, which was one of the reasons we treat them as entry points as well to maintain their facades.
Will see if I can get a PR up along these directions in the next couple of weeks.
Update
Some of this has been implemented via #2575. Nevertheless, two major open points remain:
The colouring algorithm for dynamic imports should skip modules that are already in the same graphs as all importing files. See Refactor chunking algorithm #2575 (comment) for a nice detailed example of what this is about.
Dynamic imports could be handled via either inlining the facade or having an additional namespace on the import that is extracted.
Hey folks. This is a saved-form message, but rest assured we mean every word. The Rollup team is attempting to clean up the Issues backlog in the hopes that the active and still-needed, still-relevant issues bubble up to the surface. With that, we're closing issues that have been open for an eon or two, and have gone stale like pirate hard-tack without activity.
We really appreciate the folks have taken the time to open and comment on this issue. Please don't confuse this closure with us not caring or dismissing your issue, feature request, discussion, or report. The issue will still be here, just in a closed state. If the issue pertains to a bug, please re-test for the bug on the latest version of Rollup and if present, please tag @shellscape and request a re-open, and we'll be happy to oblige.
Activity
lukastaegert commentedon Aug 20, 2018
Sounds awesome, this is something I keep stumbling about as well.
manucorporat commentedon Aug 25, 2018
@lukastaegert @guybedford will this finally rename dynamic import paths so the filename includes the hash?
shellscape commentedon Aug 10, 2019
Hey folks. This is a saved-form message, but rest assured we mean every word. The Rollup team is attempting to clean up the Issues backlog in the hopes that the active and still-needed, still-relevant issues bubble up to the surface. With that, we're closing issues that have been open for an eon or two, and have gone stale like pirate hard-tack without activity.
We really appreciate the folks have taken the time to open and comment on this issue. Please don't confuse this closure with us not caring or dismissing your issue, feature request, discussion, or report. The issue will still be here, just in a closed state. If the issue pertains to a bug, please re-test for the bug on the latest version of Rollup and if present, please tag @shellscape and request a re-open, and we'll be happy to oblige.
lukastaegert commentedon Aug 10, 2019
I think the two open points are still important to be resolved and are referenced quite often.
lukastaegert commentedon Sep 22, 2019
Closed in favour of #3124 and #3125