-
Notifications
You must be signed in to change notification settings - Fork 259
Description
With what library do you have an issue?
native-federation
Reproduction of the bug/regression with instructions
- In a monorepo with shell + remote apps, create a workspace library at libs/features/ with components (e.g. SpinnerComponent, TableFiltersComponent)
- Map it via wildcard tsconfig path:
// tsconfig.base.json
"paths": {
"@features/*": ["libs/features/src/*"]
}
- Use shareAll() in federation config:
const sharedDeps = shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' });
module.exports = withNativeFederation({
name: 'my-remote',
exposes: { './Routes': '...' },
shared: { ...sharedDeps },
});
- Import feature components in both shell and remote via wildcard path:
import { SpinnerComponent } from '@features/spinner/spinner.component';
- Serve shell + remote together: nx run-many -t serve -p shell,remote1,remote2
- Open browser console → NG0912 warnings for every component used in both shell and remote
Root cause: normalizeSharedMappings in with-native-federation.js filters out wildcard paths:
const result = paths.filter((p) =>
!(isInSkipList)(p.key, skip) &&
!p.key.includes('*') // wildcards excluded
);
Non-wildcard paths (e.g. "@admin-panel/core": ["libs/core/src/index.ts"]) are shared correctly — no collisions. Only wildcard-mapped libs are affected.
I see PR #571 addresses this — is there an ETA or a recommended workaround?
Expected behavior
Workspace libraries mapped via wildcard tsconfig paths should be shared between shell and remotes, the same way non-wildcard mapped paths are. Each component class should be loaded once at runtime, not duplicated per app.
Versions of Native/Module Federation, Angular, Node, Browser, and operating system
@angular-architects/native-federation: 21.1.1
@softarc/native-federation: 3.5.2
Angular: 21.1.5
Node: v20.19.5
Browser: Chrome
OS: macOS Darwin 24.4.0
Other information
The monorepo has 23 remote apps + shell. The libs/features/ library contains 27 feature components imported via @features/* across 489 files. Refactoring all imports to a single barrel entry point or converting to ng-packagr secondary entry points would be significant effort. A native solution for wildcard path sharing would be ideal.
I would be willing to submit a PR to fix this issue
- Yes
- No