Skip to content
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

Merged
merged 5 commits into from Mar 7, 2022

Conversation

wagnermaciel
Copy link
Contributor

  • 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
@wagnermaciel wagnermaciel added the target: feature This PR is targeted for a feature branch (outside of main and semver branches) label Mar 4, 2022
*
* @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.
Copy link
Member

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.

Copy link
Contributor Author

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';
Copy link
Member

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! 😄

@wagnermaciel wagnermaciel merged commit e7c6f0b into angular:mdc-migration Mar 7, 2022
devversion pushed a commit to devversion/material2 that referenced this pull request Mar 14, 2022
…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
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
target: feature This PR is targeted for a feature branch (outside of main and semver branches)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants