-
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
Mass migration from package-relative imports to wp-calypso-client #44958
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Webpack Runtime (~52 bytes added 📈 [gzipped])
Webpack runtime for loading modules. It is included in the HTML page as an inline script. Is downloaded and parsed every time the app is loaded. App Entrypoints (~28 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~8 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 (~1225 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. |
46f3a30
to
fef0858
Compare
b8a818d
to
bea008f
Compare
I've been doing a few dry-runs to detect potential problems, mainly places where we assume package-relative imports (eg: After a few iterations, I think this is ready to be reviewed. e2e is passing, everything seems to work in calypso.live and doing a diff between old and new bundles I can't see anything obvious missing or extra. This PR is likely going to have conflicts very soon. I'm happy to split it into smaller PRs (by directory maybe?) if you think that will make reviewing it easier. |
I smoke tested a variety of things on the |
@scinos looking at how quickly this got so many conflicts... I think it indeed might be best if we split it into chunks. It would surely add some overhead, but then it wouldn't be so scary for review 😬 |
I'm happy to split this per directory if that helps, it won't be a problem 👍 That being said, I don't think it will help a lot. The risk of this PR is not that I changed something that breaks (I trust eslint can do a string replacement correctly). The risk is that maybe I forgot some place where we assume package-relative imports (for example, somewhere where we look for imports of Personally I think the best way to review this is to build master, build this branch (or run the auto-fix for the rule) and analyze the diff between the generated bundles. |
To get this merged, I'd suggest setting a freeze on the channel ahead of time, waiting a few minutes to make sure everyone is aware, and re-generating the PR based on trunk before merging. Then check everything is working correctly with a smoke-test of the whole application before turning the channel back green. There doesn't seem to be much point in reviewing the PR; the approach seems solid, so it's just a matter of giving it a try 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.
FWIW I did some smoke testing and didn't find any trouble anywhere. Should be good to go, given that it's up to date with the latest master.
55f2f85
to
f162d7e
Compare
Update: I changed this PR to apply the autofix only to files inside In case it helps with the review, we already have many places where we import from |
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 looking good to me at this point.
In case it helps with the review, we already have many places where we import from calypso/
, including the section loader (so it is definitely being used in prod). In other words, this PR is not introducing a new pattern, it is increasing the usage of an existing pattern. I hope that helps reduce the riskiness of this change.
This makes sense. Happy to review subsequent PRs applying the autofix more widely.
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 agree, let's go ahead with this one 🚢
This change is due to the new rule from #44958
* Refactor BillingReceipt functions into smaller components * Add ReceiptView at site-level * Fix siteId PropType for TransactionsHeader * Move billing-history top-level components to own file * Make getReceiptUrlFor a prop on BillingHistoryList * Add getReceiptUrlFor to site-level BillingHistoryList * Add redirect from receipt page for invalid receipt * Rename getEditPaymentMethodUrlFor to getEditOrAddPaymentMethodUrlFor This will make it more explicit what that function does. * Rename editPaymentMethod to getEditPaymentMethodUrlFor This follows the pattern for the other functions in this file. * Add recordGoogleEvent action when printing receipt * Add backHref prop to ReceiptTitle and export it * Add ReceiptTitle to site-level ReceiptView * Add wide layout to ReceiptView * Move useRedirectToHistoryPageOnInvalidTransaction to own file * Fix missing page import * Add redirect from ReceiptView if transaction does not belong to site * Fix relative package imports This change is due to the new rule from #44958
* Refactor BillingReceipt functions into smaller components * Add ReceiptView at site-level * Fix siteId PropType for TransactionsHeader * Move billing-history top-level components to own file * Make getReceiptUrlFor a prop on BillingHistoryList * Add getReceiptUrlFor to site-level BillingHistoryList * Add redirect from receipt page for invalid receipt * Rename getEditPaymentMethodUrlFor to getEditOrAddPaymentMethodUrlFor This will make it more explicit what that function does. * Rename editPaymentMethod to getEditPaymentMethodUrlFor This follows the pattern for the other functions in this file. * Add recordGoogleEvent action when printing receipt * Add backHref prop to ReceiptTitle and export it * Add ReceiptTitle to site-level ReceiptView * Add wide layout to ReceiptView * Move useRedirectToHistoryPageOnInvalidTransaction to own file * Fix missing page import * Add redirect from ReceiptView if transaction does not belong to site * Fix relative package imports This change is due to the new rule from #44958
Background
See #44602
Changes
wpcalypso/no-package-relative-imports
in./eslintrc.js
node_modules
. This is not ideal, but afaik is the only way to tell eslint that importing fromcalypso/...
is fine.wpcalypso/no-package-relative-imports
in./client/me/**/*
After this PR is merged,
wpcalypso/no-package-relative-imports
becomes like any other eslint rule in our repo: there are many files that violate that rule, and as soon as a developer change one of those files, eslint will complain and they will have to migrate it.Meanwhile I'll continue creating PRs with auto-fixer applied in batch to some folders to reduce the violations of this rule.
Testing instructions