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

Fix multiple entries pointing to wrong bundle in dist #8991

Merged
merged 8 commits into from
May 22, 2023
Merged

Conversation

AGawrys
Copy link
Contributor

@AGawrys AGawrys commented May 6, 2023

↪️ Pull Request

This aims to fix issue #8864 , Where specifying two dists, with an external shared bundle caused the wrong relative path to be placed in the loader code. I don't think this is an issue with the bundler algorithm though, since it still created separate shared bundles for each dist and the edges were fine. (see graph below)

Anyway, so it looks like the wrong path occurs when getting externalBundles in the runtime code. It grabs both shared bundles (for each target) and then picked the first match by asset, which didn't take into account targets. Not sure if this fix is best, so do let me know.

Update: I've added the target name when keying for bundlegroups, which actually addresses the problem of having two identical bundles (same entry asset) under the same bundlegroup.

💻 Examples

BEFORE:
parcel-after_bundle
AFTER:
parcel-after_fix

🚨 Test instructions

Test case and @joeyslater 's reproduction

✔️ PR Todo

  • Added/updated unit tests for this change
  • Filled out test instructions (In case there aren't any unit tests)
  • Included links to related issues/PRs

@AGawrys AGawrys requested a review from mattcompiles May 8, 2023 16:38
@@ -347,6 +347,10 @@ function getLoaderRuntime({
}

let externalBundles = bundleGraph.getBundlesInBundleGroup(bundleGroup);
externalBundles = externalBundles.filter(
externalBundle => externalBundle.target == bundle.target,
);
Copy link
Member

Choose a reason for hiding this comment

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

One question is how bundles from multiple different targets are getting into the same bundle groups in the first place?

Copy link
Contributor Author

@AGawrys AGawrys May 17, 2023

Choose a reason for hiding this comment

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

I believe I fixed it properly now 😅 @devongovett , added an updated graph pic as well where theres two separate bundlegroups for each target :)
Only issue here could be if targets don't have a name but I thought they would always have one? Is that true?

Copy link
Contributor

@mattcompiles mattcompiles left a comment

Choose a reason for hiding this comment

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

Nice one 🍻 🚀

@AGawrys AGawrys merged commit 6682a59 into v2 May 22, 2023
@AGawrys AGawrys deleted the entries-bug-050423 branch May 22, 2023 19:40
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