-
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
Replace client/languages with packages/languages #46709
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~6896 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~50 bytes added 📈 [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 (~16 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.
I think it'd be better to stick with the current approach and have languages-meta.json
data to be downloaded on each initial build (e.g. in the prepare
script). And to avoid the data being constantly updated with other commits, languages-meta.json
should also be git ignored.
Since the package depends mainly on that data file, from developer experience perspective, it's a good idea to have a data file that it can fallback to when it's unable to reach the download url (e.g. when offline). Here's the Webpack config in the current implementation that's used to replace the path to the JSON file.
f7b7a0c
to
2ccd103
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.
After having a discussion with @lsl, we came to the conclusion that languages data doesn't change that frequently so it's not really needed. Downloading the languages data on each build will save the few extra steps to manually update the data, but it has some other downsides:
- The downloaded data can't be validated properly
- Relies on downloading the file, which could block the builds
- It will require overcomplicated implementation with no real benefit
Having these in mind, we should stick with manual approach so we can have better control over the languages data updates and therefore the suggestion from my previous comment should be ignored.
I've noticed that there are some leftovers related to the old languages module:
bin/download-languages-meta.js
and its related scripts inpackage.json
client/languages/fallback-languages-meta.json
andclient/languages/index.d.ts
- Languages data replacement webpack config https://github.com/Automattic/wp-calypso/blob/2ccd10313b43c8181c0b93b0438643ec0036add0/client/webpack.config.js#L376-L383
Is there any reason to be keeping these?
Also left a few small comments, but other than that, I've tested the package and it LGTM.
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 comments above, but just dropping in to say this lgtm too
2ccd103
to
fa4115e
Compare
@yuliyan / @p-jackson thanks for the feedback/input, I've made a few changes:
|
Sounds good, but I'm not sure if wget has a good cross platform support (e.g. on Windows). |
0725421
to
faf9601
Compare
Felt leaving the old languages file around was a bit untidy so I've updated all the old references to point at the new package and removed it completely. Tested:
Couldn't test
|
This unit test failure is interesting, I wonder if it's something to do with no longer being allowed to implicitly import from the root of calypso repo. Maybe the path to mock just needs updated to |
And I'm not sure, but I think the |
It's enabled for support session, but you can also enable it with URL feature flag
As @p-jackson pointed above, it should be related to the failing unit tests. Let's try updating the mock here to point to the package Also, package's own tests are also failing as they're still using named import here. |
Close, I dropped this module completely now, @yuliyan mentioned the fix needed: updated to @automattic/languages and return a plain array by default. We could also just drop the mock completely but I think either way has a point. |
807d857
to
7184fa3
Compare
rebase + conflict resolution |
7184fa3
to
8b0793e
Compare
8b0793e
to
477829c
Compare
Squashed this - was becoming unruly to rebase against
@yuliyan I think I checked the build-languages script works properly but would appreciate a confirmation / double check |
@lsl tested it and it works fine 🚀 I noticed that |
477829c
to
935e9d3
Compare
One more thing - I checked and it seems like With that being said, I'd suggest removing it from the generated Ref. D52271-code |
- Package tidy up - Remove more of the old languages setup, replace with ts - Always error / exit 1 on failure - This script is no longer run as part of the build. - Add languages as default export - Replace transpile call with tsc directly - Remove old languages dir completely and replace usage - Use same lodash version as calypso - Missed test import after default export change - Test fix - update mock of languages import - Use new package in bin/build-languages.js
4ea1e04
to
12f9912
Compare
Rebased and force pushed |
Language data currently held in client/languages is required outside the calypso scope.
We need this data to enable moving the
localizeUrl
function outside of calypso (I'm looking to move this function into i18n-calypso.)For examples, linking to support documentation in Gutenboarding: #45610/#46670, or linking to the help/contact page in the editing toolkit.
Changes proposed in this Pull Request
client/languages
withpackages/languages
.Testing instructions
Unit tests check basic data is being loaded:
yarn workspace @automattic/languages test
Manually you can: