@nx/webpack 18.2.2 → 18.2.3
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 +4 -4
- package/src/executors/dev-server/dev-server.impl.js +5 -0
- package/src/utils/ensure-dependencies.js +0 -1
- package/src/utils/module-federation/get-remotes-for-host.d.ts +2 -1
- package/src/utils/module-federation/get-remotes-for-host.js +11 -7
- package/src/utils/versions.d.ts +0 -1
- package/src/utils/versions.js +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/webpack",
|
|
3
|
-
"version": "18.2.
|
|
3
|
+
"version": "18.2.3",
|
|
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": {
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"webpack-dev-server": "^4.9.3",
|
|
64
64
|
"webpack-node-externals": "^3.0.0",
|
|
65
65
|
"webpack-subresource-integrity": "^5.1.0",
|
|
66
|
-
"@nx/devkit": "18.2.
|
|
67
|
-
"@nx/js": "18.2.
|
|
68
|
-
"@nrwl/webpack": "18.2.
|
|
66
|
+
"@nx/devkit": "18.2.3",
|
|
67
|
+
"@nx/js": "18.2.3",
|
|
68
|
+
"@nrwl/webpack": "18.2.3"
|
|
69
69
|
},
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
@@ -48,6 +48,11 @@ async function* devServerExecutor(serveOptions, context) {
|
|
|
48
48
|
configuration: serveOptions.buildTarget.split(':')[2],
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
+
else if (userDefinedWebpackConfig) {
|
|
52
|
+
// New behavior, we want the webpack config to export object
|
|
53
|
+
config = userDefinedWebpackConfig;
|
|
54
|
+
config.devServer ??= devServer;
|
|
55
|
+
}
|
|
51
56
|
}
|
|
52
57
|
return yield* (0, rxjs_for_await_1.eachValueFrom)((0, run_webpack_1.runWebpackDevServer)(config, webpack, WebpackDevServer).pipe((0, operators_1.tap)(({ stats }) => {
|
|
53
58
|
console.info(stats.toString(config.stats));
|
|
@@ -20,7 +20,6 @@ function ensureDependencies(tree, options) {
|
|
|
20
20
|
versions_1.reactRefreshWebpackPluginVersion;
|
|
21
21
|
devDependencies['@svgr/webpack'] = versions_1.svgrWebpackVersion;
|
|
22
22
|
devDependencies['react-refresh'] = versions_1.reactRefreshVersion;
|
|
23
|
-
devDependencies['url-loader'] = versions_1.urlLoaderVersion;
|
|
24
23
|
}
|
|
25
24
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies));
|
|
26
25
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
@@ -7,7 +7,8 @@ interface ModuleFederationExecutorContext {
|
|
|
7
7
|
}
|
|
8
8
|
export declare function getRemotes(devRemotes: string[], skipRemotes: string[], config: ModuleFederationConfig, context: ModuleFederationExecutorContext, pathToManifestFile?: string): {
|
|
9
9
|
staticRemotes: string[];
|
|
10
|
-
devRemotes:
|
|
10
|
+
devRemotes: any[];
|
|
11
|
+
dynamicRemotes: any[];
|
|
11
12
|
remotePorts: any[];
|
|
12
13
|
};
|
|
13
14
|
export declare function getModuleFederationConfig(tsconfigPath: string, workspaceRoot: string, projectRoot: string, pluginName?: 'react' | 'angular'): any;
|
|
@@ -9,6 +9,7 @@ const path_1 = require("path");
|
|
|
9
9
|
const fs_1 = require("fs");
|
|
10
10
|
function extractRemoteProjectsFromConfig(config, pathToManifestFile) {
|
|
11
11
|
const remotes = [];
|
|
12
|
+
const dynamicRemotes = [];
|
|
12
13
|
if (pathToManifestFile && (0, fs_1.existsSync)(pathToManifestFile)) {
|
|
13
14
|
const moduleFederationManifestJson = (0, fs_1.readFileSync)(pathToManifestFile, 'utf-8');
|
|
14
15
|
if (moduleFederationManifestJson) {
|
|
@@ -18,13 +19,13 @@ function extractRemoteProjectsFromConfig(config, pathToManifestFile) {
|
|
|
18
19
|
// }
|
|
19
20
|
const parsedManifest = JSON.parse(moduleFederationManifestJson);
|
|
20
21
|
if (Object.keys(parsedManifest).every((key) => typeof key === 'string' && typeof parsedManifest[key] === 'string')) {
|
|
21
|
-
|
|
22
|
+
dynamicRemotes.push(...Object.keys(parsedManifest));
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
const staticRemotes = config.remotes?.map((r) => (Array.isArray(r) ? r[0] : r)) ?? [];
|
|
26
27
|
remotes.push(...staticRemotes);
|
|
27
|
-
return remotes;
|
|
28
|
+
return { remotes, dynamicRemotes };
|
|
28
29
|
}
|
|
29
30
|
function collectRemoteProjects(remote, collected, context) {
|
|
30
31
|
const remoteProject = context.projectGraph.nodes[remote]?.data;
|
|
@@ -35,30 +36,33 @@ function collectRemoteProjects(remote, collected, context) {
|
|
|
35
36
|
const remoteProjectRoot = remoteProject.root;
|
|
36
37
|
const remoteProjectTsConfig = remoteProject.targets['build'].options.tsConfig;
|
|
37
38
|
const remoteProjectConfig = getModuleFederationConfig(remoteProjectTsConfig, context.root, remoteProjectRoot);
|
|
38
|
-
const remoteProjectRemotes = extractRemoteProjectsFromConfig(remoteProjectConfig);
|
|
39
|
+
const { remotes: remoteProjectRemotes } = extractRemoteProjectsFromConfig(remoteProjectConfig);
|
|
39
40
|
remoteProjectRemotes.forEach((r) => collectRemoteProjects(r, collected, context));
|
|
40
41
|
}
|
|
41
42
|
function getRemotes(devRemotes, skipRemotes, config, context, pathToManifestFile) {
|
|
42
43
|
const collectedRemotes = new Set();
|
|
43
|
-
const remotes = extractRemoteProjectsFromConfig(config, pathToManifestFile);
|
|
44
|
+
const { remotes, dynamicRemotes } = extractRemoteProjectsFromConfig(config, pathToManifestFile);
|
|
44
45
|
remotes.forEach((r) => collectRemoteProjects(r, collectedRemotes, context));
|
|
45
46
|
const remotesToSkip = new Set((0, find_matching_projects_1.findMatchingProjects)(skipRemotes, context.projectGraph.nodes) ?? []);
|
|
46
47
|
if (remotesToSkip.size > 0) {
|
|
47
48
|
devkit_1.logger.info(`Remotes not served automatically: ${[...remotesToSkip.values()].join(', ')}`);
|
|
48
49
|
}
|
|
49
50
|
const knownRemotes = Array.from(collectedRemotes).filter((r) => !remotesToSkip.has(r));
|
|
50
|
-
|
|
51
|
+
const knownDynamicRemotes = dynamicRemotes.filter((r) => !remotesToSkip.has(r));
|
|
52
|
+
devkit_1.logger.info(`NX Starting module federation dev-server for ${chalk.bold(context.projectName)} with ${[...knownRemotes, ...knownDynamicRemotes].length} remotes`);
|
|
51
53
|
const devServeApps = new Set(!devRemotes
|
|
52
54
|
? []
|
|
53
55
|
: Array.isArray(devRemotes)
|
|
54
56
|
? (0, find_matching_projects_1.findMatchingProjects)(devRemotes, context.projectGraph.nodes)
|
|
55
57
|
: (0, find_matching_projects_1.findMatchingProjects)([devRemotes], context.projectGraph.nodes));
|
|
56
58
|
const staticRemotes = knownRemotes.filter((r) => !devServeApps.has(r));
|
|
57
|
-
const devServeRemotes = knownRemotes.filter((r) => devServeApps.has(r));
|
|
58
|
-
const
|
|
59
|
+
const devServeRemotes = [...knownRemotes, ...dynamicRemotes].filter((r) => devServeApps.has(r));
|
|
60
|
+
const staticDynamicRemotes = knownDynamicRemotes.filter((r) => !devServeApps.has(r));
|
|
61
|
+
const remotePorts = [...devServeRemotes, ...staticDynamicRemotes].map((r) => context.projectGraph.nodes[r].data.targets['serve'].options.port);
|
|
59
62
|
return {
|
|
60
63
|
staticRemotes,
|
|
61
64
|
devRemotes: devServeRemotes,
|
|
65
|
+
dynamicRemotes: staticDynamicRemotes,
|
|
62
66
|
remotePorts,
|
|
63
67
|
};
|
|
64
68
|
}
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -5,4 +5,3 @@ export declare const webpackCliVersion = "^5.1.4";
|
|
|
5
5
|
export declare const reactRefreshWebpackPluginVersion = "^0.5.7";
|
|
6
6
|
export declare const svgrWebpackVersion = "^8.0.1";
|
|
7
7
|
export declare const reactRefreshVersion = "^0.10.0";
|
|
8
|
-
export declare const urlLoaderVersion = "^4.1.1";
|
package/src/utils/versions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.reactRefreshVersion = exports.svgrWebpackVersion = exports.reactRefreshWebpackPluginVersion = exports.webpackCliVersion = exports.tsLibVersion = exports.swcLoaderVersion = exports.nxVersion = void 0;
|
|
4
4
|
exports.nxVersion = require('../../package.json').version;
|
|
5
5
|
exports.swcLoaderVersion = '0.1.15';
|
|
6
6
|
exports.tsLibVersion = '^2.3.0';
|
|
@@ -9,4 +9,3 @@ exports.webpackCliVersion = '^5.1.4';
|
|
|
9
9
|
exports.reactRefreshWebpackPluginVersion = '^0.5.7';
|
|
10
10
|
exports.svgrWebpackVersion = '^8.0.1';
|
|
11
11
|
exports.reactRefreshVersion = '^0.10.0';
|
|
12
|
-
exports.urlLoaderVersion = '^4.1.1';
|