-
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
ExPlat: Loosen requirements on dependencies #62979
Conversation
@@ -26,8 +26,8 @@ | |||
}, | |||
"dependencies": { | |||
"@automattic/explat-client": "workspace:^", | |||
"react": "^17.0.2", | |||
"tslib": "^2.3.0" | |||
"react": ">=16.8", |
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, tests are failing, seems like this isn't working like I thought...
Thanks! I'm not sure how to test the package with WCCOM's version, but I'm confident this will do the trick! |
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~95 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~20 bytes removed 📉 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~96 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
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 yarn.lock
file introduces some unwanted duplications that can be easily resolved by merging them into existing resolution. I pointed out a few examples, there are a few more.
@@ -26,15 +26,14 @@ | |||
}, | |||
"dependencies": { | |||
"@automattic/explat-client": "workspace:^", | |||
"react": "^17.0.2", | |||
"tslib": "^2.3.0" | |||
"react": ">=16.8 <18", |
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.
@testing-library/react-hooks doesn't yet support React 18:
testing-library/react-hooks-testing-library#654
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.
WCCom seems to use 16.14 so we should be good here.
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.
Also, is there a reason why React 18 should be excluded? The Explat bindings should work with v18 equally well as with an earlier v16 or v17, shouldn't they?
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.
Unfortunately @testing-library/react-hooks doesn't yet support React 18:
testing-library/react-hooks-testing-library#654
My unit tests are getting errors where I try to use it because the testing-library is incompatible with React 18.
548d724
to
ab3738f
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.
Nice... thanks!
I'm not sure how to tell what React version WCCOM is running – we're currently on WordPress 5.9.3, which seems to use React 17.0.1.
I assume this change will eventually make its way into https://www.npmjs.com/package/@automattic/explat-client-react-helpers, from where I can try it in WCCOM.
I've now published this to NPM so you can try it out :) |
Thanks @jessie-ross, I'm getting a rather baffling error from the package. When I add
to our dependencies and install, then import import createExPlatClientReactHelpers from '@automattic/explat-client-react-helpers'; and create the helpers as before, I get this in the browser:
|
@andfinally it looks like it is choking on the optional chaining (character 39), after all the packages have been built and minified by WCCom's build tool. Might be something to do with the targeting of TypeScript compilation in WCCom. Is there anyone experienced with WCCom's JS build setup we could ask? |
This has changed actually: It might be worth a try specifying |
Thanks Jessie! Unfortunately |
This error is thrown by webpack. After a JS/TS source file is processed and transpiled by Babel or the TypeScript compiler (invoked inside a webpack loader), the loader-processed source file goes to webpack that further processes it for bundling. And here webpack parses it with the Acorn parser. Apparently the version of the Acorn parser used by webpack doesn't know the The issue is that the The issue has nothing to do with TypeScript or |
Changes proposed in this Pull Request
See: 12687-gh-Automattic/woocommerce.com#issuecomment-1106673768