Skip to content

Commit a4099cb

Browse files
committed
Step 2 - Generate JSON of configuration for importmap
1 parent efcf289 commit a4099cb

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

build-skip-list.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"@angular/platform-browser-dynamic/testing",
1212
"@angular/platform-browser/testing",
1313
"@angular/router/testing",
14+
"@angular/router/upgrade",
1415
"@angular/animations/browser/testing",
1516
"@angular/common/http/testing",
1617
"@angular/common/testing",

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { getSystemPath, normalize } from '@angular-devkit/core';
22
import { workspaceRoot, readJsonFile } from '@nx/devkit';
33
import { join } from 'path';
4+
import { ConfigMf, DataForImportMap } from '../types';
5+
import { getMapName } from './dependencies';
46

57
export const workspaceRootPath = getSystemPath(normalize(workspaceRoot));
68

@@ -41,4 +43,16 @@ export function deepMergeObject(targetObject = {}, sourceObject = {}) {
4143
return copyTargetObject;
4244
}
4345

46+
export function getDataForImportMap(
47+
mfeConfig: ConfigMf,
48+
): DataForImportMap {
49+
const mapShareObject = getMapName(mfeConfig.shared, mfeConfig.sharedMappings);
50+
return {
51+
imports: [...mapShareObject.entries()].reduce((acum, [key, val]) => {
4452

53+
acum[val.packageName] = key + '.js';
54+
55+
return acum;
56+
}, {}),
57+
};
58+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ export type MapPackage = Map<
2121
string,
2222
{ packageName: string; entryPoint: string }
2323
>;
24+
25+
export type DataForImportMap = {
26+
imports: Record<string, string>;
27+
};

0 commit comments

Comments
 (0)