@nx/angular 0.0.0-pr-26891-95f6262 → 0.0.0-pr-26482-1bdb7bd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/mf/mf.mjs +5 -2
- package/fesm2022/nx-angular-mf.mjs +4 -1
- package/fesm2022/nx-angular-mf.mjs.map +1 -1
- package/mf/mf.d.ts +1 -0
- package/migrations.json +16 -0
- package/ng-package.json +5 -1
- package/package.json +9 -15
- package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.js +2 -0
- package/src/executors/module-federation-dev-server/lib/build-static-remotes.d.ts +2 -2
- package/src/executors/module-federation-dev-server/lib/build-static-remotes.js +11 -4
- package/src/executors/module-federation-dev-server/lib/index.d.ts +0 -1
- package/src/executors/module-federation-dev-server/lib/index.js +0 -1
- package/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.d.ts +1 -1
- package/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.js +5 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +11 -21
- package/src/generators/setup-ssr/files/server/server-builder/v17+/__serverFileName__ +7 -5
- package/src/generators/utils/add-mf-env-to-inputs.js +1 -1
- package/src/generators/utils/storybook-ast/component-info.js +4 -2
- package/src/utils/mf/with-module-federation-ssr.js +53 -38
- package/src/utils/mf/with-module-federation.js +56 -41
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +2 -2
- package/src/executors/module-federation-dev-server/lib/parse-static-remotes-config.d.ts +0 -11
- package/src/executors/module-federation-dev-server/lib/parse-static-remotes-config.js +0 -17
- package/src/generators/utils/storybook-ast/tree-utilities.d.ts +0 -2
- package/src/generators/utils/storybook-ast/tree-utilities.js +0 -31
package/esm2022/mf/mf.mjs
CHANGED
|
@@ -2,10 +2,13 @@ let resolveRemoteUrl;
|
|
|
2
2
|
export function setRemoteUrlResolver(_resolveRemoteUrl) {
|
|
3
3
|
resolveRemoteUrl = _resolveRemoteUrl;
|
|
4
4
|
}
|
|
5
|
-
let remoteUrlDefinitions;
|
|
5
|
+
let remoteUrlDefinitions = {};
|
|
6
6
|
export function setRemoteDefinitions(definitions) {
|
|
7
7
|
remoteUrlDefinitions = definitions;
|
|
8
8
|
}
|
|
9
|
+
export function setRemoteDefinition(remoteName, remoteUrl) {
|
|
10
|
+
remoteUrlDefinitions[remoteName] = remoteUrl;
|
|
11
|
+
}
|
|
9
12
|
let remoteModuleMap = new Map();
|
|
10
13
|
let remoteContainerMap = new Map();
|
|
11
14
|
export async function loadRemoteModule(remoteName, moduleName) {
|
|
@@ -45,4 +48,4 @@ async function loadRemoteContainer(remoteName) {
|
|
|
45
48
|
remoteContainerMap.set(remoteName, container);
|
|
46
49
|
return container;
|
|
47
50
|
}
|
|
48
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
51
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWYuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9hbmd1bGFyL21mL21mLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQU9BLElBQUksZ0JBQTBDLENBQUM7QUFDL0MsTUFBTSxVQUFVLG9CQUFvQixDQUNsQyxpQkFBMkM7SUFFM0MsZ0JBQWdCLEdBQUcsaUJBQWlCLENBQUM7QUFDdkMsQ0FBQztBQUVELElBQUksb0JBQW9CLEdBQTJCLEVBQUUsQ0FBQztBQUN0RCxNQUFNLFVBQVUsb0JBQW9CLENBQUMsV0FBbUM7SUFDdEUsb0JBQW9CLEdBQUcsV0FBVyxDQUFDO0FBQ3JDLENBQUM7QUFFRCxNQUFNLFVBQVUsbUJBQW1CLENBQUMsVUFBa0IsRUFBRSxTQUFpQjtJQUN2RSxvQkFBb0IsQ0FBQyxVQUFVLENBQUMsR0FBRyxTQUFTLENBQUM7QUFDL0MsQ0FBQztBQUVELElBQUksZUFBZSxH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19
|
|
@@ -2,10 +2,13 @@ let resolveRemoteUrl;
|
|
|
2
2
|
function setRemoteUrlResolver(_resolveRemoteUrl) {
|
|
3
3
|
resolveRemoteUrl = _resolveRemoteUrl;
|
|
4
4
|
}
|
|
5
|
-
let remoteUrlDefinitions;
|
|
5
|
+
let remoteUrlDefinitions = {};
|
|
6
6
|
function setRemoteDefinitions(definitions) {
|
|
7
7
|
remoteUrlDefinitions = definitions;
|
|
8
8
|
}
|
|
9
|
+
function setRemoteDefinition(remoteName, remoteUrl) {
|
|
10
|
+
remoteUrlDefinitions[remoteName] = remoteUrl;
|
|
11
|
+
}
|
|
9
12
|
let remoteModuleMap = new Map();
|
|
10
13
|
let remoteContainerMap = new Map();
|
|
11
14
|
async function loadRemoteModule(remoteName, moduleName) {
|
|
@@ -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;\nexport function setRemoteUrlResolver(\n _resolveRemoteUrl: ResolveRemoteUrlFunction\n) {\n resolveRemoteUrl = _resolveRemoteUrl;\n}\n\nlet remoteUrlDefinitions: Record<string, string
|
|
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;\nexport function setRemoteUrlResolver(\n _resolveRemoteUrl: ResolveRemoteUrlFunction\n) {\n resolveRemoteUrl = _resolveRemoteUrl;\n}\n\nlet remoteUrlDefinitions: Record<string, string> = {};\nexport function setRemoteDefinitions(definitions: Record<string, string>) {\n remoteUrlDefinitions = definitions;\n}\n\nexport function setRemoteDefinition(remoteName: string, remoteUrl: string) {\n remoteUrlDefinitions[remoteName] = remoteUrl;\n}\n\nlet remoteModuleMap = new Map<string, unknown>();\nlet remoteContainerMap = new Map<string, unknown>();\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;\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;AACzC,SAAU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e,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;;AC5EA;;AAEG;;;;"}
|
package/mf/mf.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type ResolveRemoteUrlFunction = (remoteName: string) => string | Promise<string>;
|
|
2
2
|
export declare function setRemoteUrlResolver(_resolveRemoteUrl: ResolveRemoteUrlFunction): void;
|
|
3
3
|
export declare function setRemoteDefinitions(definitions: Record<string, string>): void;
|
|
4
|
+
export declare function setRemoteDefinition(remoteName: string, remoteUrl: string): void;
|
|
4
5
|
export declare function loadRemoteModule(remoteName: string, moduleName: string): Promise<any>;
|
package/migrations.json
CHANGED
|
@@ -2012,6 +2012,22 @@
|
|
|
2012
2012
|
"alwaysAddToPackageJson": false
|
|
2013
2013
|
}
|
|
2014
2014
|
}
|
|
2015
|
+
},
|
|
2016
|
+
"19.5.4-ngrx": {
|
|
2017
|
+
"version": "19.5.4-beta.0",
|
|
2018
|
+
"requires": {
|
|
2019
|
+
"@angular/core": "^18.0.0"
|
|
2020
|
+
},
|
|
2021
|
+
"packages": {
|
|
2022
|
+
"@ngrx/store": {
|
|
2023
|
+
"version": "^18.0.1",
|
|
2024
|
+
"alwaysAddToPackageJson": false
|
|
2025
|
+
},
|
|
2026
|
+
"@ngrx/operators": {
|
|
2027
|
+
"version": "^18.0.1",
|
|
2028
|
+
"alwaysAddToPackageJson": false
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2015
2031
|
}
|
|
2016
2032
|
}
|
|
2017
2033
|
}
|
package/ng-package.json
CHANGED
|
@@ -21,11 +21,15 @@
|
|
|
21
21
|
"ts-node",
|
|
22
22
|
"tsconfig-paths",
|
|
23
23
|
"semver",
|
|
24
|
+
"webpack",
|
|
25
|
+
"express",
|
|
26
|
+
"http-proxy-middleware",
|
|
24
27
|
"http-server",
|
|
25
28
|
"magic-string",
|
|
26
29
|
"enquirer",
|
|
27
30
|
"find-cache-dir",
|
|
28
|
-
"piscina"
|
|
31
|
+
"piscina",
|
|
32
|
+
"webpack"
|
|
29
33
|
],
|
|
30
34
|
"keepLifecycleScripts": true
|
|
31
35
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/angular",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-26482-1bdb7bd",
|
|
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": {
|
|
@@ -72,35 +72,29 @@
|
|
|
72
72
|
"@typescript-eslint/type-utils": "^7.16.0",
|
|
73
73
|
"chalk": "^4.1.0",
|
|
74
74
|
"find-cache-dir": "^3.3.2",
|
|
75
|
-
"ignore": "^5.0.4",
|
|
76
75
|
"magic-string": "~0.30.2",
|
|
77
76
|
"minimatch": "9.0.3",
|
|
78
77
|
"semver": "^7.5.3",
|
|
79
78
|
"tslib": "^2.3.0",
|
|
80
79
|
"webpack-merge": "^5.8.0",
|
|
80
|
+
"webpack": "^5.88.0",
|
|
81
81
|
"@module-federation/enhanced": "~0.2.3",
|
|
82
|
-
"@nx/devkit": "0.0.0-pr-
|
|
83
|
-
"@nx/js": "0.0.0-pr-
|
|
84
|
-
"@nx/eslint": "0.0.0-pr-
|
|
85
|
-
"@nx/webpack": "0.0.0-pr-
|
|
86
|
-
"@nx/web": "0.0.0-pr-
|
|
87
|
-
"@nx/workspace": "0.0.0-pr-
|
|
82
|
+
"@nx/devkit": "0.0.0-pr-26482-1bdb7bd",
|
|
83
|
+
"@nx/js": "0.0.0-pr-26482-1bdb7bd",
|
|
84
|
+
"@nx/eslint": "0.0.0-pr-26482-1bdb7bd",
|
|
85
|
+
"@nx/webpack": "0.0.0-pr-26482-1bdb7bd",
|
|
86
|
+
"@nx/web": "0.0.0-pr-26482-1bdb7bd",
|
|
87
|
+
"@nx/workspace": "0.0.0-pr-26482-1bdb7bd",
|
|
88
88
|
"piscina": "^4.4.0",
|
|
89
|
-
"@nrwl/angular": "0.0.0-pr-
|
|
89
|
+
"@nrwl/angular": "0.0.0-pr-26482-1bdb7bd"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"@angular-devkit/build-angular": ">= 16.0.0 < 19.0.0",
|
|
93
93
|
"@angular-devkit/core": ">= 16.0.0 < 19.0.0",
|
|
94
94
|
"@angular-devkit/schematics": ">= 16.0.0 < 19.0.0",
|
|
95
95
|
"@schematics/angular": ">= 16.0.0 < 19.0.0",
|
|
96
|
-
"esbuild": "^0.19.2",
|
|
97
96
|
"rxjs": "^6.5.3 || ^7.5.0"
|
|
98
97
|
},
|
|
99
|
-
"peerDependenciesMeta": {
|
|
100
|
-
"esbuild": {
|
|
101
|
-
"optional": true
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
98
|
"publishConfig": {
|
|
105
99
|
"access": "public"
|
|
106
100
|
},
|
|
@@ -36,6 +36,8 @@ function executeModuleFederationDevSSRBuilder(schema, context) {
|
|
|
36
36
|
: Array.isArray(options.devRemotes)
|
|
37
37
|
? options.devRemotes
|
|
38
38
|
: [options.devRemotes];
|
|
39
|
+
// Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
|
|
40
|
+
process.env.NX_MF_DEV_REMOTES = JSON.stringify(devServeRemotes);
|
|
39
41
|
(0, module_federation_1.validateDevRemotes)({ devRemotes: devServeRemotes }, workspaceProjects);
|
|
40
42
|
const remotesToSkip = new Set(options.skipRemotes ?? []);
|
|
41
43
|
const staticRemotes = (0, module_federation_1.getStaticRemotes)(project, context, workspaceProjects, remotesToSkip);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type Schema } from '../schema';
|
|
2
2
|
import { type ExecutorContext } from '@nx/devkit';
|
|
3
|
-
import type { StaticRemotesConfig } from '
|
|
4
|
-
export declare function buildStaticRemotes(staticRemotesConfig: StaticRemotesConfig, nxBin: any, context: ExecutorContext, options: Schema): Promise<
|
|
3
|
+
import type { StaticRemotesConfig } from '@nx/webpack/src/utils/module-federation/parse-static-remotes-config';
|
|
4
|
+
export declare function buildStaticRemotes(staticRemotesConfig: StaticRemotesConfig, nxBin: any, context: ExecutorContext, options: Schema): Promise<Record<string, string>>;
|
|
@@ -14,8 +14,7 @@ async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options)
|
|
|
14
14
|
for (const app of staticRemotesConfig.remotes) {
|
|
15
15
|
mappedLocationOfRemotes[app] = `http${options.ssl ? 's' : ''}://${options.host}:${options.staticRemotesPort}/${staticRemotesConfig.config[app].urlSegment}`;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
await new Promise((res) => {
|
|
17
|
+
await new Promise((res, rej) => {
|
|
19
18
|
devkit_1.logger.info(`NX Building ${staticRemotesConfig.remotes.length} static remotes...`);
|
|
20
19
|
const staticProcess = (0, node_child_process_1.fork)(nxBin, [
|
|
21
20
|
'run-many',
|
|
@@ -36,6 +35,11 @@ async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options)
|
|
|
36
35
|
const ANSII_CODE_REGEX = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
37
36
|
const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
|
|
38
37
|
stdoutStream.write(stdoutString);
|
|
38
|
+
// in addition to writing into the stdout stream, also show error directly in console
|
|
39
|
+
// so the error is easily discoverable. 'ERROR in' is the key word to search in webpack output.
|
|
40
|
+
if (stdoutString.includes('ERROR in')) {
|
|
41
|
+
devkit_1.logger.log(stdoutString);
|
|
42
|
+
}
|
|
39
43
|
if (stdoutString.includes('Successfully ran target build')) {
|
|
40
44
|
staticProcess.stdout.removeAllListeners('data');
|
|
41
45
|
devkit_1.logger.info(`NX Built ${staticRemotesConfig.remotes.length} static remotes`);
|
|
@@ -48,11 +52,14 @@ async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options)
|
|
|
48
52
|
staticProcess.stdout.removeAllListeners('data');
|
|
49
53
|
staticProcess.stderr.removeAllListeners('data');
|
|
50
54
|
if (code !== 0) {
|
|
51
|
-
|
|
55
|
+
rej(`Remote failed to start. A complete log can be found in: ${remoteBuildLogFile}`);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
res();
|
|
52
59
|
}
|
|
53
|
-
res();
|
|
54
60
|
});
|
|
55
61
|
process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
|
|
56
62
|
process.on('exit', () => staticProcess.kill('SIGTERM'));
|
|
57
63
|
});
|
|
64
|
+
return mappedLocationOfRemotes;
|
|
58
65
|
}
|
|
@@ -3,6 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./build-static-remotes"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./normalize-options"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./parse-static-remotes-config"), exports);
|
|
7
6
|
tslib_1.__exportStar(require("./start-dev-remotes"), exports);
|
|
8
7
|
tslib_1.__exportStar(require("./start-static-remotes-file-server"), exports);
|
package/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ExecutorContext } from '@nx/devkit';
|
|
2
2
|
import { type Schema } from '../schema';
|
|
3
|
-
import type { StaticRemotesConfig } from '
|
|
3
|
+
import type { StaticRemotesConfig } from '@nx/webpack/src/utils/module-federation/parse-static-remotes-config';
|
|
4
4
|
export declare function startStaticRemotesFileServer(staticRemotesConfig: StaticRemotesConfig, context: ExecutorContext, options: Schema): AsyncGenerator<{
|
|
5
5
|
success: boolean;
|
|
6
6
|
baseUrl: string;
|
|
@@ -7,6 +7,10 @@ const file_server_impl_1 = tslib_1.__importDefault(require("@nx/web/src/executor
|
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
9
|
function startStaticRemotesFileServer(staticRemotesConfig, context, options) {
|
|
10
|
+
if (!staticRemotesConfig.remotes ||
|
|
11
|
+
staticRemotesConfig.remotes.length === 0) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
10
14
|
let shouldMoveToCommonLocation = false;
|
|
11
15
|
let commonOutputDirectory;
|
|
12
16
|
for (const app of staticRemotesConfig.remotes) {
|
|
@@ -41,6 +45,7 @@ function startStaticRemotesFileServer(staticRemotesConfig, context, options) {
|
|
|
41
45
|
ssl: options.ssl,
|
|
42
46
|
sslCert: options.sslCert,
|
|
43
47
|
sslKey: options.sslKey,
|
|
48
|
+
cacheSeconds: -1,
|
|
44
49
|
}, context);
|
|
45
50
|
return staticRemotesIter;
|
|
46
51
|
}
|
|
@@ -14,11 +14,12 @@ const dev_server_impl_1 = require("../../builders/dev-server/dev-server.impl");
|
|
|
14
14
|
const module_federation_2 = require("../../builders/utilities/module-federation");
|
|
15
15
|
const path_1 = require("path");
|
|
16
16
|
const fs_1 = require("fs");
|
|
17
|
+
const start_remote_proxies_1 = require("@nx/webpack/src/utils/module-federation/start-remote-proxies");
|
|
18
|
+
const parse_static_remotes_config_1 = require("@nx/webpack/src/utils/module-federation/parse-static-remotes-config");
|
|
17
19
|
async function* moduleFederationDevServerExecutor(schema, context) {
|
|
18
20
|
// Force Node to resolve to look for the nx binary that is inside node_modules
|
|
19
21
|
const nxBin = require.resolve('nx/bin/nx');
|
|
20
22
|
const options = (0, lib_1.normalizeOptions)(schema);
|
|
21
|
-
options.staticRemotesPort ??= options.port + 1;
|
|
22
23
|
const { projects: workspaceProjects } = (0, devkit_1.readProjectsConfigurationFromProjectGraph)(context.projectGraph);
|
|
23
24
|
const project = workspaceProjects[context.projectName];
|
|
24
25
|
const currIter = options.static
|
|
@@ -31,6 +32,7 @@ async function* moduleFederationDevServerExecutor(schema, context) {
|
|
|
31
32
|
spa: false,
|
|
32
33
|
withDeps: false,
|
|
33
34
|
cors: true,
|
|
35
|
+
cacheSeconds: -1,
|
|
34
36
|
}, context)
|
|
35
37
|
: (0, rxjs_for_await_1.eachValueFrom)((0, dev_server_impl_1.executeDevServerBuilder)(options, await (0, ngcli_adapter_1.createBuilderContext)({
|
|
36
38
|
builderName: '@nx/angular:webpack-browser',
|
|
@@ -62,31 +64,19 @@ async function* moduleFederationDevServerExecutor(schema, context) {
|
|
|
62
64
|
projectGraph: context.projectGraph,
|
|
63
65
|
root: context.root,
|
|
64
66
|
}, pathToManifestFile);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (remotePort >= portToUse) {
|
|
71
|
-
return remotePort + 1;
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
return portToUse;
|
|
75
|
-
}
|
|
76
|
-
}, options.staticRemotesPort);
|
|
77
|
-
}
|
|
78
|
-
const staticRemotesConfig = (0, lib_1.parseStaticRemotesConfig)(remotes.staticRemotes, context);
|
|
79
|
-
await (0, lib_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options);
|
|
67
|
+
options.staticRemotesPort ??= remotes.staticRemotePort;
|
|
68
|
+
// Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
|
|
69
|
+
process.env.NX_MF_DEV_REMOTES = JSON.stringify(remotes.devRemotes.map((r) => (typeof r === 'string' ? r : r.remoteName)));
|
|
70
|
+
const staticRemotesConfig = (0, parse_static_remotes_config_1.parseStaticRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
|
|
71
|
+
const mappedLocationsOfStaticRemotes = await (0, lib_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options);
|
|
80
72
|
const devRemoteIters = await (0, lib_1.startRemotes)(remotes.devRemotes, workspaceProjects, options, context, 'serve');
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
? (0, lib_1.startStaticRemotesFileServer)(staticRemotesConfig, context, options)
|
|
84
|
-
: undefined;
|
|
73
|
+
const staticRemotesIter = (0, lib_1.startStaticRemotesFileServer)(staticRemotesConfig, context, options);
|
|
74
|
+
(0, start_remote_proxies_1.startRemoteProxies)(staticRemotesConfig, mappedLocationsOfStaticRemotes);
|
|
85
75
|
const removeBaseUrlEmission = (iter) => (0, async_iterable_1.mapAsyncIterable)(iter, (v) => ({
|
|
86
76
|
...v,
|
|
87
77
|
baseUrl: undefined,
|
|
88
78
|
}));
|
|
89
|
-
return yield* (0, async_iterable_1.combineAsyncIterables)(removeBaseUrlEmission(currIter), ...devRemoteIters.map(removeBaseUrlEmission), ...
|
|
79
|
+
return yield* (0, async_iterable_1.combineAsyncIterables)(removeBaseUrlEmission(currIter), ...devRemoteIters.map(removeBaseUrlEmission), ...(staticRemotesIter ? [removeBaseUrlEmission(staticRemotesIter)] : []), (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
|
|
90
80
|
if (!options.isInitialHost) {
|
|
91
81
|
done();
|
|
92
82
|
return;
|
|
@@ -23,13 +23,15 @@ export function app(): express.Express {
|
|
|
23
23
|
// Example Express Rest API endpoints
|
|
24
24
|
// server.get('/api/**', (req, res) => { });
|
|
25
25
|
// Serve static files from /browser
|
|
26
|
-
server.get(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
server.get(
|
|
27
|
+
'*.*',
|
|
28
|
+
express.static(distFolder, {
|
|
29
|
+
maxAge: '1y',
|
|
30
|
+
})
|
|
31
|
+
);
|
|
30
32
|
|
|
31
33
|
// All regular routes use the Angular engine
|
|
32
|
-
server.get('
|
|
34
|
+
server.get('*', (req, res, next) => {
|
|
33
35
|
const { protocol, originalUrl, baseUrl, headers } = req;
|
|
34
36
|
|
|
35
37
|
commonEngine
|
|
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
function addMfEnvToTargetDefaultInputs(tree) {
|
|
6
6
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
7
7
|
const webpackExecutor = '@nx/angular:webpack-browser';
|
|
8
|
-
const mfEnvVar = '
|
|
8
|
+
const mfEnvVar = 'NX_MF_DEV_REMOTES';
|
|
9
9
|
nxJson.targetDefaults ??= {};
|
|
10
10
|
nxJson.targetDefaults[webpackExecutor] ??= {};
|
|
11
11
|
nxJson.targetDefaults[webpackExecutor].inputs ??= [
|
|
@@ -7,7 +7,6 @@ const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescri
|
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const ast_utils_1 = require("../../../utils/nx-devkit/ast-utils");
|
|
9
9
|
const module_info_1 = require("./module-info");
|
|
10
|
-
const tree_utilities_1 = require("./tree-utilities");
|
|
11
10
|
let tsModule;
|
|
12
11
|
let tsquery;
|
|
13
12
|
function getComponentsInfo(tree, entryPoint, moduleFilePaths, projectName) {
|
|
@@ -133,7 +132,10 @@ function getComponentInfo(tree, entryPoint, sourceFile, imports, moduleFilePath,
|
|
|
133
132
|
function getComponentInfoFromDir(tree, entryPoint, dir, componentName, moduleFolderPath) {
|
|
134
133
|
let path = null;
|
|
135
134
|
let componentFileName = null;
|
|
136
|
-
const componentImportPathChildren =
|
|
135
|
+
const componentImportPathChildren = [];
|
|
136
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, dir, (filePath) => {
|
|
137
|
+
componentImportPathChildren.push(filePath);
|
|
138
|
+
});
|
|
137
139
|
for (const candidateFile of componentImportPathChildren) {
|
|
138
140
|
if (candidateFile.endsWith('.ts')) {
|
|
139
141
|
const content = tree.read(candidateFile, 'utf-8');
|
|
@@ -9,44 +9,59 @@ async function withModuleFederationForSSR(options, configOverride) {
|
|
|
9
9
|
const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_1.getModuleFederationConfig)(options, {
|
|
10
10
|
isServer: true,
|
|
11
11
|
});
|
|
12
|
-
return (config) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
optimization: {
|
|
20
|
-
...(config.optimization ?? {}),
|
|
21
|
-
runtimeChunk: false,
|
|
22
|
-
},
|
|
23
|
-
resolve: {
|
|
24
|
-
...(config.resolve ?? {}),
|
|
25
|
-
alias: {
|
|
26
|
-
...(config.resolve?.alias ?? {}),
|
|
27
|
-
...sharedLibraries.getAliases(),
|
|
12
|
+
return (config) => {
|
|
13
|
+
const updatedConfig = {
|
|
14
|
+
...(config ?? {}),
|
|
15
|
+
target: false,
|
|
16
|
+
output: {
|
|
17
|
+
...(config.output ?? {}),
|
|
18
|
+
uniqueName: options.name,
|
|
28
19
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
...sharedDependencies,
|
|
39
|
-
},
|
|
40
|
-
library: {
|
|
41
|
-
type: 'commonjs-module',
|
|
20
|
+
optimization: {
|
|
21
|
+
...(config.optimization ?? {}),
|
|
22
|
+
runtimeChunk: false,
|
|
23
|
+
},
|
|
24
|
+
resolve: {
|
|
25
|
+
...(config.resolve ?? {}),
|
|
26
|
+
alias: {
|
|
27
|
+
...(config.resolve?.alias ?? {}),
|
|
28
|
+
...sharedLibraries.getAliases(),
|
|
42
29
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
30
|
+
},
|
|
31
|
+
plugins: [
|
|
32
|
+
...(config.plugins ?? []),
|
|
33
|
+
new (require('@module-federation/node').UniversalFederationPlugin)({
|
|
34
|
+
name: options.name,
|
|
35
|
+
filename: 'remoteEntry.js',
|
|
36
|
+
exposes: options.exposes,
|
|
37
|
+
remotes: mappedRemotes,
|
|
38
|
+
shared: {
|
|
39
|
+
...sharedDependencies,
|
|
40
|
+
},
|
|
41
|
+
library: {
|
|
42
|
+
type: 'commonjs-module',
|
|
43
|
+
},
|
|
44
|
+
isServer: true,
|
|
45
|
+
/**
|
|
46
|
+
* Apply user-defined config override
|
|
47
|
+
*/
|
|
48
|
+
...(configOverride ? configOverride : {}),
|
|
49
|
+
runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
|
|
50
|
+
!options.disableNxRuntimeLibraryControlPlugin
|
|
51
|
+
? [
|
|
52
|
+
...(configOverride?.runtimePlugins ?? []),
|
|
53
|
+
require.resolve('@nx/webpack/src/utils/module-federation/plugins/runtime-library-control.plugin.js'),
|
|
54
|
+
]
|
|
55
|
+
: configOverride?.runtimePlugins,
|
|
56
|
+
}, {}),
|
|
57
|
+
sharedLibraries.getReplacementPlugin(),
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
// The env var is only set from the module-federation-dev-server
|
|
61
|
+
// Attach the runtime plugin
|
|
62
|
+
updatedConfig.plugins.push(new (require('webpack').DefinePlugin)({
|
|
63
|
+
'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
|
|
64
|
+
}));
|
|
65
|
+
return updatedConfig;
|
|
66
|
+
};
|
|
52
67
|
}
|
|
@@ -8,47 +8,62 @@ async function withModuleFederation(options, configOverride) {
|
|
|
8
8
|
return (config) => config;
|
|
9
9
|
}
|
|
10
10
|
const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_1.getModuleFederationConfig)(options);
|
|
11
|
-
return (config) =>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
optimization: {
|
|
19
|
-
...(config.optimization ?? {}),
|
|
20
|
-
runtimeChunk: false,
|
|
21
|
-
},
|
|
22
|
-
resolve: {
|
|
23
|
-
...(config.resolve ?? {}),
|
|
24
|
-
alias: {
|
|
25
|
-
...(config.resolve?.alias ?? {}),
|
|
26
|
-
...sharedLibraries.getAliases(),
|
|
11
|
+
return (config) => {
|
|
12
|
+
const updatedConfig = {
|
|
13
|
+
...(config ?? {}),
|
|
14
|
+
output: {
|
|
15
|
+
...(config.output ?? {}),
|
|
16
|
+
uniqueName: options.name,
|
|
17
|
+
publicPath: 'auto',
|
|
27
18
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
filename: 'remoteEntry.mjs',
|
|
38
|
-
exposes: options.exposes,
|
|
39
|
-
remotes: mappedRemotes,
|
|
40
|
-
shared: {
|
|
41
|
-
...sharedDependencies,
|
|
42
|
-
},
|
|
43
|
-
library: {
|
|
44
|
-
type: 'module',
|
|
19
|
+
optimization: {
|
|
20
|
+
...(config.optimization ?? {}),
|
|
21
|
+
runtimeChunk: false,
|
|
22
|
+
},
|
|
23
|
+
resolve: {
|
|
24
|
+
...(config.resolve ?? {}),
|
|
25
|
+
alias: {
|
|
26
|
+
...(config.resolve?.alias ?? {}),
|
|
27
|
+
...sharedLibraries.getAliases(),
|
|
45
28
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
29
|
+
},
|
|
30
|
+
experiments: {
|
|
31
|
+
...(config.experiments ?? {}),
|
|
32
|
+
outputModule: true,
|
|
33
|
+
},
|
|
34
|
+
plugins: [
|
|
35
|
+
...(config.plugins ?? []),
|
|
36
|
+
new webpack_1.ModuleFederationPlugin({
|
|
37
|
+
name: options.name,
|
|
38
|
+
filename: 'remoteEntry.mjs',
|
|
39
|
+
exposes: options.exposes,
|
|
40
|
+
remotes: mappedRemotes,
|
|
41
|
+
shared: {
|
|
42
|
+
...sharedDependencies,
|
|
43
|
+
},
|
|
44
|
+
library: {
|
|
45
|
+
type: 'module',
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Apply user-defined config override
|
|
49
|
+
*/
|
|
50
|
+
...(configOverride ? configOverride : {}),
|
|
51
|
+
runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
|
|
52
|
+
!options.disableNxRuntimeLibraryControlPlugin
|
|
53
|
+
? [
|
|
54
|
+
...(configOverride?.runtimePlugins ?? []),
|
|
55
|
+
require.resolve('@nx/webpack/src/utils/module-federation/plugins/runtime-library-control.plugin.js'),
|
|
56
|
+
]
|
|
57
|
+
: configOverride?.runtimePlugins,
|
|
58
|
+
}),
|
|
59
|
+
sharedLibraries.getReplacementPlugin(),
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
// The env var is only set from the module-federation-dev-server
|
|
63
|
+
// Attach the runtime plugin
|
|
64
|
+
updatedConfig.plugins.push(new (require('webpack').DefinePlugin)({
|
|
65
|
+
'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
|
|
66
|
+
}));
|
|
67
|
+
return updatedConfig;
|
|
68
|
+
};
|
|
54
69
|
}
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export declare const nxVersion: any;
|
|
|
2
2
|
export declare const angularVersion = "~18.1.0";
|
|
3
3
|
export declare const angularDevkitVersion = "~18.1.0";
|
|
4
4
|
export declare const ngPackagrVersion = "~18.1.0";
|
|
5
|
-
export declare const ngrxVersion = "^18.0.
|
|
5
|
+
export declare const ngrxVersion = "^18.0.1";
|
|
6
6
|
export declare const rxjsVersion = "~7.8.0";
|
|
7
7
|
export declare const zoneJsVersion = "~0.14.3";
|
|
8
8
|
export declare const angularJsVersion = "1.7.9";
|
|
@@ -12,7 +12,7 @@ export declare const typesCorsVersion = "~2.8.5";
|
|
|
12
12
|
export declare const expressVersion = "~4.18.2";
|
|
13
13
|
export declare const typesExpressVersion = "4.17.14";
|
|
14
14
|
export declare const browserSyncVersion = "^3.0.0";
|
|
15
|
-
export declare const moduleFederationNodeVersion = "
|
|
15
|
+
export declare const moduleFederationNodeVersion = "~2.4.0";
|
|
16
16
|
export declare const moduleFederationEnhancedVersion = "~0.2.3";
|
|
17
17
|
export declare const angularEslintVersion = "^18.0.1";
|
|
18
18
|
export declare const typescriptEslintVersion = "^7.16.0";
|
package/src/utils/versions.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.nxVersion = require('../../package.json').version;
|
|
|
5
5
|
exports.angularVersion = '~18.1.0';
|
|
6
6
|
exports.angularDevkitVersion = '~18.1.0';
|
|
7
7
|
exports.ngPackagrVersion = '~18.1.0';
|
|
8
|
-
exports.ngrxVersion = '^18.0.
|
|
8
|
+
exports.ngrxVersion = '^18.0.1';
|
|
9
9
|
exports.rxjsVersion = '~7.8.0';
|
|
10
10
|
exports.zoneJsVersion = '~0.14.3';
|
|
11
11
|
exports.angularJsVersion = '1.7.9';
|
|
@@ -15,7 +15,7 @@ exports.typesCorsVersion = '~2.8.5';
|
|
|
15
15
|
exports.expressVersion = '~4.18.2';
|
|
16
16
|
exports.typesExpressVersion = '4.17.14';
|
|
17
17
|
exports.browserSyncVersion = '^3.0.0';
|
|
18
|
-
exports.moduleFederationNodeVersion = '
|
|
18
|
+
exports.moduleFederationNodeVersion = '~2.4.0';
|
|
19
19
|
exports.moduleFederationEnhancedVersion = '~0.2.3';
|
|
20
20
|
exports.angularEslintVersion = '^18.0.1';
|
|
21
21
|
exports.typescriptEslintVersion = '^7.16.0';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
export type StaticRemoteConfig = {
|
|
3
|
-
basePath: string;
|
|
4
|
-
outputPath: string;
|
|
5
|
-
urlSegment: string;
|
|
6
|
-
};
|
|
7
|
-
export type StaticRemotesConfig = {
|
|
8
|
-
remotes: string[];
|
|
9
|
-
config: Record<string, StaticRemoteConfig> | undefined;
|
|
10
|
-
};
|
|
11
|
-
export declare function parseStaticRemotesConfig(staticRemotes: string[] | undefined, context: ExecutorContext): StaticRemotesConfig;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseStaticRemotesConfig = parseStaticRemotesConfig;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
function parseStaticRemotesConfig(staticRemotes, context) {
|
|
6
|
-
if (!staticRemotes?.length) {
|
|
7
|
-
return { remotes: [], config: undefined };
|
|
8
|
-
}
|
|
9
|
-
const config = {};
|
|
10
|
-
for (const app of staticRemotes) {
|
|
11
|
-
const outputPath = context.projectGraph.nodes[app].data.targets['build'].options.outputPath;
|
|
12
|
-
const basePath = (0, path_1.dirname)(outputPath);
|
|
13
|
-
const urlSegment = (0, path_1.basename)(outputPath);
|
|
14
|
-
config[app] = { basePath, outputPath, urlSegment };
|
|
15
|
-
}
|
|
16
|
-
return { remotes: staticRemotes, config };
|
|
17
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAllFilesRecursivelyFromDir = getAllFilesRecursivelyFromDir;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const ignore_1 = tslib_1.__importDefault(require("ignore"));
|
|
7
|
-
function getAllFilesRecursivelyFromDir(tree, dir) {
|
|
8
|
-
if (isPathIgnored(tree, dir)) {
|
|
9
|
-
return [];
|
|
10
|
-
}
|
|
11
|
-
const files = [];
|
|
12
|
-
const children = tree.children(dir);
|
|
13
|
-
children.forEach((child) => {
|
|
14
|
-
const childPath = (0, devkit_1.joinPathFragments)(dir, child);
|
|
15
|
-
if (tree.isFile(childPath)) {
|
|
16
|
-
files.push(childPath);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
files.push(...getAllFilesRecursivelyFromDir(tree, childPath));
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
return files;
|
|
23
|
-
}
|
|
24
|
-
function isPathIgnored(tree, path) {
|
|
25
|
-
let ig;
|
|
26
|
-
if (tree.exists('.gitignore')) {
|
|
27
|
-
ig = (0, ignore_1.default)();
|
|
28
|
-
ig.add(tree.read('.gitignore', 'utf-8'));
|
|
29
|
-
}
|
|
30
|
-
return path !== '' && ig?.ignores(path);
|
|
31
|
-
}
|