-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Assets: Fix the order of the chunk files #95748
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
client/server/middleware/assets.js
Outdated
const allTheFiles = chunk.files.concat( | ||
flatten( chunk.siblings.map( ( sibling ) => getChunkById( assets, sibling ).files ) ) | ||
); | ||
const allTheFiles = chunk.chunks |
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.
I assume the named chunks always have the chunks
property derived from the stats.namedChunkGroups
above. But it seems to be safer to keep the old implementation.
@Automattic/team-calypso Does this change make sense? It would be helpful to get your review 🙂 |
I don't think this is going to work. You change the order of the CSS modules to fix the domain button, but what if this reorder breaks another CSS which used to be in a "correct" order and now it is not? The right solution is to change the CSS specificity so that it doesn't depend on the stylesheet order. The By the way, is the order of these two classes really breaking something? One of the classes defines only the |
I second what @jsnajdr explained. The load order depends on the load order of the corresponding stylesheets, so it can vary based on the user's current session. To not have to rely on the load order, proper specificity should be used. That's one of the downsides of the current CSS system. Unfortunately, it hasn't improved over the last years, and we've had similar issues before (see p4TIVU-9vD-p2 as one example). |
@jsnajdr Thanks for the review! I replied pbxlJb-6v0-p2#comment-3995
This one is just an example 😅 And I guess there are still lots of places that have the same issue but I didn't remember suddenly. For example, I remembered there are the same issue on the reader page and I changed the CSS specificity and rewrite the conflicts into a single file to resolve the issue. |
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.
Do you think it's good to move this forward?
Yes, this should definitely get merged. I'm just proposing to simplify the code a bit, removing the bits that are no longer used.
client/server/middleware/assets.js
Outdated
? flatten( chunk.chunks.map( ( chunkId ) => getChunkById( assets, chunkId ).files ) ) | ||
: chunk.files.concat( | ||
flatten( chunk.siblings.map( ( sibling ) => getChunkById( assets, sibling ).files ) ) | ||
); |
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.
The new code is good, but to keep the code readable we should remove the old code. The assets writer plugin doesn't need to output siblings
any more, they are not used. And getFilesForChunk
should work only with chunk.chunks
. getFilesForChunk
is called only for chunks that are the main chunks of a chunk group, and the chunk.chunks
should always be there. If it's not, it's a reason to warn about an unknown chunk group and return empty assets.
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 bin/loader-stats.js still in use?
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.
I think you can safely delete it, it was relevant many years ago. Its job is now done by the iscalypsofastyet.com server and the GitHub comments that bot is posting.
But even if you wanted to keep it should be easy to update it to use chunk.chunks
instead of chunk.siblings
. The getChunkAndSiblings
just gets the list of chunks in a chunk group, a task we are already familiar with.
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
4ceba4d
to
1586a8a
Compare
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, thanks for figuring out this subtle fix
client/server/middleware/assets.js
Outdated
flatten( chunk.siblings.map( ( sibling ) => getChunkById( assets, sibling ).files ) ) | ||
); | ||
if ( ! chunk.chunks ) { | ||
console.warn( 'cannot find the chunks of the chunk ' + chunkName ); |
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.
Better wording:
cannot find the chunks of the chunk group xxx
In the Calypso codebase we often don't correctly distinguish between a "chunk" and a "chunk group". For historical reasons, because we've been using webpack for a long time and "chunk groups" were added only in version 4 I think.
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.
Ok! Updated, thank you!
cfa8bc7
to
05fe9bb
Compare
This reverts commit 0c5b372.
Related to pbxlJb-6v0-p2
Proposed Changes
Here is the example of the “Add new domain” button
Why are these changes being made?
Testing Instructions
Here is an example of the “Add new domain” button on the domains page
Pre-merge Checklist