-
Notifications
You must be signed in to change notification settings - Fork 6
De-duplicate ifTrueBundles and ifFalseBundles arrays when creating conditional manifest #642
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: d624be3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 102 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| '@atlaspack/reporter-conditional-manifest': patch | ||
| '@atlaspack/integration-tests': patch | ||
| '@atlaspack/feature-flags': patch | ||
| '@atlaspack/bundler-default': patch |
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.
@atlaspack/bundler-default and @atlaspack/utils were included by default, is this correct?
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.
Is it because of the change in feature flags? Though I'd expect more packages to be touched by that?
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.
yeah this seems incorrect, the changeset file doesn't list dependents - that's handled in the business logic of the github action
7e5f4bd to
d624be3
Compare
| ifTrueBundles: [ | ||
| ...new Set( | ||
| mapBundles(cond.ifTrueBundles) | ||
| .concat(bundleInfo[key]?.ifTrueBundles ?? []) |
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.
Probably not important right now but might be a factor as the feature scales - but does it make sense to do the sort/set for every bundle, or do it once as a pass at the end?
Maybe even consider something like using two maps like ifTrueBundles: Map<string, Set<string>> = new Map() (and one for false), adding to the sets in this pass, and at the end producing the bundleInfo object and sorting the sets then.
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.
@dddlr might be a good opportunity to improve this code, given you've raised a PR to mitigate in jira - you can take your time on this one
JakeLane
left a comment
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.
looks good! Did you check if the JSRuntime code needs to be updated?
yeah, i updated the conditional bundling example locally to try to reproduce the issue, as well as looking into the not quite sure why though, will have to dig into the implementation (especially the |
Conditional bundling bug fix:
Add de-duplication so that assets don't appear duplicated inside the conditional manifest.
In other words, we want to de-duplicate stuff like this:

Motivation
When
importCondis used twice in the same bundle with the exact same arguments, we will add the conditional bundles toifTrueBundlesandifFalseBundlestwice.For example, imagine we have two files that get bundled into the same asset (let's call it
navigation-stuff.4abe98ff.js) at build-time:index-new.jsandindex-old.jswill get added to theifTrueBundlesandifFalseBundlesarrays fornavigation-stuff.4abe98ff.jstwice, because there are twoimportCondfunction calls that end up in the same bundle.Changes
Add some basic de-duplication in
packages/reporters/conditional-manifest/src/ConditionalManifestReporter.js, which is where we create the conditional manifest.I considered adding this de-duplication into
getConditionalBundleMappingdirectly too, but it seemed superfluous - @JakeLane let me know if you have a different opinion here.Note that this PR will need to be updated once #640 is merged in
Checklist