Skip to content
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

Do not merge isolated bundles in experimental bundler #8566

Merged
merged 4 commits into from Oct 27, 2022
Merged

Conversation

devongovett
Copy link
Member

@devongovett devongovett commented Oct 22, 2022

This make handling of bundleBehavior more consistent, and fixes bundle merging logic with isolated bundles. In addition, bundles of different contexts should not be merged. This fixes the react spectrum site

@parcel-benchmark
Copy link

parcel-benchmark commented Oct 22, 2022

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 1.43s -18.00ms
Cached 328.00ms -15.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

React HackerNews 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

AtlasKit Editor 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

Three.js ✅

Timings

Description Time Difference
Cold 6.66s +7.00ms
Cached 287.00ms -27.00ms 🚀

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

@@ -670,8 +672,9 @@ function createIdealGraph(
);
if (
bundle !== 'root' &&
bundle.bundleBehavior !== 'inline' &&
!bundle.env.isIsolated()
bundle.bundleBehavior == null &&
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is what caused the test change, where a bundle was previously internalized and now isn't. I think in the general case, however, that isolated bundles should not be reachable.

// Store Type-Change bundles for later since we need to know ALL bundlegroups they are part of to reduce/combine them
typeChangeIds.add(bundleId);
if (parentAsset.type !== childAsset.type) {
typeChangeIds.add(bundleId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Speaking of fixes, I notice in the default bundler we maintain bundleByType, which not only holds bundles created via type change, but also all others (lazy/ parallel etc). It looks like that is how we determine where we can merge a type change bundle.
In experimental, we only attempt to merge type change with type change.... does this mean we're not merging as many bundles as we could in experimental ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not merge parallel/lazy bundles, because the transformer that created those dependencies might not expect it. For example, if you have two <script> tags in an HTML page, those have parallel priority, but merging them would result in both scripts pointing to the same URL and (possibly?) executing twice.

typeChangeIds.add(bundleId);
}
} else {
// Otherwise, merge.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my mistake, but this comment doesn't make sense here anymore since we don't merge until later

@devongovett devongovett merged commit 27bf596 into v2 Oct 27, 2022
@devongovett devongovett deleted the fix-merge branch October 27, 2022 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants