@nx/rspack 20.2.0-beta.1 → 20.2.0-beta.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/app-plugin.d.ts +2 -0
- package/app-plugin.js +5 -0
- package/generators.json +10 -0
- package/migrations.json +21 -1
- package/module-federation.d.ts +4 -1
- package/module-federation.js +7 -2
- package/package.json +10 -8
- package/react-plugin.d.ts +1 -0
- package/react-plugin.js +5 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +5 -7
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +5 -7
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts +1 -1
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.js +4 -5
- package/src/executors/rspack/lib/config.d.ts +6 -0
- package/src/executors/rspack/lib/config.js +39 -0
- package/src/executors/rspack/rspack.impl.js +11 -12
- package/src/executors/rspack/schema.d.ts +39 -18
- package/src/executors/rspack/schema.json +191 -0
- package/src/generators/convert-config-to-rspack-plugin/convert-config-to-rspack-plugin.d.ts +7 -0
- package/src/generators/convert-config-to-rspack-plugin/convert-config-to-rspack-plugin.js +92 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/extract-rspack-options.d.ts +6 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/extract-rspack-options.js +106 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/normalize-path-options.d.ts +2 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/normalize-path-options.js +73 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/utils.d.ts +1 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/utils.js +13 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/validate-project.d.ts +9 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/validate-project.js +40 -0
- package/src/generators/convert-config-to-rspack-plugin/schema.json +19 -0
- package/src/generators/convert-to-inferred/__snapshots__/convert-to-inferred.spec.ts.snap +268 -0
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts +12 -0
- package/src/generators/convert-to-inferred/convert-to-inferred.js +114 -0
- package/src/generators/convert-to-inferred/schema.json +19 -0
- package/src/generators/convert-to-inferred/utils/ast.d.ts +3 -0
- package/src/generators/convert-to-inferred/utils/ast.js +40 -0
- package/src/generators/convert-to-inferred/utils/build-post-target-transformer.d.ts +6 -0
- package/src/generators/convert-to-inferred/utils/build-post-target-transformer.js +210 -0
- package/src/generators/convert-to-inferred/utils/index.d.ts +3 -0
- package/src/generators/convert-to-inferred/utils/index.js +6 -0
- package/src/generators/convert-to-inferred/utils/serve-post-target-transformer.d.ts +6 -0
- package/src/generators/convert-to-inferred/utils/serve-post-target-transformer.js +207 -0
- package/src/generators/convert-to-inferred/utils/types.d.ts +11 -0
- package/src/generators/convert-webpack/lib/transform-cjs.js +5 -5
- package/src/generators/convert-webpack/lib/transform-esm.js +5 -5
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.d.ts +2 -0
- package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.js +35 -0
- package/src/plugins/nx-app-rspack-plugin/nx-app-rspack-plugin.d.ts +16 -0
- package/src/plugins/nx-app-rspack-plugin/nx-app-rspack-plugin.js +43 -0
- package/src/plugins/nx-react-rspack-plugin/nx-react-rspack-plugin.d.ts +8 -0
- package/src/plugins/nx-react-rspack-plugin/nx-react-rspack-plugin.js +13 -0
- package/src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.d.ts +31 -0
- package/src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.js +73 -0
- package/src/plugins/utils/apply-base-config.js +2 -5
- package/src/plugins/utils/apply-web-config.d.ts +2 -2
- package/src/plugins/utils/apply-web-config.js +1 -8
- package/src/plugins/utils/models.d.ts +2 -2
- package/src/plugins/utils/plugins/normalize-options.js +1 -1
- package/src/plugins/utils/plugins/nx-tsconfig-paths-rspack-plugin.js +3 -2
- package/src/utils/create-compiler.d.ts +2 -2
- package/src/utils/create-compiler.js +12 -49
- package/src/utils/generator-utils.d.ts +2 -2
- package/src/utils/generator-utils.js +134 -67
- package/src/utils/has-plugin.d.ts +2 -0
- package/src/utils/has-plugin.js +10 -0
- package/src/utils/module-federation/build-static.remotes.d.ts +1 -1
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +2 -2
- package/src/utils/module-federation/dependencies.d.ts +0 -6
- package/src/utils/module-federation/dependencies.js +0 -56
- package/src/utils/module-federation/get-remotes-for-host.d.ts +0 -16
- package/src/utils/module-federation/get-remotes-for-host.js +0 -99
- package/src/utils/module-federation/index.d.ts +0 -6
- package/src/utils/module-federation/index.js +0 -9
- package/src/utils/module-federation/models/index.d.ts +0 -47
- package/src/utils/module-federation/package-json.d.ts +0 -8
- package/src/utils/module-federation/package-json.js +0 -12
- package/src/utils/module-federation/parse-static-remotes-config.d.ts +0 -13
- package/src/utils/module-federation/parse-static-remotes-config.js +0 -34
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.d.ts +0 -3
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.js +0 -54
- package/src/utils/module-federation/public-api.d.ts +0 -8
- package/src/utils/module-federation/public-api.js +0 -20
- package/src/utils/module-federation/remotes.d.ts +0 -19
- package/src/utils/module-federation/remotes.js +0 -85
- package/src/utils/module-federation/secondary-entry-points.d.ts +0 -12
- package/src/utils/module-federation/secondary-entry-points.js +0 -104
- package/src/utils/module-federation/share.d.ts +0 -48
- package/src/utils/module-federation/share.js +0 -235
- package/src/utils/module-federation/start-remote-proxies.d.ts +0 -5
- package/src/utils/module-federation/start-remote-proxies.js +0 -45
- package/src/utils/module-federation/start-ssr-remote-proxies.d.ts +0 -5
- package/src/utils/module-federation/start-ssr-remote-proxies.js +0 -59
- package/src/utils/module-federation/typescript.d.ts +0 -4
- package/src/utils/module-federation/typescript.js +0 -53
- package/src/utils/module-federation/with-module-federation/package-json.d.ts +0 -8
- package/src/utils/module-federation/with-module-federation/package-json.js +0 -12
- package/src/utils/module-federation/with-module-federation/utils.d.ts +0 -12
- package/src/utils/module-federation/with-module-federation/utils.js +0 -76
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.d.ts +0 -3
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.js +0 -55
- package/src/utils/module-federation/with-module-federation/with-module-federation.d.ts +0 -8
- package/src/utils/module-federation/with-module-federation/with-module-federation.js +0 -70
- /package/src/{utils/module-federation/models/index.js → generators/convert-to-inferred/utils/types.js} +0 -0
package/app-plugin.d.ts
ADDED
package/app-plugin.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NxAppRspackPlugin = void 0;
|
|
4
|
+
var nx_app_rspack_plugin_1 = require("./src/plugins/nx-app-rspack-plugin/nx-app-rspack-plugin");
|
|
5
|
+
Object.defineProperty(exports, "NxAppRspackPlugin", { enumerable: true, get: function () { return nx_app_rspack_plugin_1.NxAppRspackPlugin; } });
|
package/generators.json
CHANGED
|
@@ -31,6 +31,16 @@
|
|
|
31
31
|
"factory": "./src/generators/convert-webpack/convert-webpack",
|
|
32
32
|
"schema": "./src/generators/convert-webpack/schema.json",
|
|
33
33
|
"description": "Convert a webpack application to use rspack."
|
|
34
|
+
},
|
|
35
|
+
"convert-config-to-rspack-plugin": {
|
|
36
|
+
"factory": "./src/generators/convert-config-to-rspack-plugin/convert-config-to-rspack-plugin",
|
|
37
|
+
"schema": "./src/generators/convert-config-to-rspack-plugin/schema.json",
|
|
38
|
+
"description": "Convert the project to use the `NxAppRspackPlugin` and `NxReactRspackPlugin`."
|
|
39
|
+
},
|
|
40
|
+
"convert-to-inferred": {
|
|
41
|
+
"factory": "./src/generators/convert-to-inferred/convert-to-inferred#convertToInferred",
|
|
42
|
+
"schema": "./src/generators/convert-to-inferred/schema.json",
|
|
43
|
+
"description": "Convert existing Rspack project(s) using `@nx/rspack:rspack` executor to use `@nx/rspack/plugin`."
|
|
34
44
|
}
|
|
35
45
|
}
|
|
36
46
|
}
|
package/migrations.json
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generators": {
|
|
2
|
+
"generators": {
|
|
3
|
+
"update-20-2-0-update-with-module-federation-import": {
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"version": "20.2.0-beta.3",
|
|
6
|
+
"description": "Update the withModuleFederation import use @nx/module-federation/rspack.",
|
|
7
|
+
"factory": "./src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
3
10
|
"packageJsonUpdates": {
|
|
4
11
|
"18.1.0": {
|
|
5
12
|
"version": "18.1.0-beta.0",
|
|
@@ -68,6 +75,19 @@
|
|
|
68
75
|
"alwaysAddToPackageJson": false
|
|
69
76
|
}
|
|
70
77
|
}
|
|
78
|
+
},
|
|
79
|
+
"20.2.0": {
|
|
80
|
+
"version": "20.2.0-beta.3",
|
|
81
|
+
"packages": {
|
|
82
|
+
"@rspack/core": {
|
|
83
|
+
"version": "^1.1.2",
|
|
84
|
+
"alwaysAddToPackageJson": false
|
|
85
|
+
},
|
|
86
|
+
"@rspack/dev-server": {
|
|
87
|
+
"version": "^1.0.9",
|
|
88
|
+
"alwaysAddToPackageJson": false
|
|
89
|
+
}
|
|
90
|
+
}
|
|
71
91
|
}
|
|
72
92
|
},
|
|
73
93
|
"version": "0.1"
|
package/module-federation.d.ts
CHANGED
package/module-federation.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
exports.withModuleFederationForSSR = exports.withModuleFederation = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Use `@nx/module-federation/rspack` instead. This will be removed in Nx v22.
|
|
6
|
+
*/
|
|
7
|
+
var rspack_1 = require("@nx/module-federation/rspack");
|
|
8
|
+
Object.defineProperty(exports, "withModuleFederation", { enumerable: true, get: function () { return rspack_1.withModuleFederation; } });
|
|
9
|
+
Object.defineProperty(exports, "withModuleFederationForSSR", { enumerable: true, get: function () { return rspack_1.withModuleFederationForSSR; } });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/rspack",
|
|
3
3
|
"description": "The Nx Plugin for Rspack contains executors and generators that support building applications using Rspack.",
|
|
4
|
-
"version": "20.2.0-beta.
|
|
4
|
+
"version": "20.2.0-beta.3",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -24,12 +24,13 @@
|
|
|
24
24
|
"generators": "./generators.json",
|
|
25
25
|
"executors": "./executors.json",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@nx/js": "20.2.0-beta.
|
|
28
|
-
"@nx/devkit": "20.2.0-beta.
|
|
29
|
-
"@nx/web": "20.2.0-beta.
|
|
27
|
+
"@nx/js": "20.2.0-beta.3",
|
|
28
|
+
"@nx/devkit": "20.2.0-beta.3",
|
|
29
|
+
"@nx/web": "20.2.0-beta.3",
|
|
30
|
+
"@nx/module-federation": "20.2.0-beta.3",
|
|
30
31
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
31
|
-
"@rspack/core": "^1.
|
|
32
|
-
"@rspack/dev-server": "^1.0.
|
|
32
|
+
"@rspack/core": "^1.1.2",
|
|
33
|
+
"@rspack/dev-server": "^1.0.9",
|
|
33
34
|
"@rspack/plugin-react-refresh": "^1.0.0",
|
|
34
35
|
"autoprefixer": "^10.4.9",
|
|
35
36
|
"browserslist": "^4.21.4",
|
|
@@ -50,11 +51,12 @@
|
|
|
50
51
|
"postcss-loader": "^8.1.1",
|
|
51
52
|
"postcss": "^8.4.38",
|
|
52
53
|
"tslib": "^2.3.0",
|
|
54
|
+
"webpack": "^5.80.0",
|
|
53
55
|
"webpack-node-externals": "^3.0.0"
|
|
54
56
|
},
|
|
55
57
|
"peerDependencies": {
|
|
56
|
-
"@module-federation/enhanced": "~0.6
|
|
57
|
-
"@module-federation/node": "~2.
|
|
58
|
+
"@module-federation/enhanced": "~0.7.6",
|
|
59
|
+
"@module-federation/node": "~2.6.11"
|
|
58
60
|
},
|
|
59
61
|
"nx-migrations": {
|
|
60
62
|
"migrations": "./migrations.json"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NxReactRspackPlugin } from './src/plugins/nx-react-rspack-plugin/nx-react-rspack-plugin';
|
package/react-plugin.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NxReactRspackPlugin = void 0;
|
|
4
|
+
var nx_react_rspack_plugin_1 = require("./src/plugins/nx-react-rspack-plugin/nx-react-rspack-plugin");
|
|
5
|
+
Object.defineProperty(exports, "NxReactRspackPlugin", { enumerable: true, get: function () { return nx_react_rspack_plugin_1.NxReactRspackPlugin; } });
|
|
@@ -8,10 +8,8 @@ const file_server_impl_1 = tslib_1.__importDefault(require("@nx/web/src/executor
|
|
|
8
8
|
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
|
9
9
|
const fs_1 = require("fs");
|
|
10
10
|
const path_1 = require("path");
|
|
11
|
-
const
|
|
11
|
+
const utils_1 = require("@nx/module-federation/src/utils");
|
|
12
12
|
const build_static_remotes_1 = require("../../utils/module-federation/build-static.remotes");
|
|
13
|
-
const parse_static_remotes_config_1 = require("../../utils/module-federation/parse-static-remotes-config");
|
|
14
|
-
const start_remote_proxies_1 = require("../../utils/module-federation/start-remote-proxies");
|
|
15
13
|
const dev_server_impl_1 = tslib_1.__importDefault(require("../dev-server/dev-server.impl"));
|
|
16
14
|
function getBuildOptions(buildTarget, context) {
|
|
17
15
|
const target = (0, devkit_1.parseTargetString)(buildTarget, context);
|
|
@@ -121,9 +119,9 @@ async function* moduleFederationDevServer(options, context) {
|
|
|
121
119
|
if (!options.isInitialHost) {
|
|
122
120
|
return yield* currIter;
|
|
123
121
|
}
|
|
124
|
-
const moduleFederationConfig = (0,
|
|
122
|
+
const moduleFederationConfig = (0, utils_1.getModuleFederationConfig)(buildOptions.tsConfig, context.root, p.root, 'react');
|
|
125
123
|
const remoteNames = options.devRemotes?.map((r) => typeof r === 'string' ? r : r.remoteName);
|
|
126
|
-
const remotes = (0,
|
|
124
|
+
const remotes = (0, utils_1.getRemotes)(remoteNames, options.skipRemotes, moduleFederationConfig, {
|
|
127
125
|
projectName: context.projectName,
|
|
128
126
|
projectGraph: context.projectGraph,
|
|
129
127
|
root: context.root,
|
|
@@ -134,11 +132,11 @@ async function* moduleFederationDevServer(options, context) {
|
|
|
134
132
|
...(remotes.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName) ?? []).map((r) => r.replace(/-/g, '_')),
|
|
135
133
|
p.name.replace(/-/g, '_'),
|
|
136
134
|
]);
|
|
137
|
-
const staticRemotesConfig = (0,
|
|
135
|
+
const staticRemotesConfig = (0, utils_1.parseStaticRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
|
|
138
136
|
const mappedLocationsOfStaticRemotes = await (0, build_static_remotes_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options);
|
|
139
137
|
const devRemoteIters = await startRemotes(remotes.devRemotes, context, options, 'serve');
|
|
140
138
|
const staticRemotesIter = startStaticRemotesFileServer(staticRemotesConfig, context, options);
|
|
141
|
-
(0,
|
|
139
|
+
(0, utils_1.startRemoteProxies)(staticRemotesConfig, mappedLocationsOfStaticRemotes, options.ssl
|
|
142
140
|
? {
|
|
143
141
|
pathToCert: (0, path_1.join)(devkit_1.workspaceRoot, options.sslCert),
|
|
144
142
|
pathToKey: (0, path_1.join)(devkit_1.workspaceRoot, options.sslKey),
|
package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js
CHANGED
|
@@ -4,16 +4,14 @@ exports.default = moduleFederationSsrDevServer;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
-
const
|
|
7
|
+
const utils_1 = require("@nx/module-federation/src/utils");
|
|
8
8
|
const ssr_dev_server_impl_1 = tslib_1.__importDefault(require("../ssr-dev-server/ssr-dev-server.impl"));
|
|
9
9
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
10
10
|
const child_process_1 = require("child_process");
|
|
11
11
|
const fs_1 = require("fs");
|
|
12
|
-
const parse_static_remotes_config_1 = require("../../utils/module-federation/parse-static-remotes-config");
|
|
13
12
|
const file_server_impl_1 = tslib_1.__importDefault(require("@nx/web/src/executors/file-server/file-server.impl"));
|
|
14
13
|
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
|
15
14
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
16
|
-
const start_ssr_remote_proxies_1 = require("../../utils/module-federation/start-ssr-remote-proxies");
|
|
17
15
|
function normalizeOptions(options) {
|
|
18
16
|
return {
|
|
19
17
|
...options,
|
|
@@ -159,9 +157,9 @@ async function* moduleFederationSsrDevServer(ssrDevServerOptions, context) {
|
|
|
159
157
|
if (!options.isInitialHost) {
|
|
160
158
|
return yield* iter;
|
|
161
159
|
}
|
|
162
|
-
const moduleFederationConfig = (0,
|
|
160
|
+
const moduleFederationConfig = (0, utils_1.getModuleFederationConfig)(buildOptions.tsConfig, context.root, projectConfig.root, 'react');
|
|
163
161
|
const remoteNames = options.devRemotes?.map((remote) => typeof remote === 'string' ? remote : remote.remoteName);
|
|
164
|
-
const remotes = (0,
|
|
162
|
+
const remotes = (0, utils_1.getRemotes)(remoteNames, options.skipRemotes, moduleFederationConfig, {
|
|
165
163
|
projectName: context.projectName,
|
|
166
164
|
projectGraph: context.projectGraph,
|
|
167
165
|
root: context.root,
|
|
@@ -171,11 +169,11 @@ async function* moduleFederationSsrDevServer(ssrDevServerOptions, context) {
|
|
|
171
169
|
...(remotes.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName) ?? []).map((r) => r.replace(/-/g, '_')),
|
|
172
170
|
projectConfig.name.replace(/-/g, '_'),
|
|
173
171
|
]);
|
|
174
|
-
const staticRemotesConfig = (0,
|
|
172
|
+
const staticRemotesConfig = (0, utils_1.parseStaticSsrRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
|
|
175
173
|
const mappedLocationsOfStaticRemotes = await buildSsrStaticRemotes(staticRemotesConfig, nxBin, context, options);
|
|
176
174
|
const devRemoteIters = await startRemotes(remotes.devRemotes, context, options);
|
|
177
175
|
const staticRemotesIter = startSsrStaticRemotesFileServer(staticRemotesConfig, context, options);
|
|
178
|
-
(0,
|
|
176
|
+
(0, utils_1.startSsrRemoteProxies)(staticRemotesConfig, mappedLocationsOfStaticRemotes, options.ssl
|
|
179
177
|
? {
|
|
180
178
|
pathToCert: options.sslCert,
|
|
181
179
|
pathToKey: options.sslKey,
|
package/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExecutorContext } from 'nx/src/config/misc-interfaces';
|
|
2
|
-
import { StaticRemotesConfig } from '
|
|
2
|
+
import { StaticRemotesConfig } from '@nx/module-federation/src/utils';
|
|
3
3
|
import { ModuleFederationDevServerOptions } from '../module-federation-dev-server/schema';
|
|
4
4
|
import { ModuleFederationStaticServerSchema } from './schema';
|
|
5
5
|
export declare function startProxies(staticRemotesConfig: StaticRemotesConfig, hostServeOptions: ModuleFederationDevServerOptions, mappedLocationOfHost: string, mappedLocationsOfRemotes: Record<string, string>, sslOptions?: {
|
package/src/executors/module-federation-static-server/module-federation-static-server.impl.js
CHANGED
|
@@ -10,9 +10,8 @@ const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
|
|
10
10
|
const child_process_1 = require("child_process");
|
|
11
11
|
const fs_1 = require("fs");
|
|
12
12
|
const path_1 = require("path");
|
|
13
|
-
const
|
|
13
|
+
const utils_1 = require("@nx/module-federation/src/utils");
|
|
14
14
|
const build_static_remotes_1 = require("../../utils/module-federation/build-static.remotes");
|
|
15
|
-
const parse_static_remotes_config_1 = require("../../utils/module-federation/parse-static-remotes-config");
|
|
16
15
|
function getBuildAndServeOptionsFromServeTarget(serveTarget, context) {
|
|
17
16
|
const target = (0, devkit_1.parseTargetString)(serveTarget, context);
|
|
18
17
|
const serveOptions = (0, devkit_1.readTargetOptions)(target, context);
|
|
@@ -170,13 +169,13 @@ async function* moduleFederationStaticServer(schema, context) {
|
|
|
170
169
|
// Get the remotes from the module federation config
|
|
171
170
|
const p = context.projectsConfigurations.projects[context.projectName];
|
|
172
171
|
const options = getBuildAndServeOptionsFromServeTarget(schema.serveTarget, context);
|
|
173
|
-
const moduleFederationConfig = (0,
|
|
174
|
-
const remotes = (0,
|
|
172
|
+
const moduleFederationConfig = (0, utils_1.getModuleFederationConfig)(options.buildOptions.tsConfig, context.root, p.root, 'react');
|
|
173
|
+
const remotes = (0, utils_1.getRemotes)([], options.serveOptions.skipRemotes, moduleFederationConfig, {
|
|
175
174
|
projectName: context.projectName,
|
|
176
175
|
projectGraph: context.projectGraph,
|
|
177
176
|
root: context.root,
|
|
178
177
|
}, options.pathToManifestFile);
|
|
179
|
-
const staticRemotesConfig = (0,
|
|
178
|
+
const staticRemotesConfig = (0, utils_1.parseStaticRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
|
|
180
179
|
options.serveOptions.staticRemotesPort ??= remotes.staticRemotePort;
|
|
181
180
|
const mappedLocationsOfStaticRemotes = await (0, build_static_remotes_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options.serveOptions);
|
|
182
181
|
// Build the host
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { type Configuration } from '@rspack/core';
|
|
3
|
+
import { type NormalizedRspackExecutorSchema } from '../schema';
|
|
4
|
+
export declare function getRspackConfigs(options: NormalizedRspackExecutorSchema & {
|
|
5
|
+
devServer?: any;
|
|
6
|
+
}, context: ExecutorContext): Promise<Configuration | Configuration[]>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRspackConfigs = getRspackConfigs;
|
|
4
|
+
const config_1 = require("../../../utils/config");
|
|
5
|
+
const resolve_user_defined_rspack_config_1 = require("../../../utils/resolve-user-defined-rspack-config");
|
|
6
|
+
const with_nx_1 = require("../../../utils/with-nx");
|
|
7
|
+
const with_web_1 = require("../../../utils/with-web");
|
|
8
|
+
async function getRspackConfigs(options, context) {
|
|
9
|
+
let userDefinedConfig = (0, resolve_user_defined_rspack_config_1.resolveUserDefinedRspackConfig)(options.rspackConfig, options.tsConfig);
|
|
10
|
+
if (typeof userDefinedConfig.then === 'function') {
|
|
11
|
+
userDefinedConfig = await userDefinedConfig;
|
|
12
|
+
}
|
|
13
|
+
const config = (options.target === 'web'
|
|
14
|
+
? (0, config_1.composePluginsSync)((0, with_nx_1.withNx)(options), (0, with_web_1.withWeb)(options))
|
|
15
|
+
: (0, with_nx_1.withNx)(options))({}, { options, context });
|
|
16
|
+
if ((typeof userDefinedConfig === 'function' &&
|
|
17
|
+
(0, config_1.isNxRspackComposablePlugin)(userDefinedConfig)) ||
|
|
18
|
+
!options.standardRspackConfigFunction) {
|
|
19
|
+
// Old behavior, call the Nx-specific rspack config function that user exports
|
|
20
|
+
return await userDefinedConfig(config, {
|
|
21
|
+
options,
|
|
22
|
+
context,
|
|
23
|
+
configuration: context.configurationName,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
else if (userDefinedConfig) {
|
|
27
|
+
if (typeof userDefinedConfig === 'function') {
|
|
28
|
+
// assume it's an async standard rspack config function which operates similar to webpack
|
|
29
|
+
// https://webpack.js.org/configuration/configuration-types/#exporting-a-promise
|
|
30
|
+
return await userDefinedConfig(process.env.NODE_ENV, {});
|
|
31
|
+
}
|
|
32
|
+
// New behavior, we want the rspack config to export object
|
|
33
|
+
return userDefinedConfig;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// Fallback case, if we cannot find a rspack config path
|
|
37
|
+
return config;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = runExecutor;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
7
6
|
const js_1 = require("@nx/js");
|
|
8
7
|
const fs_1 = require("fs");
|
|
9
|
-
const path = tslib_1.__importStar(require("path"));
|
|
10
8
|
const create_compiler_1 = require("../../utils/create-compiler");
|
|
11
9
|
const mode_utils_1 = require("../../utils/mode-utils");
|
|
12
10
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
11
|
+
const path_1 = require("path");
|
|
13
12
|
async function* runExecutor(options, context) {
|
|
14
13
|
process.env.NODE_ENV ??= options.mode ?? 'production';
|
|
15
14
|
options.target ??= 'web';
|
|
15
|
+
const metadata = context.projectsConfigurations.projects[context.projectName];
|
|
16
|
+
const sourceRoot = metadata.sourceRoot;
|
|
17
|
+
const normalizedOptions = (0, normalize_options_1.normalizeOptions)(options, context.root, metadata.root, sourceRoot);
|
|
16
18
|
if ((0, mode_utils_1.isMode)(process.env.NODE_ENV)) {
|
|
17
|
-
|
|
19
|
+
normalizedOptions.mode = process.env.NODE_ENV;
|
|
18
20
|
}
|
|
19
|
-
if (
|
|
20
|
-
await executeTypeCheck(
|
|
21
|
+
if (normalizedOptions.typeCheck) {
|
|
22
|
+
await executeTypeCheck(normalizedOptions, context);
|
|
21
23
|
}
|
|
22
24
|
// Mimic --clean from webpack.
|
|
23
|
-
(0, fs_1.rmSync)(
|
|
25
|
+
(0, fs_1.rmSync)((0, path_1.join)(context.root, normalizedOptions.outputPath), {
|
|
24
26
|
force: true,
|
|
25
27
|
recursive: true,
|
|
26
28
|
});
|
|
27
|
-
const metadata = context.projectsConfigurations.projects[context.projectName];
|
|
28
|
-
const sourceRoot = metadata.sourceRoot;
|
|
29
|
-
const normalizedOptions = (0, normalize_options_1.normalizeOptions)(options, context.root, metadata.root, sourceRoot);
|
|
30
29
|
const compiler = await (0, create_compiler_1.createCompiler)(normalizedOptions, context);
|
|
31
30
|
const iterable = (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
|
|
32
31
|
if (options.watch) {
|
|
@@ -49,7 +48,7 @@ async function* runExecutor(options, context) {
|
|
|
49
48
|
}
|
|
50
49
|
next({
|
|
51
50
|
success: !stats.hasErrors(),
|
|
52
|
-
outfile:
|
|
51
|
+
outfile: (0, path_1.resolve)(context.root, normalizedOptions.outputPath, 'main.js'),
|
|
53
52
|
});
|
|
54
53
|
});
|
|
55
54
|
registerCleanupCallback(() => {
|
|
@@ -79,7 +78,7 @@ async function* runExecutor(options, context) {
|
|
|
79
78
|
}
|
|
80
79
|
next({
|
|
81
80
|
success: !stats.hasErrors(),
|
|
82
|
-
outfile:
|
|
81
|
+
outfile: (0, path_1.resolve)(context.root, normalizedOptions.outputPath, 'main.js'),
|
|
83
82
|
});
|
|
84
83
|
done();
|
|
85
84
|
});
|
|
@@ -103,7 +102,7 @@ function registerCleanupCallback(callback) {
|
|
|
103
102
|
async function executeTypeCheck(options, context) {
|
|
104
103
|
const projectConfiguration = context.projectGraph.nodes[context.projectName].data;
|
|
105
104
|
const result = await (0, js_1.runTypeCheck)({
|
|
106
|
-
workspaceRoot:
|
|
105
|
+
workspaceRoot: (0, path_1.resolve)(projectConfiguration.root),
|
|
107
106
|
tsConfigPath: options.tsConfig,
|
|
108
107
|
mode: 'noEmit',
|
|
109
108
|
});
|
|
@@ -1,28 +1,49 @@
|
|
|
1
|
-
import type { Mode } from '@rspack/core';
|
|
1
|
+
import type { DevTool, Mode } from '@rspack/core';
|
|
2
2
|
|
|
3
3
|
export interface RspackExecutorSchema {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
index?: string;
|
|
7
|
-
tsConfig?: string;
|
|
8
|
-
typeCheck?: boolean;
|
|
9
|
-
skipTypeChecking?: boolean;
|
|
10
|
-
outputPath?: string;
|
|
11
|
-
outputFileName?: string;
|
|
12
|
-
index?: string;
|
|
13
|
-
indexHtml?: string;
|
|
14
|
-
mode?: Mode;
|
|
15
|
-
watch?: boolean;
|
|
4
|
+
additionalEntryPoints?: AdditionalEntryPoint[];
|
|
5
|
+
assets?: Array<AssetGlobPattern | string>;
|
|
16
6
|
baseHref?: string;
|
|
7
|
+
buildLibsFromSource?: boolean;
|
|
17
8
|
deployUrl?: string;
|
|
18
|
-
|
|
19
|
-
rspackConfig: string;
|
|
20
|
-
optimization?: boolean | OptimizationOptions;
|
|
21
|
-
sourceMap?: boolean | string;
|
|
22
|
-
assets?: any[];
|
|
9
|
+
extractCss?: boolean;
|
|
23
10
|
extractLicenses?: boolean;
|
|
11
|
+
externalDependencies?: 'all' | 'none' | string[];
|
|
24
12
|
fileReplacements?: FileReplacement[];
|
|
13
|
+
generateIndexHtml?: boolean;
|
|
25
14
|
generatePackageJson?: boolean;
|
|
15
|
+
index?: string;
|
|
16
|
+
indexHtml?: string;
|
|
17
|
+
main?: string;
|
|
18
|
+
memoryLimit?: number;
|
|
19
|
+
mode?: Mode;
|
|
20
|
+
namedChunks?: boolean;
|
|
21
|
+
optimization?: boolean | OptimizationOptions;
|
|
22
|
+
outputFileName?: string;
|
|
23
|
+
outputHashing?: any;
|
|
24
|
+
outputPath?: string;
|
|
25
|
+
poll?: number;
|
|
26
|
+
polyfills?: string;
|
|
27
|
+
postcssConfig?: string;
|
|
28
|
+
progress?: boolean;
|
|
29
|
+
publicPath?: string;
|
|
30
|
+
rebaseRootRelative?: boolean;
|
|
31
|
+
rspackConfig?: string;
|
|
32
|
+
runtimeChunk?: boolean;
|
|
33
|
+
scripts?: Array<ExtraEntryPointClass | string>;
|
|
34
|
+
skipTypeChecking?: boolean;
|
|
35
|
+
sourceMap?: boolean | DevTool;
|
|
36
|
+
standardRspackConfigFunction?: boolean;
|
|
37
|
+
statsJson?: boolean;
|
|
38
|
+
stylePreprocessorOptions?: any;
|
|
39
|
+
styles?: Array<ExtraEntryPointClass | string>;
|
|
40
|
+
target?: 'web' | 'node';
|
|
41
|
+
transformers?: TransformerEntry[];
|
|
42
|
+
tsConfig?: string;
|
|
43
|
+
typeCheck?: boolean;
|
|
44
|
+
verbose?: boolean;
|
|
45
|
+
vendorChunk?: boolean;
|
|
46
|
+
watch?: boolean;
|
|
26
47
|
}
|
|
27
48
|
|
|
28
49
|
export interface AssetGlobPattern {
|
|
@@ -129,6 +129,144 @@
|
|
|
129
129
|
"generatePackageJson": {
|
|
130
130
|
"type": "boolean",
|
|
131
131
|
"description": "Generates a `package.json` and pruned lock file with the project's `node_module` dependencies populated for installing in a container. If a `package.json` exists in the project's directory, it will be reused with dependencies populated."
|
|
132
|
+
},
|
|
133
|
+
"additionalEntryPoints": {
|
|
134
|
+
"type": "array",
|
|
135
|
+
"items": {
|
|
136
|
+
"type": "object",
|
|
137
|
+
"properties": {
|
|
138
|
+
"entryName": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"description": "Name of the additional entry file."
|
|
141
|
+
},
|
|
142
|
+
"entryPath": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"description": "Path to the additional entry file.",
|
|
145
|
+
"x-completion-type": "file",
|
|
146
|
+
"x-completion-glob": "**/*@(.js|.ts)"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"buildLibsFromSource": {
|
|
152
|
+
"type": "boolean",
|
|
153
|
+
"description": "Read buildable libraries from source instead of building them separately. If set to `false`, the `tsConfig` option must also be set to remap paths.",
|
|
154
|
+
"default": true
|
|
155
|
+
},
|
|
156
|
+
"extractCss": {
|
|
157
|
+
"type": "boolean",
|
|
158
|
+
"description": "Extract CSS into a `.css` file."
|
|
159
|
+
},
|
|
160
|
+
"externalDependencies": {
|
|
161
|
+
"oneOf": [
|
|
162
|
+
{
|
|
163
|
+
"type": "string",
|
|
164
|
+
"enum": ["none", "all"]
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"type": "array",
|
|
168
|
+
"items": {
|
|
169
|
+
"type": "string"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
"description": "Dependencies to keep external to the bundle. (`all` (default), `none`, or an array of module names)"
|
|
174
|
+
},
|
|
175
|
+
"generateIndexHtml": {
|
|
176
|
+
"type": "boolean",
|
|
177
|
+
"description": "Generates `index.html` file to the output path. This can be turned off if using a webpack plugin to generate HTML such as `html-webpack-plugin`."
|
|
178
|
+
},
|
|
179
|
+
"memoryLimit": {
|
|
180
|
+
"type": "number",
|
|
181
|
+
"description": "Memory limit for type checking service process in `MB`."
|
|
182
|
+
},
|
|
183
|
+
"namedChunks": {
|
|
184
|
+
"type": "boolean",
|
|
185
|
+
"description": "Names the produced bundles according to their entry file."
|
|
186
|
+
},
|
|
187
|
+
"outputHashing": {
|
|
188
|
+
"type": "string",
|
|
189
|
+
"description": "Define the output filename cache-busting hashing mode.",
|
|
190
|
+
"enum": ["none", "all", "media", "bundles"]
|
|
191
|
+
},
|
|
192
|
+
"poll": {
|
|
193
|
+
"type": "number",
|
|
194
|
+
"description": "Enable and define the file watching poll time period."
|
|
195
|
+
},
|
|
196
|
+
"polyfills": {
|
|
197
|
+
"type": "string",
|
|
198
|
+
"description": "Polyfills to load before application",
|
|
199
|
+
"x-completion-type": "file",
|
|
200
|
+
"x-completion-glob": "**/*@(.js|.ts|.tsx)"
|
|
201
|
+
},
|
|
202
|
+
"postcssConfig": {
|
|
203
|
+
"type": "string",
|
|
204
|
+
"description": "Set a path to PostCSS config that applies to the app and all libs. Defaults to `undefined`, which auto-detects postcss.config.js files in each `app`/`lib` directory."
|
|
205
|
+
},
|
|
206
|
+
"progress": {
|
|
207
|
+
"type": "boolean",
|
|
208
|
+
"description": "Log progress to the console while building."
|
|
209
|
+
},
|
|
210
|
+
"publicPath": {
|
|
211
|
+
"type": "string",
|
|
212
|
+
"description": "Set a public path for assets resources with absolute paths."
|
|
213
|
+
},
|
|
214
|
+
"rebaseRootRelative": {
|
|
215
|
+
"type": "boolean",
|
|
216
|
+
"description": "Whether to rebase absolute path for assets in postcss cli resources."
|
|
217
|
+
},
|
|
218
|
+
"runtimeChunk": {
|
|
219
|
+
"type": "boolean",
|
|
220
|
+
"description": "Use a separate bundle containing the runtime."
|
|
221
|
+
},
|
|
222
|
+
"scripts": {
|
|
223
|
+
"type": "array",
|
|
224
|
+
"description": "External Scripts which will be included before the main application entry.",
|
|
225
|
+
"items": {
|
|
226
|
+
"$ref": "#/definitions/extraEntryPoint"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
"standardRspackConfigFunction": {
|
|
230
|
+
"type": "boolean",
|
|
231
|
+
"description": "Set to true if the rspack config exports a standard rspack function, not an Nx-specific one. See: https://rspack.dev/config/",
|
|
232
|
+
"default": false
|
|
233
|
+
},
|
|
234
|
+
"statsJson": {
|
|
235
|
+
"type": "boolean",
|
|
236
|
+
"description": "Generates a 'stats.json' file which can be analyzed using tools such as: 'webpack-bundle-analyzer' See: https://rspack.dev/guide/optimization/analysis"
|
|
237
|
+
},
|
|
238
|
+
"stylePreprocessorOptions": {
|
|
239
|
+
"description": "Options to pass to style preprocessors.",
|
|
240
|
+
"type": "object",
|
|
241
|
+
"properties": {
|
|
242
|
+
"includePaths": {
|
|
243
|
+
"description": "Paths to include. Paths will be resolved to project root.",
|
|
244
|
+
"type": "array",
|
|
245
|
+
"items": {
|
|
246
|
+
"type": "string"
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"additionalProperties": false
|
|
251
|
+
},
|
|
252
|
+
"styles": {
|
|
253
|
+
"type": "array",
|
|
254
|
+
"description": "External Styles which will be included with the application",
|
|
255
|
+
"items": {
|
|
256
|
+
"$ref": "#/definitions/extraEntryPoint"
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
"transformers": {
|
|
260
|
+
"type": "array",
|
|
261
|
+
"description": "List of TypeScript Compiler Transfomers Plugins.",
|
|
262
|
+
"aliases": ["tsPlugins"],
|
|
263
|
+
"items": {
|
|
264
|
+
"$ref": "#/definitions/transformerPattern"
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
"vendorChunk": {
|
|
268
|
+
"type": "boolean",
|
|
269
|
+
"description": "Use a separate bundle containing only vendor libraries."
|
|
132
270
|
}
|
|
133
271
|
},
|
|
134
272
|
"required": ["rspackConfig"],
|
|
@@ -170,6 +308,59 @@
|
|
|
170
308
|
"type": "string"
|
|
171
309
|
}
|
|
172
310
|
]
|
|
311
|
+
},
|
|
312
|
+
"extraEntryPoint": {
|
|
313
|
+
"oneOf": [
|
|
314
|
+
{
|
|
315
|
+
"type": "object",
|
|
316
|
+
"properties": {
|
|
317
|
+
"input": {
|
|
318
|
+
"type": "string",
|
|
319
|
+
"description": "The file to include.",
|
|
320
|
+
"x-completion-type": "file",
|
|
321
|
+
"x-completion-glob": "**/*@(.css|.scss|.less|.sass|.styl|.stylus)"
|
|
322
|
+
},
|
|
323
|
+
"bundleName": {
|
|
324
|
+
"type": "string",
|
|
325
|
+
"description": "The bundle name for this extra entry point."
|
|
326
|
+
},
|
|
327
|
+
"inject": {
|
|
328
|
+
"type": "boolean",
|
|
329
|
+
"description": "If the bundle will be referenced in the HTML file.",
|
|
330
|
+
"default": true
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
"additionalProperties": false,
|
|
334
|
+
"required": ["input"]
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"type": "string",
|
|
338
|
+
"description": "The file to include.",
|
|
339
|
+
"x-completion-type": "file",
|
|
340
|
+
"x-completion-glob": "**/*@(.css|.scss|.less|.sass|.styl|.stylus)"
|
|
341
|
+
}
|
|
342
|
+
]
|
|
343
|
+
},
|
|
344
|
+
"transformerPattern": {
|
|
345
|
+
"oneOf": [
|
|
346
|
+
{
|
|
347
|
+
"type": "string"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"type": "object",
|
|
351
|
+
"properties": {
|
|
352
|
+
"name": {
|
|
353
|
+
"type": "string"
|
|
354
|
+
},
|
|
355
|
+
"options": {
|
|
356
|
+
"type": "object",
|
|
357
|
+
"additionalProperties": true
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
"additionalProperties": false,
|
|
361
|
+
"required": ["name"]
|
|
362
|
+
}
|
|
363
|
+
]
|
|
173
364
|
}
|
|
174
365
|
}
|
|
175
366
|
}
|