Summary
ng g @angular-architects/native-federation-v4:update-v4 <project> rewrites the federation config's import to @angular-architects/native-federation-v4-v4/config (note the doubled -v4), which does not resolve. The build then fails with Cannot find package '@angular-architects/native-federation-v4-v4' until the import is corrected by hand.
Affected versions
@angular-architects/native-federation-v4@20.4.3 (dist-tag v20-support)
@angular-architects/native-federation-v4@21.2.8 (dist-tag latest)
Both ship the identical code path.
Cause
src/schematics/update-v4/schematic.js:
const V3_PACKAGE = '@angular-architects/native-federation';
const V4_PACKAGE = '@angular-architects/native-federation-v4';
// ...
content = content.replace(new RegExp(escapeRegExp(V3_PACKAGE + '/config'), 'g'), V4_PACKAGE + '/config');
content = content.replace(new RegExp(escapeRegExp(V3_PACKAGE) + '(?!/)', 'g'), V4_PACKAGE);
The first replacement produces @angular-architects/native-federation-v4/config. The second then matches the @angular-architects/native-federation prefix inside that result: its (?!/) lookahead only guards against a following /, and the next character here is -. So it substitutes a second time, giving @angular-architects/native-federation-v4-v4/config.
Reproduction
- An Angular 20 workspace on
@angular-architects/native-federation v3 with a CommonJS federation.config.js.
npm i -D @angular-architects/native-federation-v4@20.4.3
ng g @angular-architects/native-federation-v4:update-v4 <project>
Generated federation.config.mjs:
import { withNativeFederation } from '@angular-architects/native-federation-v4-v4/config';
Expected: @angular-architects/native-federation-v4/config.
Suggested fix
Make the second replacement skip an already-substituted prefix, for example by widening the lookahead to (?!\/|-v4), or by running the bare-package replacement before the /config one so the two cannot compound.
Summary
ng g @angular-architects/native-federation-v4:update-v4 <project>rewrites the federation config's import to@angular-architects/native-federation-v4-v4/config(note the doubled-v4), which does not resolve. The build then fails withCannot find package '@angular-architects/native-federation-v4-v4'until the import is corrected by hand.Affected versions
@angular-architects/native-federation-v4@20.4.3(dist-tagv20-support)@angular-architects/native-federation-v4@21.2.8(dist-taglatest)Both ship the identical code path.
Cause
src/schematics/update-v4/schematic.js:The first replacement produces
@angular-architects/native-federation-v4/config. The second then matches the@angular-architects/native-federationprefix inside that result: its(?!/)lookahead only guards against a following/, and the next character here is-. So it substitutes a second time, giving@angular-architects/native-federation-v4-v4/config.Reproduction
@angular-architects/native-federationv3 with a CommonJSfederation.config.js.npm i -D @angular-architects/native-federation-v4@20.4.3ng g @angular-architects/native-federation-v4:update-v4 <project>Generated
federation.config.mjs:Expected:
@angular-architects/native-federation-v4/config.Suggested fix
Make the second replacement skip an already-substituted prefix, for example by widening the lookahead to
(?!\/|-v4), or by running the bare-package replacement before the/configone so the two cannot compound.