This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Optimise imports of Product Query variation #10340
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: -804 B (0%) Total Size: 1.36 MB
ℹ️ View Unchanged
|
kmanijak
added
focus: performance
The issue/PR is related to performance.
block-type: product-query
Issues related to/affecting all product-query variations.
type: bug
The issue/PR concerns a confirmed bug.
labels
Jul 25, 2023
7 tasks
woocommercebot
requested review from
a team and
nefeline
and removed request for
a team
July 25, 2023 12:14
nefeline
approved these changes
Jul 26, 2023
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.
🚀
Confirmed that:
- On trunk, the subscription occurs both on
legacy-template.js
andproduct-query.js
- On this branch subscription occurs on
product-query.js
exclusively
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
block-type: product-query
Issues related to/affecting all product-query variations.
focus: performance
The issue/PR is related to performance.
type: bug
The issue/PR concerns a confirmed bug.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When working on #10267 I encountered a problem that Product Query logic was initialized twice in Editor and that included the subscription to the store changes here.
In scope of #10267 I subscribe to the
'core/block-editor'
store changes and it's important to have singleunsubscribe
function returned from it. Unexpectedly the module was loaded twice and importing theunsubscribe
was undeterministic.Product Query is marked with
sideEffect
hence tree shaking is not applied when importingVARIATION_NAME
from Product Query variation file which happened withinclassic-template
. So it actually included the whole module because of thesideEffects
.This PR overcomes the problem by moving the variable to
constants
which can be tree shaken when imported withinclassic-template
andproduct-query
modules.Summarizing this PR, it:
legacy-template
moduleproduct-query
module twice.Part of #9703
Testing
Automated Tests
User Facing Testing
console.log( 'Subscribing' )
before the subscription happens inproduct-query
here. (Adding breakpoint doesn't help here, as it's caught only once. I think it's because of the source maps that resolve to the single file anyway, hence the easiest is to actually useconsole.log
).trunk
WooCommerce Visibility
Performance Impact
It reduces the size of
legacy-template
moduleChangelog