fix: Prevented double -v4 substitution in the update-v4 schematic (20.3.x) - #103
Open
Ionaru wants to merge 1 commit into
Open
fix: Prevented double -v4 substitution in the update-v4 schematic (20.3.x)#103Ionaru wants to merge 1 commit into
Ionaru wants to merge 1 commit into
Conversation
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.
Fixes #99
Problem
ng g @angular-architects/native-federation-v4:update-v4 <project>rewrites the federation config import to@angular-architects/native-federation-v4-v4/config(doubled-v4), which does not resolve, so the build fails until corrected by hand.Cause
Two substitution passes in
migrateFederationConfigscompound:@angular-architects/native-federation-v4/config.(?!/)lookahead only guards against a following/and the next character here is-. It appends a second-v4.Note: reordering the replacements (as suggested as an alternative in the issue) would not help, since the first substitution happens in the require-to-import rewrite before either content-level replacement runs.
Fix
Guard both substitutions against an already-substituted prefix:
(?!-v4)lookahead.(?!/)to(?!/|-v4).The conservative semantics of the bare replacement (skip subpaths other than
/config) are unchanged.Tests
Added
packages/angular/src/schematics/update-v4/schematic.spec.tscovering the reported repro (CJS config on v3) and idempotence (a require path already on v4 stays single-v4). Both failed before the fix, reproducing-v4-v4/configand-v4-v4-v4/configrespectively, and pass after. Full suite, typecheck, and lint are clean.This is the same change as #102, ported to the 20.3.x branch (monorepo layout).