-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 across reexports using symbol data by splitting dependencies #8432
Conversation
if ( | ||
node.type === 'dependency' && | ||
node.value.specifier === '@parcel/service-worker' | ||
node.value.specifier === '@parcel/service-worker' && | ||
!bundleGraph.isDependencySkipped(node.value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was needed because there are now two such dependencies, one of the being excluded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good to me. Would like to do some testing on some large apps to make sure we don't break anything.
Benchmark ResultsKitchen Sink ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. React HackerNews 🚨
Timings
Cold BundlesNo bundles found, this is probably a failed build... Cached BundlesNo bundles found, this is probably a failed build... AtlasKit Editor 🚨
Timings
Cold BundlesNo bundles found, this is probably a failed build... Cached BundlesNo bundles found, this is probably a failed build... Three.js ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get this into nightly releases to test.
FYI - I have this change patched in to our very large app for a few days now without build issues, and no runtime issues we're yet aware of (dog-fooding is currently limited for the Parcel builds). It's provided an improvement in runtime performance (hard to quantify as we had a workaround in place rewriting imports with a transform, but it's provided a further 10% improvement over the workaround - I think we're roughly at 30-40% improvement over the baseline we had). |
Closes #7392
Symbol propagation already does the traversals anyway, so now it just always tracks for each symbol in a dependency, what that symbol should resolve to.
So for each used symbol, it now says where that symbol should resolve to. This is not exectly the same as
getSymbolResolution
though, as it stops at non-sideeffect-free assets (whilegetSymbolResolution
does resolve through them).This information is then used in
BundleGraph.fromAssetGraph
to split up dependencies to be per symbol (and point them at the resolved asset according to the previous analysis). The old dependency is kept in case some transformer used its placeholder. This changes the execution order because the old dependency is replaced withdep.usedSymbolsUp.map(... => new Dependency(...))
so the arbitrary (sorted alphabetically) order of the symbols is used for this.Since it's possible to rename symbols via reexports, I've had to add an additional map to the dependency node, e.g. a dependency to a side-effect-free asset that doesexport {foo as bar} from "y";
would then be rewritten to point directly toy
instead, and thesymbolTarget
map then hasfoo -> bar
which is applied transparently inbundleGraph.getUsedSymbols
andbundleGraph.getSymbols
(which I think is a better solution compared to mutating the actual DependencyValue symbols entry).dependency.symbolTarget