feat(schematics): rewrite Vertex AI imports to AI Logic on ng update - #3725
Open
armando-navarro wants to merge 1 commit into
Open
feat(schematics): rewrite Vertex AI imports to AI Logic on ng update#3725armando-navarro wants to merge 1 commit into
armando-navarro wants to merge 1 commit into
Conversation
AngularFire 21 renamed the Vertex AI module to Firebase AI Logic: the @angular/fire/vertexai and older @angular/fire/vertexai-preview entry points were removed in favor of @angular/fire/ai, and the exported symbols were renamed (getVertexAI to getAI, provideVertexAI to provideAI, VertexAI to AI, and so on). A workspace on 20 that used Vertex AI would fail to compile after the upgrade. Extend the existing v21 migration (which aligns the firebase dependency) to also rewrite these imports and their usages. The rewrite parses each source file with the TypeScript compiler and edits only genuine references, so it leaves strings, comments, and unrelated identifiers that merely share a name untouched. It handles named imports and their aliases, namespace imports in both value and type position, bare local re-exports, and shorthand properties. The one accepted limitation is name shadowing: because the rewrite matches by name, a local variable that shadows an imported name with the same spelling can be mis-renamed. ng update always presents its changes as a diff for review, so this is caught on inspection. Also add typescript to the schematics esbuild externals so the compiler is resolved from the workspace at ng-update time rather than bundled into the package, matching how Angular's own migrations ship. Docs: add a 20-to-21 upgrade guide, note the rename in the AI Logic guide, and link the upgrade guide from the README. Refs angular#3686
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an
ng updatemigration that moves a workspace off the Vertex AI module onto Firebase AI Logic, and a guide for upgrading from AngularFire 20 to 21.Background
AngularFire 21 renamed the Vertex AI module to Firebase AI Logic. The
@angular/fire/vertexaientry point (and the older@angular/fire/vertexai-preview) were removed in favor of@angular/fire/ai, and the exported symbols were renamed. A project upgrading from 20 that used Vertex AI would fail to compile until it updated those imports by hand.What this does
firebasedependency) to also rewrite Vertex AI imports and their usages to AI Logic. It parses each source file with the TypeScript compiler and edits only real references, leaving strings, comments, and unrelated identifiers that happen to share a name untouched. It handles named imports and aliases, namespace imports in value and type position, bare local re-exports, and shorthand properties.docs/version-21-upgrade.md, a note indocs/ai.md, and a README link.typescriptto the schematics esbuild externals, so the compiler is resolved from the workspace atng updatetime rather than bundled into the package. This matches how Angular's own migrations ship and keeps the package from growing by several megabytes.Symbol map
@angular/fire/vertexai)@angular/fire/ai)getVertexAIgetAIprovideVertexAIprovideAIVertexAIAIVertexAIInstancesAIInstancesvertexAIInstance$AIInstance$VertexAIModuleAIModulegetGenerativeModelandgetImagenModelkeep their names.Known limitation
The rewrite matches by name, so a local variable that shadows an imported name with the same spelling can be mis-renamed.
ng updatealways shows its changes as a diff to review, so this surfaces on inspection.Verification
Unit specs cover each kind of code the migration can run into:
ns.getVertexAI()) and type position (ns.VertexAI){ getVertexAI }) and bare local re-exports (export { VertexAI })I also ran the migration for real, not just in specs:
@angular/fire/vertexaing updateand confirmed every import and usage rewrote to@angular/fire/aifirebasealigned to^12.4.0, and that a second run made no changesRefs #3686