-
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
[ETK] Update @wordpress/interface
to the latest published version
#73629
[ETK] Update @wordpress/interface
to the latest published version
#73629
Conversation
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. |
This PR modifies the release build for editing-toolkit To test your changes on WordPress.com, run To deploy your changes after merging, see the documentation: PCYsg-mMA-p2 |
62a74f4
to
9a0a68a
Compare
describe( 'TimeMismatchWarning', () => { | ||
beforeAll( () => { | ||
jest.spyOn( global, 'Date' ).mockImplementation( () => ( { getTimezoneOffset: () => 240 } ) ); | ||
global.Date = MockedDate; |
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.
These tests were failing with:
TypeError: Date.now is not a function
at ../node_modules/requestidlecallback/index.js:57:21
at MutationObserver.onInputorMutation (../node_modules/requestidlecallback/index.js:87:3)
I haven't dug too deep, but looks like this is caused by the requestidlecallback
package, which now uses Date.now
. Before the package updates that are part of this PR, Date.now
was not in any of the code paths for this test (apparently), so something changed after the update.
With the mockedImplementation
approach, it discarded Date
's original implementation to only define the custom getTimezoneOffset
. I've tried to use spyOn
+ mockImplementation
to return a custom class based off Date
but failed - it was much simpler to just override the global variable and re-assign the original object to it in the afterAll
callback.
I wonder why this test triggered a portion of code that uses this package now while it didn't before the update. Maybe that package was already used, and it was recently updated to use Date.now
. Provided tests pass, I think it's okay to consider this relatively safe to ship, but if you have more insights, let me know. Besides, in the case of globals like Date
, I think it's safer to keep the original implementation accessible and mock the functions over it. The previous approach based on mockImplementation
removed all other functions and properties (including the static now
).
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.
No concerns from my side about this change. We've seen similar issues in Gutenberg tests too. It's usually that something tries to access Date
before the jsdom
mock has been setup, or something inadvertently overrides it for the test.
To match the changes introduced by the same package in Gutenberg 15.2.
…ontinue working with React 17
7526f02
to
a9d298c
Compare
Referring to #73078 (comment), the FYI @Automattic/team-calypso-frameworks is working on Try: Upgrade @wordpress packages to pre-React 18 |
@arthur791004 the big difference between this PR and #73078 is that this is updating the I've taken a look around the |
Got it! Looks like I misunderstood some changes in |
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've taken a more extensive look over the yarn.lock
updates and have some concerns - we this package upgrade, and specifically the deduplication might have unexpected effects on the rest of Calypso. I'm not sure we intended to upgrade all those @wordpress
packages for the test of the monorepo.
package.json
Outdated
@@ -300,7 +300,9 @@ | |||
"newspack-components/@wordpress/element": "4.7.0", | |||
"newspack-components/@wordpress/i18n": "4.9.0", | |||
"keytar@npm:7.7.0/node-addon-api": "3.1.0", | |||
"lzma-native": "^8.0.5" | |||
"lzma-native": "^8.0.5", | |||
"@wordpress/primitives/@wordpress/element": "4.20.0", |
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.
Should we pin this to a particular version of @wordpress/primitives
to avoid this propagating to another version of @wordpress/primitives
and accidentally into the rest of the monorepo?
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.
Good point 👍🏻
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.
Hmm, after resetting the yarn.lock
to the trunk
version and re-installing the new version of @wordpress/interface
in ETK without deduping, these resolution overrides don't seem to be needed anymore, the storybook task is working fine.
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 removed those entries.
describe( 'TimeMismatchWarning', () => { | ||
beforeAll( () => { | ||
jest.spyOn( global, 'Date' ).mockImplementation( () => ( { getTimezoneOffset: () => 240 } ) ); | ||
global.Date = MockedDate; |
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.
No concerns from my side about this change. We've seen similar issues in Gutenberg tests too. It's usually that something tries to access Date
before the jsdom
mock has been setup, or something inadvertently overrides it for the test.
yarn.lock
Outdated
"@types/react-dom@npm:*, @types/react-dom@npm:>=16.9.0, @types/react-dom@npm:^18.0.6": | ||
version: 18.0.11 | ||
resolution: "@types/react-dom@npm:18.0.11" |
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.
This is where things could eventually get thorny, but if there are no TS errors introduced, we're likely fine for now. We should keep an eye on this. Ideally, we should upgrade to the newest @wordpress
packages and upgrade the repo to use React 18 as soon as possible.
yarn.lock
Outdated
"@wordpress/a11y@npm:^3.10.0, @wordpress/a11y@npm:^3.13.0, @wordpress/a11y@npm:^3.27.0, @wordpress/a11y@npm:^3.9.0": | ||
version: 3.27.0 | ||
resolution: "@wordpress/a11y@npm:3.27.0" |
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.
Seems like this is forcing the rest of Calypso to use @wordpress/a11y@3.27.0
- is it intentional? I think we should refrain from affecting the rest of the monorepo.
languageName: node | ||
linkType: hard | ||
|
||
"@wordpress/date@npm:^4.13.0, @wordpress/date@npm:^4.27.0, @wordpress/date@npm:^4.9.0": |
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.
Same as for other @wordpress/a11y
above.
"@wordpress/icons@npm:^9.0.0, @wordpress/icons@npm:^9.11.0, @wordpress/icons@npm:^9.4.0, @wordpress/icons@npm:^9.5.0": | ||
version: 9.11.0 | ||
resolution: "@wordpress/icons@npm:9.11.0" | ||
"@wordpress/icons@npm:^9.0.0, @wordpress/icons@npm:^9.11.0, @wordpress/icons@npm:^9.18.0, @wordpress/icons@npm:^9.4.0, @wordpress/icons@npm:^9.5.0": |
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.
Same as for other @wordpress/a11y
above.
"@wordpress/keycodes@npm:^3.10.0, @wordpress/keycodes@npm:^3.13.0, @wordpress/keycodes@npm:^3.9.0": | ||
version: 3.13.0 | ||
resolution: "@wordpress/keycodes@npm:3.13.0" | ||
"@wordpress/keycodes@npm:^3.10.0, @wordpress/keycodes@npm:^3.13.0, @wordpress/keycodes@npm:^3.27.0, @wordpress/keycodes@npm:^3.9.0": |
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.
Same as for other @wordpress/a11y
above.
yarn.lock
Outdated
"@wordpress/primitives@npm:^3.1.1, @wordpress/primitives@npm:^3.11.0, @wordpress/primitives@npm:^3.18.0, @wordpress/primitives@npm:^3.5.0, @wordpress/primitives@npm:^3.7.0, @wordpress/primitives@npm:^3.8.0": | ||
version: 3.18.0 | ||
resolution: "@wordpress/primitives@npm:3.18.0" | ||
"@wordpress/primitives@npm:^3.1.1, @wordpress/primitives@npm:^3.11.0, @wordpress/primitives@npm:^3.25.0, @wordpress/primitives@npm:^3.5.0, @wordpress/primitives@npm:^3.7.0, @wordpress/primitives@npm:^3.8.0": |
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.
Same as for other @wordpress/a11y
above.
"@wordpress/redux-routine@npm:^4.13.0": | ||
version: 4.13.0 | ||
resolution: "@wordpress/redux-routine@npm:4.13.0" | ||
"@wordpress/redux-routine@npm:^4.13.0, @wordpress/redux-routine@npm:^4.27.0": |
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.
Same as for other @wordpress/a11y
above.
version: 2.27.0 | ||
resolution: "moment@npm:2.27.0" | ||
checksum: ea5b2fd73c8ad9070fc82c21ccb6226f7556c27a6a305e64371a3d1223729e9f9e75da59c3114160f21f9181e74f6d245534093179825eb20bf0f40ec7495d92 | ||
"moment@npm:>= 2.9.0, moment@npm:>=1.6.0, moment@npm:^2.19.3, moment@npm:^2.22.1, moment@npm:^2.26.0, moment@npm:^2.29.4": |
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.
Are we sure this doesn't break something? Moment is quite broadly used throughout Calypso.
I've taken a more thorough look and I think I understand your concerns. Left some comments above to raise those concerns as well. |
@fullofcaffeine I wonder if it's worth investing some time in finishing #73155 that upgrades all packages together to the pre-React 18 versions instead. |
I've closed #73155 since it went far from what it should have been. I think we should proceed with upgrading to newer versions of the packages, but not with such a giant leap forward - rather in smaller chunks. |
Hmm, not intentional, no; that was the (indirect?) result of either upgrading |
@tyxla Would you suggest reinstalling and not deduping? The problem is that the build might fail to ask us to dedupe. To make sure we're on the same page: when you say "pin", I assume you mean explicitly defining the version of these packages in the root |
That's true. The title for this PR might seem a bit misleading, but I wanted to point out that this was about this specific package, that originally caused the issue (and needed to be updated to match the version in Gutenberg). The alternative would be to explore extracting it using the Dependency Extraction plugin, but not sure if it'd have side effects in Gutenberg/WP (cc @gziolo) |
Yes and yes - I think that would be the only way to ensure that we don't affect the rest of Calypso inadvertently. The downside is that we might and will end up shipping multiple versions of the same package, which is why |
Yeah, that's a very good point about not deduping, my bad. Deduping will tend to re-organize/DRY packages and that probably means moving them down the monorepo tree. |
I remember one of the test builds failed once and asked me to dedupe, though, but I guess we can just skip that specific check. |
One thing that worries me is that if someone else runs |
19e8c0b
to
b090bcf
Compare
The problem with the current state of the dependencies is that there are multiple dependencies that satisfy a set of requirements. In that case, I've tried with a bit more strict dependencies in order to both satisfy the previous requirements and satisfy yarn to not think that deduplication is possible. I've reverted those changes (left them in place if you'd like to take a look) because there were still unnecessary updates to other packages. My conclusion from working on this PR and other It seems like we're blocked by this problem. So, what would I recommend? Exploring making the dependencies more strict in a separate PR, either by using The downside of that strict dependency approach would be that upgrades of Let me know what you think. |
Yes, it's excluded from the mechanics on purpose in the Gutenberg project and WordPress core to avoid creating an entry point and exposing it under |
Closed in favor of #73856. |
Update it to match the changes introduced by the same package in Gutenberg 15.2.
IMPORTANT: This PR should be merged before releasing Gutenberg 15.2 to WPCOM.
The mismatch between versions is causing a WSOD in simple sites (and probably in AT, too). Gutenberg 15.2 introduced some changes in this package (WordPress/gutenberg#47498), but ETK ends up loading an older version without these changes. The ETK version is probably loaded (enqueued) after the GB version and then replaces most of it*, while the GB version still tries to import from the replaced module
selectors.js
and fails, since it contains the old code.*only some parts, probably because the package is code-split and ETK only loads some modules (like selectors.js)? I haven't looked deeply, this is just an assumption.
Related to WordPress/gutenberg#47498.
Slack discussion: p1677020860615489-slack-CBTN58FTJ (also a good primer on why the
.yarmlrc.yml
changes were needed)Sum up on Slack: p1677778450155879/1677777680.547219-slack-CBTN58FTJ
Proposed Changes
Update the version of
@wordpress/interface
in ETK to match the one in Gutenberg 15.2.Testing Instructions
to your sandbox, make sure your test sandboxed site has the
gutenberg-edge
sticker applied;yarn && yarn dev --sync
)