-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Migrate to use the Sass module system #5220
Comments
Thanks @jathak for the update!
Here is what I'm thinking: Option 1// rtl/_base.scss (Sass module)
@mixin rtl() {...}
// rtl/_mixins.scss (Sass module)
@mixin reflexive-box() {...}
@forward "base"
// rtl/_mixins.import.scss (Import path)
@forward "mixins" as mdc-rtl-*
@forward "base" as mdc-* The first forward above might include mdc-rtl-rtl() mixin, but I think it should be fine. WDYT? Option 2Rename those mixins, but this requires changing all the places where these mixins were used. Not preferable. |
For option 1, we wouldn't actually have to split it into a separate file, we could just do:
That should have the same effect as Option 1, but without requiring any new files. Would that work for you? |
I think that looks even better. Thanks! :) |
One other non-standard namespace I found: for |
Can we do the same as above? |
I think the three options here are:
All three are possible, but it looks like there's also an |
Thanks for providing these options! I prefer an option which is backward compatible. I'm also open to renaming any of these mixins if you think the migration is getting super complicated, but I prefer it as last resort. Here is what I'm proposing -
This makes the import path fully backward compatible. Please let me know your thoughts. |
Yeah, that should work (it's mostly my option 2). I don't think there's any member named exactly |
An update on this: we realized that the module system as-is did not allow variables behind a Another thing I realized is running the migrator in its current state on material-components-web could break downstream users that implicitly depended on files they didn't directly import (e.g. depending on a variable from |
Add missing dependencies to three files that previously didn't depend on all the stylesheets they reference (even indirectly). This caused issues with the module system migrator (material-components#5220), so this fix is necessary for that.
Update: I now have a shell script that automatically migrates most components (still working on This script works using a combination of Sass migrator (currently on a branch, but will be released once sass/migrator#131 is merged) and some |
Add missing dependencies to five files that previously didn't depend on all the stylesheets they reference (even indirectly). This caused issues with the module system migrator (material-components#5220), so this fix is necessary for that.
Updated the script with migrations for Now all that's missing is |
Thanks for the updates @jathak!
|
Add missing dependencies to five files that previously didn't depend on all the stylesheets they reference (even indirectly). This caused issues with the module system migrator (material-components#5220), so this fix is necessary for that.
Add missing dependencies to five files that previously didn't depend on all the stylesheets they reference (even indirectly). This caused issues with the module system migrator (#5220), so this fix is necessary for that.
Add missing dependencies to five files that previously didn't depend on all the stylesheets they reference (even indirectly). This caused issues with the module system migrator (#5220), so this fix is necessary for that.
I now have the migrated code properly compiling when run directly through Dart Sass, but Webpack doesn't currently support import-only files, so migrating externally is blocked on webpack-contrib/sass-loader#788. |
Dart Sass 1.24.2 fixes that issue. The big remaining issue on the GitHub side is how to handle lints. The following are what's failing now:
|
We would like to remove some of the custom lint rules from GitHub to keep it in sync with internal Sass lint rules. I wouldn't mind removing above lints if these lints are not applicable internally. Let me know if you need any help removing above lint rules or would want me to remove these lints. Thanks! |
One more thing that came up when testing internally: All of these mixins are already indicated as private with a trailing underscore, but there are some Google-internal files that do still reference them, and these references are broken by the migration. My preferred solution to this would be to manually rename these mixins in a separate change prior to the module system migration and update the internal references accordingly. Does that work for you? If so, what new naming structure would you prefer for these mixins? |
SGTM. We can rename these mixins from BEM-style to conventional mixin names. For example, |
Yeah, that works. Should I make the PR and CL or should you? |
I'm working on figuring out migrations for the remaining 3 components. I think I have one working for
|
SGTM for textarea and chip-set. Thanks for clear comms. |
One more thing for |
Yes, we can rename that mixin. |
As discussed offline with @abhiomkar and @aprigogin, we'd like to migrate the stylesheets in this repo to use the Sass module system.
I'm working on preparing a script that uses the Sass migrator to handle most of this migration, but I have a question about how to handle member prefixes.
Right now, most variables, mixins, and functions are manually namespaced with
mdc-<component>-
. Since the module system adds automatic namespacing, it makes sense to remove these manual prefixes (which the migrator can handle automatically).However, there are two cases where this pattern doesn't quite hold:
mdc-theme/_color-palette.scss
are instead prefixed withmaterial-color-
. For these variables, should we just leave their names as-is?mdc-<component>
(so removing the prefix would leave an empty name). How should these be handled?Examples (there might be more though):
mdc-elevation
mdc-layout-grid
mdc-rtl
mdc-typography
Note that however we choose to handle namespacing during this migration, we'll add import-only files that forward the members with their original, manually-namespaced names. When downstream users migrate, the migrator will be able to detect this and automatically change these names when necessary.
The text was updated successfully, but these errors were encountered: