Skip to content

update-v4 schematic writes @angular-architects/native-federation-v4-v4/config into federation.config.mjs #99

Description

@Ionaru

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

  1. An Angular 20 workspace on @angular-architects/native-federation v3 with a CommonJS federation.config.js.
  2. npm i -D @angular-architects/native-federation-v4@20.4.3
  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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions