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): v15 migrate import declarations #25133
feat(material/schematics): v15 migrate import declarations #25133
Conversation
d855620
to
df0e848
Compare
return createUpdate(arg, {old: arg.text, new: opts.arg}); | ||
} | ||
|
||
function createUpdate(node: ts.Node, substring: {old: string; new: string}): Update { |
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.
OOC: Why do we need to handle everything through captured updates, sorted by indices, if we could directly apply the updates? The original file indices are usable and that is what we use in all other migrations: https://github.com/angular/angular-cli/blob/3884b865262c1ffa5652ac0f4d67bbf59087f453/packages/angular_devkit/schematics/src/utility/update-buffer.ts#L330
just mentioning this for additional information. I guess my concern is that this is now a material schematics utilities folder but the concept of update objects is untypical
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.
Directly applying the updates could cause problems with collisions, so capturing everything as updates avoids this issue altogether
E.g.
Given the following scenario, if the import was updated first, the stored position of the console.log would be stale. Contrarily, if the export name MatButton
was renamed before the module specifier @angular/...
was changed, the stored position of the module specifier would be stale
some-file.ts (before)
import {MatButton} from '@angular/material/button';
...
console.log(MatButton);
some-file.ts (after)
import {MatLegacyButton} from '@angular/material/legacy-button';
...
console.log(MatLegacyButton);
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.
@wagnermaciel that's exactly it. If you would always only analyze the original source file and migrate on top of that, the original indices will remain known to the update recorder and the devkit update recorder/magic-string could perform all the replacements, even though if offsets would be shifted around.
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'm a little bit confused, but it seems like you're saying the devkit update recorder/magic-string already solves this problem in a standardized way? I've never tried using it, but from what I see here it looks promising
I'll give it a shot and re-request review once I'm done
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.
yeah, feel free to land this for now, but I'm just trying to avoid these common schematics utilities as all other migrations never required this. The magic string/update-recorder really handles this "magically". This is also why the insert left and insert right methods exist -- trying to keep original indices as is -- and placing stuff in between without shifting offsets known to the recorder. Magic string has a good readme IIRC
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.
Took a step back here and started working from the v15 legacy-components ng-update migration side of things. I'll revisit sharing code with the v15 mdc-migration ng-generate migration through a migration-utilities later
* implement import declaration migrations for v15 legacy components ng-update
138a065
to
9f2a295
Compare
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.
Nice, LGTM. Pretty easy now with directly using the update recorder right? 😄
src/material/schematics/ng-update/migrations/legacy-components-v15/index.ts
Outdated
Show resolved
Hide resolved
src/material/schematics/ng-update/migrations/legacy-components-v15/index.ts
Outdated
Show resolved
Hide resolved
* implement import expression migrations for v15 legacy components ng-update
67cb8f6
to
6759543
Compare
Yeah, ty for the advice! 👍🏽 |
* feat(material/schematics): v15 migrate import declarations * implement import declaration migrations for v15 legacy components ng-update * feat(material/schematics): v15 migrate import expressions * implement import expression migrations for v15 legacy components ng-update
* feat(material/schematics): v15 migrate import declarations * implement import declaration migrations for v15 legacy components ng-update * feat(material/schematics): v15 migrate import expressions * implement import expression migrations for v15 legacy components ng-update
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. |
v15 legacy components ng-update