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(core): add automatic migration from Renderer to Renderer2 #30936
Conversation
491965d
to
2c570bd
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.
Thanks for doing all this work! Seems like it is pretty close! Some thoughts below
packages/core/schematics/migrations/renderer-to-renderer2/README.md
Outdated
Show resolved
Hide resolved
packages/core/schematics/migrations/renderer-to-renderer2/google3/rendererToRenderer2Rule.ts
Outdated
Show resolved
Hide resolved
packages/core/schematics/migrations/renderer-to-renderer2/google3/rendererToRenderer2Rule.ts
Outdated
Show resolved
Hide resolved
packages/core/schematics/migrations/renderer-to-renderer2/helpers.ts
Outdated
Show resolved
Hide resolved
packages/core/schematics/migrations/renderer-to-renderer2/helpers.ts
Outdated
Show resolved
Hide resolved
packages/core/schematics/migrations/renderer-to-renderer2/helpers.ts
Outdated
Show resolved
Hide resolved
packages/core/schematics/migrations/renderer-to-renderer2/google3/rendererToRenderer2Rule.ts
Show resolved
Hide resolved
packages/core/schematics/migrations/renderer-to-renderer2/index.ts
Outdated
Show resolved
Hide resolved
packages/core/schematics/migrations/renderer-to-renderer2/helpers.ts
Outdated
Show resolved
Hide resolved
packages/core/schematics/migrations/renderer-to-renderer2/index.ts
Outdated
Show resolved
Hide resolved
packages/core/schematics/migrations/renderer-to-renderer2/util.ts
Outdated
Show resolved
Hide resolved
packages/core/schematics/migrations/renderer-to-renderer2/migration.ts
Outdated
Show resolved
Hide resolved
2c570bd
to
8cbfd01
Compare
@kara @jelbourn @devversion I've addressed all of the feedback. Can you take another look? |
I'll tsunami this over google3 code now to look for broken corner cases |
I'll do a global presubmit run across google3 where I hide the One thing we need to do in order to land this is update |
@alexeagle Let's land the platform-browser change in a follow-up? |
packages/core/schematics/migrations/renderer-to-renderer2/index.ts
Outdated
Show resolved
Hide resolved
packages/core/schematics/migrations/renderer-to-renderer2/index.ts
Outdated
Show resolved
Hide resolved
packages/core/schematics/migrations/renderer-to-renderer2/helpers.ts
Outdated
Show resolved
Hide resolved
#31162 has the removal of Renderer from platform-browser-dynamic |
I ran a global presubmit across all of Google code and confirmed it's green: this migration found all the locations where Renderer was used. |
d123ed4
to
70289a8
Compare
@kara can you take another look? I've updated it to incorporate yours and Paul's feedback. I've also added handling for |
81d82a0
to
bd5e5db
Compare
packages/core/schematics/migrations/renderer-to-renderer2/helpers.ts
Outdated
Show resolved
Hide resolved
packages/core/schematics/migrations/renderer-to-renderer2/helpers.ts
Outdated
Show resolved
Hide resolved
Adds a schematic and tslint rule that automatically migrate the consumer from `Renderer` to `Renderer2`. Supports: * Renaming imports. * Renaming property and method argument types. * Casting to `Renderer`. * Mapping all of the methods from the `Renderer` to `Renderer2`. Note that some of the `Renderer` methods don't map cleanly between renderers. In these cases the migration adds a helper function at the bottom of the file which ensures that we generate valid code with the same return value as before. E.g. here's what the migration for `createText` looks like. Before: ``` class SomeComponent { createAndAddText() { const node = this._renderer.createText(this._element.nativeElement, 'hello'); node.textContent += ' world'; } } ``` After: ``` class SomeComponent { createAndAddText() { const node = __rendererCreateTextHelper(this._renderer, this._element.nativeElement, 'hello'); node.textContent += ' world'; } } function __rendererCreateTextHelper(renderer: any, parent: any, value: any) { const node = renderer.createText(value); if (parent) { renderer.appendChild(parent, node); } return node; } ``` This PR resolves FW-1344.
bd5e5db
to
9ed1a44
Compare
Addressed the latest set of comments. |
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.
LGTM
Merge-assistance: codefresh OOM |
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. |
Adds a schematic and tslint rule that automatically migrate the consumer from
Renderer
toRenderer2
. Supports:Renderer
.Renderer
toRenderer2
.Note that some of the
Renderer
methods don't map cleanly between renderers. In these cases the migration adds a helper function at the bottom of the file which ensures that we generate valid code with the same return value as before. E.g. here's what the migration forcreateText
looks like.Before:
After:
This PR resolves FW-1344.