@nx/angular 20.1.0-canary.20241101-d4f4dac → 20.1.0-canary.20241105-b925f8c
Sign up to get free protection for your applications and to get access to all the features.
- package/esm2022/mf/mf.mjs +65 -1
- package/fesm2022/nx-angular-mf.mjs +64 -0
- package/fesm2022/nx-angular-mf.mjs.map +1 -1
- package/mf/mf.d.ts +64 -0
- package/package.json +7 -7
- package/src/generators/setup-mf/lib/add-remote-to-host.js +21 -8
- package/src/generators/setup-mf/lib/fix-bootstrap.js +3 -2
- package/src/generators/setup-mf/setup-mf.js +3 -2
package/esm2022/mf/mf.mjs
CHANGED
@@ -1,17 +1,81 @@
|
|
1
1
|
let resolveRemoteUrl;
|
2
|
+
/**
|
3
|
+
* @deprecated Use Runtime Helpers from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
|
4
|
+
*/
|
2
5
|
export function setRemoteUrlResolver(_resolveRemoteUrl) {
|
3
6
|
resolveRemoteUrl = _resolveRemoteUrl;
|
4
7
|
}
|
5
8
|
let remoteUrlDefinitions;
|
9
|
+
/**
|
10
|
+
* @deprecated Use init() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
|
11
|
+
* If you have a remote app called `my-remote-app` and you want to use the `http://localhost:4201/mf-manifest.json` as the remote url, you should change it from:
|
12
|
+
* ```ts
|
13
|
+
* import { setRemoteDefinitions } from '@nx/angular/mf';
|
14
|
+
*
|
15
|
+
* setRemoteDefinitions({
|
16
|
+
* 'my-remote-app': 'http://localhost:4201/mf-manifest.json'
|
17
|
+
* });
|
18
|
+
* ```
|
19
|
+
* to use init():
|
20
|
+
* ```ts
|
21
|
+
* import { init } from '@module-federation/enhanced/runtime';
|
22
|
+
*
|
23
|
+
* init({
|
24
|
+
* name: 'host',
|
25
|
+
* remotes: [{
|
26
|
+
* name: 'my-remote-app',
|
27
|
+
* entry: 'http://localhost:4201/mf-manifest.json'
|
28
|
+
* }]
|
29
|
+
* });
|
30
|
+
* ```
|
31
|
+
*/
|
6
32
|
export function setRemoteDefinitions(definitions) {
|
7
33
|
remoteUrlDefinitions = definitions;
|
8
34
|
}
|
35
|
+
/**
|
36
|
+
* @deprecated Use registerRemotes() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
|
37
|
+
* If you set a remote app with `setRemoteDefinition` such as:
|
38
|
+
* ```ts
|
39
|
+
* import { setRemoteDefinition } from '@nx/angular/mf';
|
40
|
+
*
|
41
|
+
* setRemoteDefinition(
|
42
|
+
* 'my-remote-app',
|
43
|
+
* 'http://localhost:4201/mf-manifest.json'
|
44
|
+
* );
|
45
|
+
* ```
|
46
|
+
* change it to use registerRemotes():
|
47
|
+
* ```ts
|
48
|
+
* import { registerRemotes } from '@module-federation/enhanced/runtime';
|
49
|
+
*
|
50
|
+
* registerRemotes([
|
51
|
+
* {
|
52
|
+
* name: 'my-remote-app',
|
53
|
+
* entry: 'http://localhost:4201/mf-manifest.json'
|
54
|
+
* }
|
55
|
+
* ]);
|
56
|
+
* ```
|
57
|
+
*/
|
9
58
|
export function setRemoteDefinition(remoteName, remoteUrl) {
|
10
59
|
remoteUrlDefinitions ??= {};
|
11
60
|
remoteUrlDefinitions[remoteName] = remoteUrl;
|
12
61
|
}
|
13
62
|
let remoteModuleMap = new Map();
|
14
63
|
let remoteContainerMap = new Map();
|
64
|
+
/**
|
65
|
+
* @deprecated Use loadRemote() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
|
66
|
+
* If you set a load a remote with `loadRemoteModule` such as:
|
67
|
+
* ```ts
|
68
|
+
* import { loadRemoteModule } from '@nx/angular/mf';
|
69
|
+
*
|
70
|
+
* loadRemoteModule('my-remote-app', './Module').then(m => m.RemoteEntryModule);
|
71
|
+
* ```
|
72
|
+
* change it to use loadRemote():
|
73
|
+
* ```ts
|
74
|
+
* import { loadRemote } from '@module-federation/enhanced/runtime';
|
75
|
+
*
|
76
|
+
* loadRemote<typeof import('my-remote-app/Module')>('my-remote-app/Module').then(m => m.RemoteEntryModule);
|
77
|
+
* ```
|
78
|
+
*/
|
15
79
|
export async function loadRemoteModule(remoteName, moduleName) {
|
16
80
|
const remoteModuleKey = `${remoteName}:${moduleName}`;
|
17
81
|
if (remoteModuleMap.has(remoteModuleKey)) {
|
@@ -49,4 +113,4 @@ async function loadRemoteContainer(remoteName) {
|
|
49
113
|
remoteContainerMap.set(remoteName, container);
|
50
114
|
return container;
|
51
115
|
}
|
52
|
-
//# sourceMappingURL=data:application/json;base64,
|
116
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWYuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9hbmd1bGFyL21mL21mLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQU9BLElBQUksZ0JBQTBDLENBQUM7QUFFL0M7O0dBRUc7QUFDSCxNQUFNLFVBQVUsb0JBQW9CLENBQ2xDLGlCQUEyQztJQUUzQyxnQkFBZ0IsR0FBRyxpQkFBaUIsQ0FBQztBQUN2QyxDQUFDO0FBRUQsSUFBSSxvQkFBNEMsQ0FBQztBQUVqRDs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQXNCRztBQUNILE1BQU0sVUFBVSxvQkFBb0IsQ0FBQyxXQUFtQztJQUN0RSxvQkFBb0IsR0FBRyxXQUFXLENBQUM7QUFDckMsQ0FBQztBQUVEOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBc0JHO0FBQ0gsTUFBTSxVQUFVLG1CQUFtQixDQUFDLFVBQWtCLEVBQUUsU0FBaUI7SUFDdkUsb0JBQW9CLEtBQUssRUFBRSxDQUFDO0lBQzVCLG9CQUFvQixDQUFDLFVBQVUsQ0FBQyxHQUFHLFNBQVMsQ0FBQztBQUMvQyxDQUFDO0FBRUQsSUFBSSxlQUFlLEdBQUcsSUFBSSxHQUFHLEVBQW1CLENBQUM7QUFDakQsSUFBSSxrQkFBa0IsR0FBRyxJQUFJLEdBQUcsRUFBbUIs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EZWZpbml0aW9uc1xuICAgID8gcmVtb3RlVXJsRGVmaW5pdGlvbnNbcmVtb3RlTmFtZV1cbiAgICA6IGF3YWl0IHJlc29sdmVSZW1vdGVVcmwocmVtb3RlTmFtZSk7XG5cbiAgbGV0IGNvbnRhaW5lclVybCA9IHJlbW90ZVVybDtcbiAgaWYgKCFyZW1vdGVVcmwuZW5kc1dpdGgoJy5tanMnKSAmJiAhcmVtb3RlVXJsLmVuZHNXaXRoKCcuanMnKSkge1xuICAgIGNvbnRhaW5lclVybCA9IGAke3JlbW90ZVVybH0ke1xuICAgICAgcmVtb3RlVXJsLmVuZHNXaXRoKCcvJykgPyAnJyA6ICcvJ1xuICAgIH1yZW1vdGVFbnRyeS5tanNgO1xuICB9XG5cbiAgY29uc3QgY29udGFpbmVyID0gYXdhaXQgbG9hZE1vZHVsZShjb250YWluZXJVcmwpO1xuICBhd2FpdCBjb250YWluZXIuaW5pdChfX3dlYnBhY2tfc2hhcmVfc2NvcGVzX18uZGVmYXVsdCk7XG5cbiAgcmVtb3RlQ29udGFpbmVyTWFwLnNldChyZW1vdGVOYW1lLCBjb250YWluZXIpO1xuICByZXR1cm4gY29udGFpbmVyO1xufVxuIl19
|
@@ -1,17 +1,81 @@
|
|
1
1
|
let resolveRemoteUrl;
|
2
|
+
/**
|
3
|
+
* @deprecated Use Runtime Helpers from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
|
4
|
+
*/
|
2
5
|
function setRemoteUrlResolver(_resolveRemoteUrl) {
|
3
6
|
resolveRemoteUrl = _resolveRemoteUrl;
|
4
7
|
}
|
5
8
|
let remoteUrlDefinitions;
|
9
|
+
/**
|
10
|
+
* @deprecated Use init() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
|
11
|
+
* If you have a remote app called `my-remote-app` and you want to use the `http://localhost:4201/mf-manifest.json` as the remote url, you should change it from:
|
12
|
+
* ```ts
|
13
|
+
* import { setRemoteDefinitions } from '@nx/angular/mf';
|
14
|
+
*
|
15
|
+
* setRemoteDefinitions({
|
16
|
+
* 'my-remote-app': 'http://localhost:4201/mf-manifest.json'
|
17
|
+
* });
|
18
|
+
* ```
|
19
|
+
* to use init():
|
20
|
+
* ```ts
|
21
|
+
* import { init } from '@module-federation/enhanced/runtime';
|
22
|
+
*
|
23
|
+
* init({
|
24
|
+
* name: 'host',
|
25
|
+
* remotes: [{
|
26
|
+
* name: 'my-remote-app',
|
27
|
+
* entry: 'http://localhost:4201/mf-manifest.json'
|
28
|
+
* }]
|
29
|
+
* });
|
30
|
+
* ```
|
31
|
+
*/
|
6
32
|
function setRemoteDefinitions(definitions) {
|
7
33
|
remoteUrlDefinitions = definitions;
|
8
34
|
}
|
35
|
+
/**
|
36
|
+
* @deprecated Use registerRemotes() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
|
37
|
+
* If you set a remote app with `setRemoteDefinition` such as:
|
38
|
+
* ```ts
|
39
|
+
* import { setRemoteDefinition } from '@nx/angular/mf';
|
40
|
+
*
|
41
|
+
* setRemoteDefinition(
|
42
|
+
* 'my-remote-app',
|
43
|
+
* 'http://localhost:4201/mf-manifest.json'
|
44
|
+
* );
|
45
|
+
* ```
|
46
|
+
* change it to use registerRemotes():
|
47
|
+
* ```ts
|
48
|
+
* import { registerRemotes } from '@module-federation/enhanced/runtime';
|
49
|
+
*
|
50
|
+
* registerRemotes([
|
51
|
+
* {
|
52
|
+
* name: 'my-remote-app',
|
53
|
+
* entry: 'http://localhost:4201/mf-manifest.json'
|
54
|
+
* }
|
55
|
+
* ]);
|
56
|
+
* ```
|
57
|
+
*/
|
9
58
|
function setRemoteDefinition(remoteName, remoteUrl) {
|
10
59
|
remoteUrlDefinitions ??= {};
|
11
60
|
remoteUrlDefinitions[remoteName] = remoteUrl;
|
12
61
|
}
|
13
62
|
let remoteModuleMap = new Map();
|
14
63
|
let remoteContainerMap = new Map();
|
64
|
+
/**
|
65
|
+
* @deprecated Use loadRemote() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
|
66
|
+
* If you set a load a remote with `loadRemoteModule` such as:
|
67
|
+
* ```ts
|
68
|
+
* import { loadRemoteModule } from '@nx/angular/mf';
|
69
|
+
*
|
70
|
+
* loadRemoteModule('my-remote-app', './Module').then(m => m.RemoteEntryModule);
|
71
|
+
* ```
|
72
|
+
* change it to use loadRemote():
|
73
|
+
* ```ts
|
74
|
+
* import { loadRemote } from '@module-federation/enhanced/runtime';
|
75
|
+
*
|
76
|
+
* loadRemote<typeof import('my-remote-app/Module')>('my-remote-app/Module').then(m => m.RemoteEntryModule);
|
77
|
+
* ```
|
78
|
+
*/
|
15
79
|
async function loadRemoteModule(remoteName, moduleName) {
|
16
80
|
const remoteModuleKey = `${remoteName}:${moduleName}`;
|
17
81
|
if (remoteModuleMap.has(remoteModuleKey)) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nx-angular-mf.mjs","sources":["../../../../packages/angular/mf/mf.ts","../../../../packages/angular/mf/nx-angular-mf.ts"],"sourcesContent":["export type ResolveRemoteUrlFunction = (\n remoteName: string\n) => string | Promise<string>;\n\ndeclare const __webpack_init_sharing__: (scope: 'default') => Promise<void>;\ndeclare const __webpack_share_scopes__: { default: unknown };\n\nlet resolveRemoteUrl: ResolveRemoteUrlFunction;\n\nexport function setRemoteUrlResolver(\n _resolveRemoteUrl: ResolveRemoteUrlFunction\n) {\n resolveRemoteUrl = _resolveRemoteUrl;\n}\n\nlet remoteUrlDefinitions: Record<string, string>;\n\nexport function setRemoteDefinitions(definitions: Record<string, string>) {\n remoteUrlDefinitions = definitions;\n}\n\nexport function setRemoteDefinition(remoteName: string, remoteUrl: string) {\n remoteUrlDefinitions ??= {};\n remoteUrlDefinitions[remoteName] = remoteUrl;\n}\n\nlet remoteModuleMap = new Map<string, unknown>();\nlet remoteContainerMap = new Map<string, unknown>();\n\nexport async function loadRemoteModule(remoteName: string, moduleName: string) {\n const remoteModuleKey = `${remoteName}:${moduleName}`;\n if (remoteModuleMap.has(remoteModuleKey)) {\n return remoteModuleMap.get(remoteModuleKey);\n }\n\n const container = remoteContainerMap.has(remoteName)\n ? remoteContainerMap.get(remoteName)\n : await loadRemoteContainer(remoteName);\n\n const factory = await container.get(moduleName);\n const Module = factory();\n\n remoteModuleMap.set(remoteModuleKey, Module);\n\n return Module;\n}\n\nfunction loadModule(url: string) {\n return import(/* webpackIgnore:true */ url);\n}\n\nlet initialSharingScopeCreated = false;\n\nasync function loadRemoteContainer(remoteName: string) {\n if (!resolveRemoteUrl && !remoteUrlDefinitions) {\n throw new Error(\n 'Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.'\n );\n }\n\n if (!initialSharingScopeCreated) {\n initialSharingScopeCreated = true;\n await __webpack_init_sharing__('default');\n }\n\n const remoteUrl = remoteUrlDefinitions\n ? remoteUrlDefinitions[remoteName]\n : await resolveRemoteUrl(remoteName);\n\n let containerUrl = remoteUrl;\n if (!remoteUrl.endsWith('.mjs') && !remoteUrl.endsWith('.js')) {\n containerUrl = `${remoteUrl}${\n remoteUrl.endsWith('/') ? '' : '/'\n }remoteEntry.mjs`;\n }\n\n const container = await loadModule(containerUrl);\n await container.init(__webpack_share_scopes__.default);\n\n remoteContainerMap.set(remoteName, container);\n return container;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAOA,IAAI,gBAA0C,CAAC;
|
1
|
+
{"version":3,"file":"nx-angular-mf.mjs","sources":["../../../../packages/angular/mf/mf.ts","../../../../packages/angular/mf/nx-angular-mf.ts"],"sourcesContent":["export type ResolveRemoteUrlFunction = (\n remoteName: string\n) => string | Promise<string>;\n\ndeclare const __webpack_init_sharing__: (scope: 'default') => Promise<void>;\ndeclare const __webpack_share_scopes__: { default: unknown };\n\nlet resolveRemoteUrl: ResolveRemoteUrlFunction;\n\n/**\n * @deprecated Use Runtime Helpers from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.\n */\nexport function setRemoteUrlResolver(\n _resolveRemoteUrl: ResolveRemoteUrlFunction\n) {\n resolveRemoteUrl = _resolveRemoteUrl;\n}\n\nlet remoteUrlDefinitions: Record<string, string>;\n\n/**\n * @deprecated Use init() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.\n * If you have a remote app called `my-remote-app` and you want to use the `http://localhost:4201/mf-manifest.json` as the remote url, you should change it from:\n * ```ts\n * import { setRemoteDefinitions } from '@nx/angular/mf';\n *\n * setRemoteDefinitions({\n * 'my-remote-app': 'http://localhost:4201/mf-manifest.json'\n * });\n * ```\n * to use init():\n * ```ts\n * import { init } from '@module-federation/enhanced/runtime';\n *\n * init({\n * name: 'host',\n * remotes: [{\n * name: 'my-remote-app',\n * entry: 'http://localhost:4201/mf-manifest.json'\n * }]\n * });\n * ```\n */\nexport function setRemoteDefinitions(definitions: Record<string, string>) {\n remoteUrlDefinitions = definitions;\n}\n\n/**\n * @deprecated Use registerRemotes() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.\n * If you set a remote app with `setRemoteDefinition` such as:\n * ```ts\n * import { setRemoteDefinition } from '@nx/angular/mf';\n *\n * setRemoteDefinition(\n * 'my-remote-app',\n * 'http://localhost:4201/mf-manifest.json'\n * );\n * ```\n * change it to use registerRemotes():\n * ```ts\n * import { registerRemotes } from '@module-federation/enhanced/runtime';\n *\n * registerRemotes([\n * {\n * name: 'my-remote-app',\n * entry: 'http://localhost:4201/mf-manifest.json'\n * }\n * ]);\n * ```\n */\nexport function setRemoteDefinition(remoteName: string, remoteUrl: string) {\n remoteUrlDefinitions ??= {};\n remoteUrlDefinitions[remoteName] = remoteUrl;\n}\n\nlet remoteModuleMap = new Map<string, unknown>();\nlet remoteContainerMap = new Map<string, unknown>();\n\n/**\n * @deprecated Use loadRemote() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.\n * If you set a load a remote with `loadRemoteModule` such as:\n * ```ts\n * import { loadRemoteModule } from '@nx/angular/mf';\n *\n * loadRemoteModule('my-remote-app', './Module').then(m => m.RemoteEntryModule);\n * ```\n * change it to use loadRemote():\n * ```ts\n * import { loadRemote } from '@module-federation/enhanced/runtime';\n *\n * loadRemote<typeof import('my-remote-app/Module')>('my-remote-app/Module').then(m => m.RemoteEntryModule);\n * ```\n */\nexport async function loadRemoteModule(remoteName: string, moduleName: string) {\n const remoteModuleKey = `${remoteName}:${moduleName}`;\n if (remoteModuleMap.has(remoteModuleKey)) {\n return remoteModuleMap.get(remoteModuleKey);\n }\n\n const container = remoteContainerMap.has(remoteName)\n ? remoteContainerMap.get(remoteName)\n : await loadRemoteContainer(remoteName);\n\n const factory = await container.get(moduleName);\n const Module = factory();\n\n remoteModuleMap.set(remoteModuleKey, Module);\n\n return Module;\n}\n\nfunction loadModule(url: string) {\n return import(/* webpackIgnore:true */ url);\n}\n\nlet initialSharingScopeCreated = false;\n\nasync function loadRemoteContainer(remoteName: string) {\n if (!resolveRemoteUrl && !remoteUrlDefinitions) {\n throw new Error(\n 'Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.'\n );\n }\n\n if (!initialSharingScopeCreated) {\n initialSharingScopeCreated = true;\n await __webpack_init_sharing__('default');\n }\n\n const remoteUrl = remoteUrlDefinitions\n ? remoteUrlDefinitions[remoteName]\n : await resolveRemoteUrl(remoteName);\n\n let containerUrl = remoteUrl;\n if (!remoteUrl.endsWith('.mjs') && !remoteUrl.endsWith('.js')) {\n containerUrl = `${remoteUrl}${\n remoteUrl.endsWith('/') ? '' : '/'\n }remoteEntry.mjs`;\n }\n\n const container = await loadModule(containerUrl);\n await container.init(__webpack_share_scopes__.default);\n\n remoteContainerMap.set(remoteName, container);\n return container;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAOA,IAAI,gBAA0C,CAAC;AAE/C;;AAEG;AACG,SAAU,oBAAoB,CAClC,iBAA2C,EAAA;IAE3C,gBAAgB,GAAG,iBAAiB,CAAC;AACvC,CAAC;AAED,IAAI,oBAA4C,CA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KAAK,CAAC;AAEvC,eAAe,mBAAmB,CAAC,UAAkB,EAAA;AACnD,IAAA,IAAI,CAAC,gBAAgB,IAAI,CAAC,oBAAoB,EAAE;AAC9C,QAAA,MAAM,IAAI,KAAK,CACb,kHAAkH,CACnH,CAAC;KACH;IAED,IAAI,CAAC,0BAA0B,EAAE;QAC/B,0BAA0B,GAAG,IAAI,CAAC;AAClC,QAAA,MAAM,wBAAwB,CAAC,SAAS,CAAC,CAAC;KAC3C;IAED,MAAM,SAAS,GAAG,oBAAoB;AACpC,UAAE,oBAAoB,CAAC,UAAU,CAAC;AAClC,UAAE,MAAM,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAEvC,IAAI,YAAY,GAAG,SAAS,CAAC;AAC7B,IAAA,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AAC7D,QAAA,YAAY,GAAG,CAAG,EAAA,SAAS,GACzB,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,GACjC,iBAAiB,CAAC;KACnB;AAED,IAAA,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,SAAS,CAAC,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;AAEvD,IAAA,kBAAkB,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAC9C,IAAA,OAAO,SAAS,CAAC;AACnB;;ACjJA;;AAEG;;;;"}
|
package/mf/mf.d.ts
CHANGED
@@ -1,5 +1,69 @@
|
|
1
1
|
export type ResolveRemoteUrlFunction = (remoteName: string) => string | Promise<string>;
|
2
|
+
/**
|
3
|
+
* @deprecated Use Runtime Helpers from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
|
4
|
+
*/
|
2
5
|
export declare function setRemoteUrlResolver(_resolveRemoteUrl: ResolveRemoteUrlFunction): void;
|
6
|
+
/**
|
7
|
+
* @deprecated Use init() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
|
8
|
+
* If you have a remote app called `my-remote-app` and you want to use the `http://localhost:4201/mf-manifest.json` as the remote url, you should change it from:
|
9
|
+
* ```ts
|
10
|
+
* import { setRemoteDefinitions } from '@nx/angular/mf';
|
11
|
+
*
|
12
|
+
* setRemoteDefinitions({
|
13
|
+
* 'my-remote-app': 'http://localhost:4201/mf-manifest.json'
|
14
|
+
* });
|
15
|
+
* ```
|
16
|
+
* to use init():
|
17
|
+
* ```ts
|
18
|
+
* import { init } from '@module-federation/enhanced/runtime';
|
19
|
+
*
|
20
|
+
* init({
|
21
|
+
* name: 'host',
|
22
|
+
* remotes: [{
|
23
|
+
* name: 'my-remote-app',
|
24
|
+
* entry: 'http://localhost:4201/mf-manifest.json'
|
25
|
+
* }]
|
26
|
+
* });
|
27
|
+
* ```
|
28
|
+
*/
|
3
29
|
export declare function setRemoteDefinitions(definitions: Record<string, string>): void;
|
30
|
+
/**
|
31
|
+
* @deprecated Use registerRemotes() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
|
32
|
+
* If you set a remote app with `setRemoteDefinition` such as:
|
33
|
+
* ```ts
|
34
|
+
* import { setRemoteDefinition } from '@nx/angular/mf';
|
35
|
+
*
|
36
|
+
* setRemoteDefinition(
|
37
|
+
* 'my-remote-app',
|
38
|
+
* 'http://localhost:4201/mf-manifest.json'
|
39
|
+
* );
|
40
|
+
* ```
|
41
|
+
* change it to use registerRemotes():
|
42
|
+
* ```ts
|
43
|
+
* import { registerRemotes } from '@module-federation/enhanced/runtime';
|
44
|
+
*
|
45
|
+
* registerRemotes([
|
46
|
+
* {
|
47
|
+
* name: 'my-remote-app',
|
48
|
+
* entry: 'http://localhost:4201/mf-manifest.json'
|
49
|
+
* }
|
50
|
+
* ]);
|
51
|
+
* ```
|
52
|
+
*/
|
4
53
|
export declare function setRemoteDefinition(remoteName: string, remoteUrl: string): void;
|
54
|
+
/**
|
55
|
+
* @deprecated Use loadRemote() from '@module-federation/enhanced/runtime' instead. This will be removed in Nx 22.
|
56
|
+
* If you set a load a remote with `loadRemoteModule` such as:
|
57
|
+
* ```ts
|
58
|
+
* import { loadRemoteModule } from '@nx/angular/mf';
|
59
|
+
*
|
60
|
+
* loadRemoteModule('my-remote-app', './Module').then(m => m.RemoteEntryModule);
|
61
|
+
* ```
|
62
|
+
* change it to use loadRemote():
|
63
|
+
* ```ts
|
64
|
+
* import { loadRemote } from '@module-federation/enhanced/runtime';
|
65
|
+
*
|
66
|
+
* loadRemote<typeof import('my-remote-app/Module')>('my-remote-app/Module').then(m => m.RemoteEntryModule);
|
67
|
+
* ```
|
68
|
+
*/
|
5
69
|
export declare function loadRemoteModule(remoteName: string, moduleName: string): Promise<any>;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/angular",
|
3
|
-
"version": "20.1.0-canary.
|
3
|
+
"version": "20.1.0-canary.20241105-b925f8c",
|
4
4
|
"private": false,
|
5
5
|
"description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, Playwright and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
|
6
6
|
"repository": {
|
@@ -80,12 +80,12 @@
|
|
80
80
|
"webpack-merge": "^5.8.0",
|
81
81
|
"webpack": "^5.88.0",
|
82
82
|
"@module-federation/enhanced": "0.6.9",
|
83
|
-
"@nx/devkit": "20.1.0-canary.
|
84
|
-
"@nx/js": "20.1.0-canary.
|
85
|
-
"@nx/eslint": "20.1.0-canary.
|
86
|
-
"@nx/webpack": "20.1.0-canary.
|
87
|
-
"@nx/web": "20.1.0-canary.
|
88
|
-
"@nx/workspace": "20.1.0-canary.
|
83
|
+
"@nx/devkit": "20.1.0-canary.20241105-b925f8c",
|
84
|
+
"@nx/js": "20.1.0-canary.20241105-b925f8c",
|
85
|
+
"@nx/eslint": "20.1.0-canary.20241105-b925f8c",
|
86
|
+
"@nx/webpack": "20.1.0-canary.20241105-b925f8c",
|
87
|
+
"@nx/web": "20.1.0-canary.20241105-b925f8c",
|
88
|
+
"@nx/workspace": "20.1.0-canary.20241105-b925f8c",
|
89
89
|
"piscina": "^4.4.0"
|
90
90
|
},
|
91
91
|
"peerDependencies": {
|
@@ -25,7 +25,7 @@ function addRemoteToHost(tree, options) {
|
|
25
25
|
addRemoteToStaticHost(tree, options, hostProject, isHostUsingTypescriptConfig);
|
26
26
|
}
|
27
27
|
else if (hostFederationType === 'dynamic') {
|
28
|
-
addRemoteToDynamicHost(tree, options, pathToMFManifest);
|
28
|
+
addRemoteToDynamicHost(tree, options, pathToMFManifest, hostProject.sourceRoot);
|
29
29
|
}
|
30
30
|
addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType);
|
31
31
|
}
|
@@ -58,15 +58,18 @@ function addRemoteToStaticHost(tree, options, hostProject, isHostUsingTypescript
|
|
58
58
|
const updatedConfig = `${hostMFConfig.slice(0, endOfPropertiesPos)}${isCommaNeeded ? ',' : ''}'${options.appName}',${hostMFConfig.slice(endOfPropertiesPos)}`;
|
59
59
|
tree.write(hostMFConfigPath, updatedConfig);
|
60
60
|
}
|
61
|
-
function addRemoteToDynamicHost(tree, options, pathToMfManifest) {
|
61
|
+
function addRemoteToDynamicHost(tree, options, pathToMfManifest, hostSourceRoot) {
|
62
|
+
// TODO(Colum): Remove for Nx 22
|
63
|
+
const usingLegacyDynamicFederation = tree
|
64
|
+
.read(`${hostSourceRoot}/main.ts`, 'utf-8')
|
65
|
+
.includes('setRemoteDefinitions(');
|
62
66
|
(0, devkit_1.updateJson)(tree, pathToMfManifest, (manifest) => {
|
63
67
|
return {
|
64
68
|
...manifest,
|
65
|
-
[options.appName]: `http://localhost:${options.port}`,
|
69
|
+
[options.appName]: `http://localhost:${options.port}${usingLegacyDynamicFederation ? '' : '/mf-manifest.json'}`,
|
66
70
|
};
|
67
71
|
});
|
68
72
|
}
|
69
|
-
// TODO(colum): future work: allow dev to pass to path to routing module
|
70
73
|
function addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType) {
|
71
74
|
if (!tsModule) {
|
72
75
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
@@ -78,19 +81,29 @@ function addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType) {
|
|
78
81
|
}
|
79
82
|
const hostRootRoutingFile = tree.read(pathToHostRootRouting, 'utf-8');
|
80
83
|
let sourceFile = tsModule.createSourceFile(pathToHostRootRouting, hostRootRoutingFile, tsModule.ScriptTarget.Latest, true);
|
84
|
+
// TODO(Colum): Remove for Nx 22
|
85
|
+
const usingLegacyDynamicFederation = hostFederationType === 'dynamic' &&
|
86
|
+
tree
|
87
|
+
.read(`${hostAppConfig.sourceRoot}/main.ts`, 'utf-8')
|
88
|
+
.includes('setRemoteDefinitions(');
|
81
89
|
if (hostFederationType === 'dynamic') {
|
82
|
-
sourceFile = (0, js_1.insertImport)(tree, sourceFile, pathToHostRootRouting, 'loadRemoteModule'
|
90
|
+
sourceFile = (0, js_1.insertImport)(tree, sourceFile, pathToHostRootRouting, usingLegacyDynamicFederation ? 'loadRemoteModule' : 'loadRemote', usingLegacyDynamicFederation
|
91
|
+
? '@nx/angular/mf'
|
92
|
+
: '@module-federation/enhanced/runtime');
|
83
93
|
}
|
84
94
|
const routePathName = options.standalone ? 'Routes' : 'Module';
|
85
95
|
const exportedRemote = options.standalone
|
86
96
|
? 'remoteRoutes'
|
87
97
|
: 'RemoteEntryModule';
|
98
|
+
const remoteModulePath = `${options.appName.replace(/-/g, '_')}/${routePathName}`;
|
88
99
|
const routeToAdd = hostFederationType === 'dynamic'
|
89
|
-
?
|
90
|
-
|
100
|
+
? usingLegacyDynamicFederation
|
101
|
+
? `loadRemoteModule('${options.appName.replace(/-/g, '_')}', './${routePathName}')`
|
102
|
+
: `loadRemote<typeof import('${remoteModulePath}')>('${remoteModulePath}')`
|
103
|
+
: `import('${remoteModulePath}')`;
|
91
104
|
(0, route_utils_1.addRoute)(tree, pathToHostRootRouting, `{
|
92
105
|
path: '${options.appName}',
|
93
|
-
loadChildren: () => ${routeToAdd}.then(m => m
|
106
|
+
loadChildren: () => ${routeToAdd}.then(m => m!.${exportedRemote})
|
94
107
|
}`);
|
95
108
|
const pathToAppComponentTemplate = (0, devkit_1.joinPathFragments)(hostAppConfig.sourceRoot, 'app/app.component.html');
|
96
109
|
const appComponent = tree.read(pathToAppComponentTemplate, 'utf-8');
|
@@ -20,11 +20,12 @@ function fixBootstrap(tree, appRoot, options) {
|
|
20
20
|
if (tree.exists((0, devkit_1.joinPathFragments)(appRoot, 'public/module-federation.manifest.json'))) {
|
21
21
|
manifestPath = '/module-federation.manifest.json';
|
22
22
|
}
|
23
|
-
const fetchMFManifestCode = `import {
|
23
|
+
const fetchMFManifestCode = `import { init } from '@module-federation/enhanced/runtime';
|
24
24
|
|
25
25
|
fetch('${manifestPath}')
|
26
26
|
.then((res) => res.json())
|
27
|
-
.then(
|
27
|
+
.then((remotes: Record<string, string>) => Object.entries(remotes).map(([name, entry]) => ({ name,entry})))
|
28
|
+
.then(remotes => init({name: '${options.appName}', remotes}))
|
28
29
|
.then(() => ${bootstrapImportCode});`;
|
29
30
|
tree.write(mainFilePath, fetchMFManifestCode);
|
30
31
|
}
|
@@ -19,10 +19,11 @@ async function setupMf(tree, rawOptions) {
|
|
19
19
|
(0, lib_1.removeDeadCodeFromRemote)(tree, options);
|
20
20
|
(0, lib_1.setupTspathForRemote)(tree, options);
|
21
21
|
if (!options.skipPackageJson) {
|
22
|
-
installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
22
|
+
installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
23
|
+
'@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion,
|
24
|
+
}, {
|
23
25
|
'@nx/web': versions_1.nxVersion,
|
24
26
|
'@nx/webpack': versions_1.nxVersion,
|
25
|
-
'@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion,
|
26
27
|
});
|
27
28
|
}
|
28
29
|
}
|