-
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
Migrate ETK to new Sass module system #58725
Conversation
Link to Calypso live: https://calypso.live?image=registry.a8c.com/calypso/app:build-21015 |
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. |
@use '@wordpress/base-styles/mixins'; | ||
@use '@wordpress/base-styles/variables'; |
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.
Why are we importing mixins
and variables
if we're only using breakpoints
in this file?
@@ -1,4 +1,4 @@ | |||
@import '@automattic/onboarding/styles/mixins'; | |||
@use '@automattic/onboarding/styles/mixins' as styles-mixins; |
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.
Why was this renamed to styles-mixins
? I think it's to avoid naming conflicts but there are no other imports in the file 🤔
@import '@automattic/onboarding/styles/variables'; | ||
@import '@automattic/onboarding/styles/mixins'; | ||
@use '@wordpress/base-styles/mixins'; | ||
@use '@wordpress/base-styles/variables' as variables3; |
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.
What's the rationale between renaming styles/mixins
to styles-mixins
and then, not applying the same logic to base-styles/variables
?
I know it's auto-generated by the tool, but still, that intrigues me 😂
Could we rename those variables to something more explicit? There are usages of variables3
inside the code and I have no idea where they come from.
@use '@wordpress/base-styles/variables'; | ||
@use '@wordpress/base-styles/breakpoints'; | ||
@use '@automattic/typography/styles/fonts'; |
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 we need to import this?
Sorry, I should have marked this as a draft PR! I could have added more context before making it ready for review. But that said, here are some answers: @zaguiini Great points! This PR is entirely auto-generated by the Sass migration tool. Nearly all of the "rename changes" are just preventing conflicting namespaces. For example, the default namespace for Also noting that variables coming from imports now get prefixed with the new name. Here's a fake example (I made up the variable names and packages): // Previous syntax with the old module system
@import '@automattic/foo';
@import '@wordpress/foo';
.bar {
color: $blue; // This variable is defined when I import Automattic's foo.
margin: $spacingSize; // This variable is defined when I import WordPress's foo.
} // NEW syntax after running the automatic migrator tool
@use '@automattic/foo';
@use '@wordpress/foo' as foo2;
// Note that the namespace prefixes are automatically added:
.bar {
color: foo.$blue; // This variable is defined when I import Automattic's foo.
margin: foo2.$spacingSize; // This variable is defined when I import WordPress's foo.
} The other points about importing unused files are probably related to an odd Sass architecture. For example, to utilize That said, there could easily be a couple of imports that are stale from previous rewrites, so I may double check them. Though, since my goal is to migrate the entire Calypso repo to the new system, it'd be nice to avoid a lot of manual tweaks. I think there is a part of the migrator tool which can be used to make the namespaces better, so we can try to use that to avoid the weird namespaces like "variables2" |
This may need to be done in the future, but worth starting from scratch when it's needed. |
Changes proposed in this Pull Request
This is the result of running
npx sass-migrator module --load-path node_modules "apps/editing-toolkit/**/*.scss"
See this post for more info.
NOTE: this is blocked by WordPress/gutenberg#37044 in Gutenberg
Testing instructions