Skip to content

fix(builders): externalize synthesized imports in exposed and mapping bundles - #146

Merged
Aukevanoost merged 1 commit into
mainfrom
issues/145
Sep 25, 2026
Merged

Aukevanoost merged 1 commit into
mainfrom
issues/145

Conversation

@Aukevanoost

@Aukevanoost Aukevanoost commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

The shared-mappings plugin from #128 was only wired into the app build. An exposed module that reaches a mapped lib through an NgModule still got Angular's synthesized deep import inlined, shipping a second instance of the lib and its InjectionTokens (NG0201).

  • Core 4.7: exposes and mappings build in separate contexts, so the lib is inlined into the expose outright.
  • Core 4.6: one context, so it collapses onto the remote's own chunk, but the host's copy of the mapping wins the import map at runtime, so it is still a second instance.

This adds createSharedMappingsPlugin(mappedPaths) to the exposed/mapping build, as suggested in the issue.

Verification

In angular-examples/angular/tractor-store, a probe NgModule (a component that injects an InjectionToken) was added to @ng-internal/ui and used via imports: [ProbeModule] in explore's exposed HomePage:

  • Before: the token was in both mfe-home-*.js and _ng_internal_ui-*.js.
  • After: the token is only in the mapping bundle, mfe-home imports @ng-internal/ui for both references, and the mapping bundle's hash is unchanged.

Closes #145

… bundles

The shared-mappings plugin was only wired into the app build. An exposed
module that reaches a mapped lib through an NgModule still got Angular's
synthesized deep import inlined, shipping a second instance of the lib and
its InjectionTokens (NG0201).

Since core 4.7 exposes and mappings build in separate contexts, so the copy
is inlined outright. With one context (core 4.6) it collapses onto the
remote's own chunk, but the host's copy of the mapping wins the import map
at runtime, so it is still a second instance.

Closes #145
@Aukevanoost
Aukevanoost merged commit 112f6cc into main Sep 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InjectionToken instance duplication causes NG0201 errors

1 participant