@nx/webpack 19.5.1 → 19.5.2
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/package.json +6 -4
- package/src/utils/module-federation/get-remotes-for-host.d.ts +1 -0
- package/src/utils/module-federation/get-remotes-for-host.js +6 -1
- package/src/utils/module-federation/parse-static-remotes-config.d.ts +12 -0
- package/src/utils/module-federation/parse-static-remotes-config.js +18 -0
- package/src/utils/module-federation/start-remote-proxies.d.ts +2 -0
- package/src/utils/module-federation/start-remote-proxies.js +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/webpack",
|
|
3
|
-
"version": "19.5.
|
|
3
|
+
"version": "19.5.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Webpack contains executors and generators that support building applications using Webpack.",
|
|
6
6
|
"repository": {
|
|
@@ -42,7 +42,9 @@
|
|
|
42
42
|
"copy-webpack-plugin": "^10.2.4",
|
|
43
43
|
"css-loader": "^6.4.0",
|
|
44
44
|
"css-minimizer-webpack-plugin": "^5.0.0",
|
|
45
|
+
"express": "^4.19.2",
|
|
45
46
|
"fork-ts-checker-webpack-plugin": "7.2.13",
|
|
47
|
+
"http-proxy-middleware": "^3.0.0",
|
|
46
48
|
"less": "4.1.3",
|
|
47
49
|
"less-loader": "11.1.0",
|
|
48
50
|
"license-webpack-plugin": "^4.0.2",
|
|
@@ -67,9 +69,9 @@
|
|
|
67
69
|
"webpack-dev-server": "^4.9.3",
|
|
68
70
|
"webpack-node-externals": "^3.0.0",
|
|
69
71
|
"webpack-subresource-integrity": "^5.1.0",
|
|
70
|
-
"@nx/devkit": "19.5.
|
|
71
|
-
"@nx/js": "19.5.
|
|
72
|
-
"@nrwl/webpack": "19.5.
|
|
72
|
+
"@nx/devkit": "19.5.2",
|
|
73
|
+
"@nx/js": "19.5.2",
|
|
74
|
+
"@nrwl/webpack": "19.5.2"
|
|
73
75
|
},
|
|
74
76
|
"publishConfig": {
|
|
75
77
|
"access": "public"
|
|
@@ -10,6 +10,7 @@ export declare function getRemotes(devRemotes: string[], skipRemotes: string[],
|
|
|
10
10
|
devRemotes: any[];
|
|
11
11
|
dynamicRemotes: any[];
|
|
12
12
|
remotePorts: any[];
|
|
13
|
+
staticRemotePort: number;
|
|
13
14
|
};
|
|
14
15
|
export declare function getModuleFederationConfig(tsconfigPath: string, workspaceRoot: string, projectRoot: string, pluginName?: 'react' | 'angular'): any;
|
|
15
16
|
export {};
|
|
@@ -57,14 +57,19 @@ function getRemotes(devRemotes, skipRemotes, config, context, pathToManifestFile
|
|
|
57
57
|
? (0, find_matching_projects_1.findMatchingProjects)(devRemotes, context.projectGraph.nodes)
|
|
58
58
|
: (0, find_matching_projects_1.findMatchingProjects)([devRemotes], context.projectGraph.nodes));
|
|
59
59
|
const staticRemotes = knownRemotes.filter((r) => !devServeApps.has(r));
|
|
60
|
-
const devServeRemotes = [...knownRemotes, ...
|
|
60
|
+
const devServeRemotes = [...knownRemotes, ...knownDynamicRemotes].filter((r) => devServeApps.has(r));
|
|
61
61
|
const staticDynamicRemotes = knownDynamicRemotes.filter((r) => !devServeApps.has(r));
|
|
62
62
|
const remotePorts = [...devServeRemotes, ...staticDynamicRemotes].map((r) => context.projectGraph.nodes[r].data.targets['serve'].options.port);
|
|
63
|
+
const staticRemotePort = Math.max(...[
|
|
64
|
+
...remotePorts,
|
|
65
|
+
...staticRemotes.map((r) => context.projectGraph.nodes[r].data.targets['serve'].options.port),
|
|
66
|
+
]) + 1;
|
|
63
67
|
return {
|
|
64
68
|
staticRemotes,
|
|
65
69
|
devRemotes: devServeRemotes,
|
|
66
70
|
dynamicRemotes: staticDynamicRemotes,
|
|
67
71
|
remotePorts,
|
|
72
|
+
staticRemotePort,
|
|
68
73
|
};
|
|
69
74
|
}
|
|
70
75
|
function getModuleFederationConfig(tsconfigPath, workspaceRoot, projectRoot, pluginName = 'react') {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
export type StaticRemoteConfig = {
|
|
3
|
+
basePath: string;
|
|
4
|
+
outputPath: string;
|
|
5
|
+
urlSegment: string;
|
|
6
|
+
port: number;
|
|
7
|
+
};
|
|
8
|
+
export type StaticRemotesConfig = {
|
|
9
|
+
remotes: string[];
|
|
10
|
+
config: Record<string, StaticRemoteConfig> | undefined;
|
|
11
|
+
};
|
|
12
|
+
export declare function parseStaticRemotesConfig(staticRemotes: string[] | undefined, context: ExecutorContext): StaticRemotesConfig;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
const port = context.projectGraph.nodes[app].data.targets['serve'].options.port;
|
|
15
|
+
config[app] = { basePath, outputPath, urlSegment, port };
|
|
16
|
+
}
|
|
17
|
+
return { remotes: staticRemotes, config };
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startRemoteProxies = startRemoteProxies;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function startRemoteProxies(staticRemotesConfig, mappedLocationsOfRemotes) {
|
|
6
|
+
const { createProxyMiddleware } = require('http-proxy-middleware');
|
|
7
|
+
const express = require('express');
|
|
8
|
+
devkit_1.logger.info(`NX Starting static remotes proxies...`);
|
|
9
|
+
for (const app of staticRemotesConfig.remotes) {
|
|
10
|
+
const expressProxy = express();
|
|
11
|
+
expressProxy.use(createProxyMiddleware({
|
|
12
|
+
target: mappedLocationsOfRemotes[app],
|
|
13
|
+
changeOrigin: true,
|
|
14
|
+
}));
|
|
15
|
+
const proxyServer = expressProxy.listen(staticRemotesConfig.config[app].port);
|
|
16
|
+
process.on('SIGTERM', () => proxyServer.close());
|
|
17
|
+
process.on('exit', () => proxyServer.close());
|
|
18
|
+
}
|
|
19
|
+
devkit_1.logger.info(`NX Static remotes proxies started successfully`);
|
|
20
|
+
}
|