Skip to content

Commit db82bfc

Browse files
committed
Step 2 - Add exposes and remoteEntry in import-map-config.json
1 parent c57bfab commit db82bfc

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

apps/mf1-application/tsconfig.app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"outDir": "../../dist/out-tsc",
55
"types": []
66
},
7-
"files": ["src/main.ts", "../../libs/nx-angular-mf/src/index.ts"],
7+
"files": ["src/main.ts", "../../libs/nx-angular-mf/src/index.ts", "src/app/remote/second/index.ts"],
88
"include": ["src/**/*.d.ts"],
99
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
1010
}

libs/nx-angular-mf/src/builders/es-plugin/entry-point-for-extend-dependencies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function entryPointForExtendDependencies(config: ConfigMf): Plugin {
1515
acum[key] = value.entryPoint;
1616
return acum;
1717
},
18-
{ }
18+
{ ...config.exposes }
1919
);
2020

2121
delete build.initialOptions.define.ngServerMode;

libs/nx-angular-mf/src/builders/helpers/prepare-config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ export async function prepareConfig(
5555
);
5656
}
5757

58+
if (
59+
defaultOptions.exposes &&
60+
Object.keys(defaultOptions.exposes).length > 0
61+
) {
62+
for (const [key, value] of Object.entries(defaultOptions.exposes)) {
63+
exposes[key] = join(workspaceRootPath, value);
64+
}
65+
}
66+
5867
return {
5968
skipList: skipList,
6069
externalList: externalList,

libs/nx-angular-mf/src/builders/helpers/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,12 @@ export function getDataForImportMap(
5454

5555
return acum;
5656
}, {}),
57+
exposes: Object.entries(mfeConfig.exposes).reduce((acum, [key, val]) => {
58+
const resultName =
59+
mfeConfig.outPutFileNames.find((i) => i.startsWith(key)) || key + '.js';
60+
acum[key] = './' + resultName;
61+
return acum;
62+
}, {}),
63+
remoteEntry: mfeConfig.remoteEntry,
5764
};
5865
}

libs/nx-angular-mf/src/builders/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ export type MapPackage = Map<
2828

2929
export type DataForImportMap = {
3030
imports: Record<string, string>;
31+
exposes: Record<string, string>;
32+
remoteEntry: Record<string, string>;
3133
};

0 commit comments

Comments
 (0)