-
-
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
Attach internalized orphans and consider types in PRL #8453
Conversation
…deleting a bundle for BOTH bundleGraph and bundleRootGraph
…ate source bundle down, instead ether add bundle or assets to existin type bundle
for (let parentId of parentBundleRootIds) { | ||
if ( | ||
!bundleRootGraph.hasEdge(parentId, childId, 2) || | ||
!bundleRootGraph.hasEdge(parentId, childId, 1) |
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.
hasEdge
doesn't take an array or object of edge types so this is the current work around 😅 I will update this once thats fixed
Benchmark ResultsKitchen Sink ✅
Timings
Cold Bundles
Cached Bundles
React HackerNews ✅
Timings
Cold BundlesNo bundle changes detected. Cached Bundles
AtlasKit Editor ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. Three.js ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. |
…bundler/parcel into agawrys/orphaned-internalize-bug
//Do not orphan any bundles in the bundleGraph.... At this point in time, | ||
//A bundle may have a child of type change, that exists in the bundleGraph | ||
//which must be connected to a referencing or parent bundle, which is found in the bundleROOTgraph | ||
//TODO: Get rid of bundleRootGraph and just had one bigger graph with edgetypes :) |
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 is a TODO for the future since it'd be a larger refactor
…bundler/parcel into agawrys/orphaned-internalize-bug
On the react-spectrum site, I get an error when running with this branch:
|
@@ -1163,7 +1230,14 @@ function createIdealGraph( | |||
dependencyBundleGraph.getNodeIdByContentKey(String(mainNodeId)), | |||
]); | |||
} | |||
|
|||
let mainReachableRoot = reachableRoots.getNodeIdByContentKey( |
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 section fixes the bug in react-spectrum
(missing content key)
When merging type bundles, since I moved the step to later on, we need to patch up the other graphs drawing connections to any children to their new parent
…bundler/parcel into agawrys/orphaned-internalize-bug
Closing unless we need this due to bundle groups deleting. (In the case or merging or deleted async bundles) |
🐰 Pull Request
This PR address experimental bundler issues with CompiledCss extraction enabled.
Problem 1 was that upon internalization of async bundles, we allowed for orphans to be left behind (of type change bundles) and thus were deleted from the graph.
Solution: This PR adds the function
attachOrphans
which makes sure that any children of an async bundle in the bundleGraph (these will only be non async code split point bundles) are then connected to whatever parent the async bundle was internalized into.I've also moved the merge bundles of type change step to be after internalization, so that we don't need to remerge any type change bundles after internalization, which could add a lot of extra work.
Problem 2 arose after Issue 1 was fixed. We had been processing type change bundles within the parallel request limit code. This would've been okay, since we only merge back / alter bundles with source bundles. However, when a reused bundle (an async bundle with source bundles) gets merged back, we know it may have children, so we propagate the reused bundle's source bundles to its children and attach it to the new parent. This is because we assumed the children of an async bundle at that point would only be shared bundles.
But that is not the case.
Solution: Instead, upon merging back a reused bundle, its child of a different type must be either connected to the new parent OR its assets merged into the new parent's already existing bundle of that type.
💻 Examples
The Grey Graphs below are the "bare bones" bundleGraph we use in the experimental bundler, which display only bundles loaded in parallel and their children. So all async bundles are all on the same "level" (i.e. connected to root) and their children are parallel or type change bundles, which are connected to what pulls them in.
We maintain sync relationships and async referencing relationships in supplementary graphs which are not shown but the drawings display these relationships.
INTERNALIZATION ORPHAN BUG
First, here is a visual representation of the dependencies each file has.
So, given that setup, we know
foo.js
should be internalized intoindex.js
. Butfoo.js
has two "children". One is displayed in the graph below as it is a type change and the other isbazz.js
which is an async bundle but is referenced by or "pulled in" by foo.We need to make sure we patch up these would-be orphans. So, connect them to the parent. In the
bazz.js
case we change around our supplementary graphs instead (i.e. removefoo
async connections and patch them up)Type bundles must be merged per bundleGroups so this is why I moved STEP MERGE BUNDLES to occur later, so that we don't need to re-merge.

Finally, assets are placed into bundles.

PARALLEL LIMIT TYPE CHANGE BUG
First, heres a representation of the dependencies each asset has on others
So, given that setup, we see that
bar.js
andfoo.js
become their own bundles as they're code split points. (Async relationship). Notice in the graph above, that they share some assets synchronously. Normally, we can create a shared bundle here, which will be a child to both and have a propertysourcebundles
to reference them. However, in the experimentalbundler, if a bundle requires the total sum of a bundle including it's main Asset Entry (which isfoo.js
in this case) we simply "reuse" the existing bundle. This creates a hybrid bundle that has a mainEntryAsset, and sourceBundles.The Graph below shows
foo.js
as a reused bundle. It has a source bundle,bar.js
but also remember it is originally referenced byindexcss.js
by async relationship.Now, that graph above would be fine, since even though you see two bundles of type
css
, they're in different bundleGroups. But we have to uphold parallel request limits which has special rules for reused bundles. The current rules are:indexcss.js
)a.js
,b.js
, andfoo.js
are placed intobar.js
)styles.css
)styles.css
asset is duplicated and placed intoc.css
bundle)✔️ PR Todo
hasEdge
with @mattcompiles changes