Skip to content

Commit 5393085

Browse files
committed
fix(nf): fix shared mappings plugin
1 parent a1dc238 commit 5393085

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

libs/native-federation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-architects/native-federation",
3-
"version": "17.0.6",
3+
"version": "17.0.7",
44
"main": "src/index.js",
55
"generators": "./collection.json",
66
"builders": "./builders.json",

libs/native-federation/src/builders/build/builder.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
NgCliAssetResult,
4040
} from '../../utils/mem-resuts';
4141
import { JsonObject } from '@angular-devkit/core';
42+
import { createSharedMappingsPlugin } from '../../utils/shared-mappings-plugin';
4243

4344
export async function* runBuilder(
4445
nfOptions: NfBuilderSchema,
@@ -82,6 +83,7 @@ export async function* runBuilder(
8283

8384
// options.externalDependencies = externals.filter((e) => e !== 'tslib');
8485
const plugins = [
86+
createSharedMappingsPlugin(config.sharedMappings),
8587
{
8688
name: 'externals',
8789
setup(build) {

libs/native-federation/src/utils/shared-mappings-plugin.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,20 @@ export function createSharedMappingsPlugin(mappedPaths: MappedPath[]): Plugin {
88
setup(build: PluginBuild) {
99
build.onResolve({ filter: /^[.]/ }, async (args) => {
1010
let mappedPath: MappedPath | null = null;
11-
if (
12-
args.path.includes('playground-lib') &&
13-
args.kind === 'import-statement'
14-
) {
11+
let isSelf = false;
12+
13+
if (args.kind === 'import-statement') {
1514
const importPath = path.join(args.resolveDir, args.path);
1615
mappedPath = mappedPaths.find((p) =>
1716
importPath.startsWith(path.dirname(p.path))
1817
);
1918
}
2019

2120
if (mappedPath) {
21+
isSelf = args.importer.startsWith(path.dirname(mappedPath.path));
22+
}
23+
24+
if (mappedPath && !isSelf) {
2225
return {
2326
path: mappedPath.key,
2427
external: true,

update-local.bat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
call npm unpublish @softarc/native-federation@2.0.5 --registry http://localhost:4873
2-
call npm unpublish @softarc/native-federation-runtime@2.0.5 --registry http://localhost:4873
3-
call npm unpublish @softarc/native-federation-esbuild@2.0.5 --registry http://localhost:4873
4-
call npm unpublish @angular-architects/native-federation@17.0.3 --registry http://localhost:4873
1+
call npm unpublish @softarc/native-federation@2.0.7 --registry http://localhost:4873
2+
call npm unpublish @softarc/native-federation-runtime@2.0.7 --registry http://localhost:4873
3+
call npm unpublish @softarc/native-federation-esbuild@2.0.7 --registry http://localhost:4873
4+
call npm unpublish @angular-architects/native-federation@17.0.7 --registry http://localhost:4873
55

66
call npx nx build native-federation
77
call npx nx build native-federation-core

0 commit comments

Comments
 (0)