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
feat(material/schematics): initial setup for template migrations #24515
feat(material/schematics): initial setup for template migrations #24515
Conversation
wagnermaciel
commented
Mar 3, 2022
- created TemplateMigration for migrating templates
- added it to the migrations for the mdc-migration schematic
* created TemplateMigration for migrating templates * added it to the migrations for the mdc-migration schematic
* | ||
* @param nodes The nodes of the ast from a parsed template. | ||
* @param preorderCallback A function that gets run for each Element node in a preorder traversal. | ||
* @param postorderCallback A function that gets run for each Element node in a postorder traversal. |
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.
Usually what we did for migrations that have problems like that (the line collisions), we captured edits and just sorted them in reverse for the offset. That makes things a little easier. Might be worth doing, but not feeling strongly.
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 considered that option because it can handle more complex queries in a single pass whereas this approach will need two in some cases. However, this solution requires less code which I think is desirable for this project since there are only three components getting migrated
In other words, in this case I'm valuing simplicity over performance
import {Migration, ResolvedResource} from '@angular/cdk/schematics'; | ||
import {SchematicContext} from '@angular-devkit/schematics'; | ||
import {StyleMigrator} from './style-migrator'; | ||
import * as compiler from '@angular/compiler'; |
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.
It's super nice that this works. In framwork we needed a huge, painful workaround for this since schematics are CJS, but Angular packages are strict ESM. But here it works out nicely because we've set up bundling for the Sass AST, so it just works out nicely for the compiler as well! 😄
…ular#24515) * feat(material/schematics): initial setup for template migrations * created TemplateMigration for migrating templates * added it to the migrations for the mdc-migration schematic
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |