@nx/rspack 0.0.0-pr-28808-ae8ea8d → 0.0.0-pr-28808-41aa4e0
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/package.json +5 -4
- 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/schema.d.ts +2 -2
- 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 +47 -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/utils/apply-base-config.js +1 -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/delete-output-path.d.ts +4 -0
- package/src/plugins/utils/delete-output-path.js +15 -0
- 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/module-federation/build-static.remotes.d.ts +1 -1
- package/src/utils/module-federation/public-api.d.ts +1 -6
- package/src/utils/module-federation/public-api.js +1 -14
- package/src/utils/module-federation/with-module-federation/utils.d.ts +3 -3
- package/src/utils/module-federation/with-module-federation/utils.js +8 -10
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.d.ts +1 -1
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.js +1 -1
- package/src/utils/module-federation/with-module-federation/with-module-federation.d.ts +1 -1
- package/src/utils/module-federation/with-module-federation/with-module-federation.js +1 -1
- 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/models/index.js +0 -2
- 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/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/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/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": "0.0.0-pr-28808-
|
|
4
|
+
"version": "0.0.0-pr-28808-41aa4e0",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
"generators": "./generators.json",
|
|
25
25
|
"executors": "./executors.json",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@nx/js": "0.0.0-pr-28808-
|
|
28
|
-
"@nx/devkit": "0.0.0-pr-28808-
|
|
29
|
-
"@nx/web": "0.0.0-pr-28808-
|
|
27
|
+
"@nx/js": "0.0.0-pr-28808-41aa4e0",
|
|
28
|
+
"@nx/devkit": "0.0.0-pr-28808-41aa4e0",
|
|
29
|
+
"@nx/web": "0.0.0-pr-28808-41aa4e0",
|
|
30
|
+
"@nx/module-federation": "0.0.0-pr-28808-41aa4e0",
|
|
30
31
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
31
32
|
"@rspack/core": "^1.0.4",
|
|
32
33
|
"@rspack/dev-server": "^1.0.4",
|
|
@@ -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
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Mode } from '@rspack/core';
|
|
1
|
+
import type { DevTool, Mode } from '@rspack/core';
|
|
2
2
|
|
|
3
3
|
export interface RspackExecutorSchema {
|
|
4
4
|
additionalEntryPoints?: AdditionalEntryPoint[];
|
|
@@ -32,7 +32,7 @@ export interface RspackExecutorSchema {
|
|
|
32
32
|
runtimeChunk?: boolean;
|
|
33
33
|
scripts?: Array<ExtraEntryPointClass | string>;
|
|
34
34
|
skipTypeChecking?: boolean;
|
|
35
|
-
sourceMap?: boolean |
|
|
35
|
+
sourceMap?: boolean | DevTool;
|
|
36
36
|
standardRspackConfigFunction?: boolean;
|
|
37
37
|
statsJson?: boolean;
|
|
38
38
|
stylePreprocessorOptions?: any;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Compiler } from '@rspack/core';
|
|
2
|
+
import type { NxAppRspackPluginOptions } from '../utils/models';
|
|
3
|
+
/**
|
|
4
|
+
* This plugin provides features to build Node and Web applications.
|
|
5
|
+
* - TS Support (including tsconfig paths
|
|
6
|
+
* - Assets handling
|
|
7
|
+
* - Stylesheets handling
|
|
8
|
+
* - index.html and package.json generation
|
|
9
|
+
*
|
|
10
|
+
* Web-only features, such as stylesheets and images, are only supported when `target` is `web` or `webworker`.
|
|
11
|
+
*/
|
|
12
|
+
export declare class NxAppRspackPlugin {
|
|
13
|
+
private readonly options;
|
|
14
|
+
constructor(options?: NxAppRspackPluginOptions);
|
|
15
|
+
apply(compiler: Compiler): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NxAppRspackPlugin = void 0;
|
|
4
|
+
const normalize_options_1 = require("../utils/plugins/normalize-options");
|
|
5
|
+
const apply_base_config_1 = require("../utils/apply-base-config");
|
|
6
|
+
const apply_web_config_1 = require("../utils/apply-web-config");
|
|
7
|
+
const delete_output_path_1 = require("../utils/delete-output-path");
|
|
8
|
+
/**
|
|
9
|
+
* This plugin provides features to build Node and Web applications.
|
|
10
|
+
* - TS Support (including tsconfig paths
|
|
11
|
+
* - Assets handling
|
|
12
|
+
* - Stylesheets handling
|
|
13
|
+
* - index.html and package.json generation
|
|
14
|
+
*
|
|
15
|
+
* Web-only features, such as stylesheets and images, are only supported when `target` is `web` or `webworker`.
|
|
16
|
+
*/
|
|
17
|
+
class NxAppRspackPlugin {
|
|
18
|
+
constructor(options = {}) {
|
|
19
|
+
// If we're building inferred targets, skip normalizing the build options
|
|
20
|
+
if (!global.NX_GRAPH_CREATION) {
|
|
21
|
+
this.options = (0, normalize_options_1.normalizeOptions)(options);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
apply(compiler) {
|
|
25
|
+
// Default's to web
|
|
26
|
+
const target = this.options.target ?? compiler.options.target;
|
|
27
|
+
this.options.outputPath ??= compiler.options.output?.path;
|
|
28
|
+
if (typeof target === 'string') {
|
|
29
|
+
this.options.target = target;
|
|
30
|
+
}
|
|
31
|
+
(0, apply_base_config_1.applyBaseConfig)(this.options, compiler.options, {
|
|
32
|
+
useNormalizedEntry: true,
|
|
33
|
+
});
|
|
34
|
+
if (compiler.options.target) {
|
|
35
|
+
this.options.target = compiler.options.target;
|
|
36
|
+
}
|
|
37
|
+
if (this.options.target === 'web' || this.options.target === 'webworker') {
|
|
38
|
+
(0, apply_web_config_1.applyWebConfig)(this.options, compiler.options, {
|
|
39
|
+
useNormalizedEntry: true,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (this.options.deleteOutputPath) {
|
|
43
|
+
(0, delete_output_path_1.deleteOutputDir)(this.options.root, this.options.outputPath);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.NxAppRspackPlugin = NxAppRspackPlugin;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NxReactRspackPlugin = void 0;
|
|
4
|
+
const apply_react_config_1 = require("../utils/apply-react-config");
|
|
5
|
+
class NxReactRspackPlugin {
|
|
6
|
+
constructor(options = {}) {
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
apply(compiler) {
|
|
10
|
+
(0, apply_react_config_1.applyReactConfig)(this.options, compiler.options);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.NxReactRspackPlugin = NxReactRspackPlugin;
|
|
@@ -59,11 +59,7 @@ function applyNxIndependentConfig(options, config) {
|
|
|
59
59
|
// So to mitigate this we enable in memory caching when target is Node and in watch mode.
|
|
60
60
|
config.cache = options.target === 'node' && options.watch ? true : undefined;
|
|
61
61
|
config.devtool =
|
|
62
|
-
options.sourceMap === '
|
|
63
|
-
? 'hidden-source-map'
|
|
64
|
-
: options.sourceMap
|
|
65
|
-
? 'source-map'
|
|
66
|
-
: false;
|
|
62
|
+
options.sourceMap === true ? 'source-map' : options.sourceMap;
|
|
67
63
|
config.output = {
|
|
68
64
|
...(config.output ?? {}),
|
|
69
65
|
libraryTarget: config.output?.libraryTarget ??
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Configuration } from '@rspack/core';
|
|
1
|
+
import { type Configuration, RspackOptionsNormalized } from '@rspack/core';
|
|
2
2
|
import { NormalizedNxAppRspackPluginOptions } from './models';
|
|
3
|
-
export declare function applyWebConfig(options: NormalizedNxAppRspackPluginOptions, config?: Configuration
|
|
3
|
+
export declare function applyWebConfig(options: NormalizedNxAppRspackPluginOptions, config?: Partial<RspackOptionsNormalized | Configuration>, { useNormalizedEntry, }?: {
|
|
4
4
|
useNormalizedEntry?: boolean;
|
|
5
5
|
}): void;
|
|
@@ -70,13 +70,6 @@ function applyWebConfig(options, config = {}, { useNormalizedEntry, } = {}) {
|
|
|
70
70
|
const resolvedPath = style.input.startsWith('.')
|
|
71
71
|
? style.input
|
|
72
72
|
: (0, path_1.resolve)(options.root, style.input);
|
|
73
|
-
// Add style entry points.
|
|
74
|
-
if (entries[style.bundleName]) {
|
|
75
|
-
entries[style.bundleName].import.push(resolvedPath);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
entries[style.bundleName] = { import: [resolvedPath] };
|
|
79
|
-
}
|
|
80
73
|
// Add global css paths.
|
|
81
74
|
globalStylePaths.push(resolvedPath);
|
|
82
75
|
});
|
|
@@ -290,7 +283,7 @@ function applyWebConfig(options, config = {}, { useNormalizedEntry, } = {}) {
|
|
|
290
283
|
}
|
|
291
284
|
});
|
|
292
285
|
config.optimization = !isProd
|
|
293
|
-
?
|
|
286
|
+
? {}
|
|
294
287
|
: {
|
|
295
288
|
...(config.optimization ?? {}),
|
|
296
289
|
minimizer: [...(config.optimization?.minimizer ?? []), ...minimizer],
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteOutputDir = deleteOutputDir;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
/**
|
|
7
|
+
* Delete an output directory, but error out if it's the root of the project.
|
|
8
|
+
*/
|
|
9
|
+
function deleteOutputDir(root, outputPath) {
|
|
10
|
+
const resolvedOutputPath = (0, path_1.resolve)(root, outputPath);
|
|
11
|
+
if (resolvedOutputPath === root) {
|
|
12
|
+
throw new Error('Output path MUST not be project root directory!');
|
|
13
|
+
}
|
|
14
|
+
(0, fs_1.rmSync)(resolvedOutputPath, { recursive: true, force: true });
|
|
15
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Mode } from '@rspack/core';
|
|
1
|
+
import type { DevTool, Mode } from '@rspack/core';
|
|
2
2
|
import type { ProjectGraph } from '@nx/devkit';
|
|
3
3
|
import type { AssetGlob } from '@nx/js/src/utils/assets/assets';
|
|
4
4
|
export interface SvgrOptions {
|
|
@@ -171,7 +171,7 @@ export interface NxAppRspackPluginOptions {
|
|
|
171
171
|
/**
|
|
172
172
|
* Generate source maps.
|
|
173
173
|
*/
|
|
174
|
-
sourceMap?: boolean |
|
|
174
|
+
sourceMap?: boolean | DevTool;
|
|
175
175
|
/**
|
|
176
176
|
* When `true`, `process.env.NODE_ENV` will be excluded from the bundle. Useful for building a web application to run in a Node environment.
|
|
177
177
|
*/
|
|
@@ -81,7 +81,7 @@ function normalizeOptions(options) {
|
|
|
81
81
|
sourceMap: combinedPluginAndMaybeExecutorOptions.sourceMap ?? !isProd,
|
|
82
82
|
sourceRoot,
|
|
83
83
|
styles: combinedPluginAndMaybeExecutorOptions.styles ?? [],
|
|
84
|
-
target: combinedPluginAndMaybeExecutorOptions.target,
|
|
84
|
+
target: combinedPluginAndMaybeExecutorOptions.target ?? 'web',
|
|
85
85
|
targetName,
|
|
86
86
|
vendorChunk: combinedPluginAndMaybeExecutorOptions.vendorChunk ?? !isProd,
|
|
87
87
|
};
|
|
@@ -16,7 +16,7 @@ class NxTsconfigPathsRspackPlugin {
|
|
|
16
16
|
apply(compiler) {
|
|
17
17
|
// TODO(Colum): Investigate the best way to handle this, currently it is not working and affecting HMR
|
|
18
18
|
// // If we are not building libs from source, we need to remap paths so tsconfig may be updated.
|
|
19
|
-
|
|
19
|
+
this.handleBuildLibsFromSource(compiler.options, this.options);
|
|
20
20
|
const pathToTsconfig = !path.isAbsolute(this.options.tsConfig)
|
|
21
21
|
? path.join(devkit_1.workspaceRoot, this.options.tsConfig)
|
|
22
22
|
: this.options.tsConfig;
|
|
@@ -44,7 +44,8 @@ class NxTsconfigPathsRspackPlugin {
|
|
|
44
44
|
if (!options.buildLibsFromSource && options.targetName) {
|
|
45
45
|
const remappedTarget = options.targetName === 'serve' ? 'build' : options.targetName;
|
|
46
46
|
const { target, dependencies } = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(undefined, options.projectGraph, options.root, options.projectName, remappedTarget, options.configurationName);
|
|
47
|
-
options.tsConfig = (0, buildable_libs_utils_1.createTmpTsConfig)(options.tsConfig, options.root, target.data.root, dependencies
|
|
47
|
+
options.tsConfig = (0, buildable_libs_utils_1.createTmpTsConfig)(options.tsConfig, options.root, target.data.root, dependencies, true // There is an issue with Rspack that requires the baseUrl to be set in the generated tsconfig
|
|
48
|
+
);
|
|
48
49
|
this.tmpTsConfigPath = options.tsConfig;
|
|
49
50
|
if (options.targetName === 'serve') {
|
|
50
51
|
const buildableDependencies = dependencies
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ExecutorContext } from '@nx/devkit';
|
|
2
2
|
import { ModuleFederationDevServerOptions } from '../../executors/module-federation-dev-server/schema';
|
|
3
|
-
import type { StaticRemotesConfig } from '
|
|
3
|
+
import type { StaticRemotesConfig } from '@nx/module-federation/src/utils';
|
|
4
4
|
export declare function buildStaticRemotes(staticRemotesConfig: StaticRemotesConfig, nxBin: any, context: ExecutorContext, options: ModuleFederationDevServerOptions): Promise<Record<string, string>>;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { AdditionalSharedConfig, ModuleFederationConfig, ModuleFederationLibrary, Remotes, SharedFunction, SharedLibraryConfig, SharedWorkspaceLibraryConfig, WorkspaceLibrary, WorkspaceLibrarySecondaryEntryPoint } from './models';
|
|
2
|
-
import { applyAdditionalShared, applySharedFunction, getNpmPackageSharedConfig, sharePackages, shareWorkspaceLibraries } from './share';
|
|
3
|
-
import { mapRemotes, mapRemotesForSSR } from './remotes';
|
|
4
|
-
import { getDependentPackagesForProject } from './dependencies';
|
|
5
|
-
import { readRootPackageJson } from './package-json';
|
|
6
1
|
import { withModuleFederation } from './with-module-federation/with-module-federation';
|
|
7
2
|
import { withModuleFederationForSSR } from './with-module-federation/with-module-federation-ssr';
|
|
8
|
-
export {
|
|
3
|
+
export { withModuleFederation, withModuleFederationForSSR };
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withModuleFederationForSSR = exports.withModuleFederation =
|
|
4
|
-
const share_1 = require("./share");
|
|
5
|
-
Object.defineProperty(exports, "applyAdditionalShared", { enumerable: true, get: function () { return share_1.applyAdditionalShared; } });
|
|
6
|
-
Object.defineProperty(exports, "applySharedFunction", { enumerable: true, get: function () { return share_1.applySharedFunction; } });
|
|
7
|
-
Object.defineProperty(exports, "getNpmPackageSharedConfig", { enumerable: true, get: function () { return share_1.getNpmPackageSharedConfig; } });
|
|
8
|
-
Object.defineProperty(exports, "sharePackages", { enumerable: true, get: function () { return share_1.sharePackages; } });
|
|
9
|
-
Object.defineProperty(exports, "shareWorkspaceLibraries", { enumerable: true, get: function () { return share_1.shareWorkspaceLibraries; } });
|
|
10
|
-
const remotes_1 = require("./remotes");
|
|
11
|
-
Object.defineProperty(exports, "mapRemotes", { enumerable: true, get: function () { return remotes_1.mapRemotes; } });
|
|
12
|
-
Object.defineProperty(exports, "mapRemotesForSSR", { enumerable: true, get: function () { return remotes_1.mapRemotesForSSR; } });
|
|
13
|
-
const dependencies_1 = require("./dependencies");
|
|
14
|
-
Object.defineProperty(exports, "getDependentPackagesForProject", { enumerable: true, get: function () { return dependencies_1.getDependentPackagesForProject; } });
|
|
15
|
-
const package_json_1 = require("./package-json");
|
|
16
|
-
Object.defineProperty(exports, "readRootPackageJson", { enumerable: true, get: function () { return package_json_1.readRootPackageJson; } });
|
|
3
|
+
exports.withModuleFederationForSSR = exports.withModuleFederation = void 0;
|
|
17
4
|
const with_module_federation_1 = require("./with-module-federation/with-module-federation");
|
|
18
5
|
Object.defineProperty(exports, "withModuleFederation", { enumerable: true, get: function () { return with_module_federation_1.withModuleFederation; } });
|
|
19
6
|
const with_module_federation_ssr_1 = require("./with-module-federation/with-module-federation-ssr");
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ModuleFederationConfig } from '
|
|
1
|
+
import { ModuleFederationConfig } from '@nx/module-federation';
|
|
2
2
|
export declare function getFunctionDeterminateRemoteUrl(isServer?: boolean): (remote: string) => string;
|
|
3
3
|
export declare function getModuleFederationConfig(mfConfig: ModuleFederationConfig, options?: {
|
|
4
4
|
isServer: boolean;
|
|
5
5
|
determineRemoteUrl?: (remote: string) => string;
|
|
6
6
|
}): Promise<{
|
|
7
|
-
sharedLibraries: import("
|
|
7
|
+
sharedLibraries: import("@nx/module-federation").SharedWorkspaceLibraryConfig;
|
|
8
8
|
sharedDependencies: {
|
|
9
|
-
[x: string]: import("
|
|
9
|
+
[x: string]: import("@nx/module-federation").SharedLibraryConfig;
|
|
10
10
|
};
|
|
11
11
|
mappedRemotes: {};
|
|
12
12
|
}>;
|
|
@@ -4,9 +4,7 @@ exports.getFunctionDeterminateRemoteUrl = getFunctionDeterminateRemoteUrl;
|
|
|
4
4
|
exports.getModuleFederationConfig = getModuleFederationConfig;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const project_graph_1 = require("nx/src/project-graph/project-graph");
|
|
7
|
-
const
|
|
8
|
-
const remotes_1 = require("../remotes");
|
|
9
|
-
const share_1 = require("../share");
|
|
7
|
+
const module_federation_1 = require("@nx/module-federation");
|
|
10
8
|
function getFunctionDeterminateRemoteUrl(isServer = false) {
|
|
11
9
|
const target = 'serve';
|
|
12
10
|
const remoteEntry = isServer ? 'server/remoteEntry.js' : 'remoteEntry.js';
|
|
@@ -48,21 +46,21 @@ async function getModuleFederationConfig(mfConfig, options = { isServer: false }
|
|
|
48
46
|
if (!project) {
|
|
49
47
|
throw Error(`Cannot find project "${mfConfig.name}". Check that the name is correct in module-federation.config.js`);
|
|
50
48
|
}
|
|
51
|
-
const dependencies = (0,
|
|
49
|
+
const dependencies = (0, module_federation_1.getDependentPackagesForProject)(projectGraph, mfConfig.name);
|
|
52
50
|
if (mfConfig.shared) {
|
|
53
51
|
dependencies.workspaceLibraries = dependencies.workspaceLibraries.filter((lib) => mfConfig.shared(lib.importKey, {}) !== false);
|
|
54
52
|
dependencies.npmPackages = dependencies.npmPackages.filter((pkg) => mfConfig.shared(pkg, {}) !== false);
|
|
55
53
|
}
|
|
56
|
-
const sharedLibraries = (0,
|
|
57
|
-
const npmPackages = (0,
|
|
54
|
+
const sharedLibraries = (0, module_federation_1.shareWorkspaceLibraries)(dependencies.workspaceLibraries);
|
|
55
|
+
const npmPackages = (0, module_federation_1.sharePackages)(dependencies.npmPackages);
|
|
58
56
|
const sharedDependencies = {
|
|
59
57
|
...sharedLibraries.getLibraries(project.root),
|
|
60
58
|
...npmPackages,
|
|
61
59
|
};
|
|
62
|
-
(0,
|
|
63
|
-
(0,
|
|
60
|
+
(0, module_federation_1.applySharedFunction)(sharedDependencies, mfConfig.shared);
|
|
61
|
+
(0, module_federation_1.applyAdditionalShared)(sharedDependencies, mfConfig.additionalShared, projectGraph);
|
|
64
62
|
// Choose the correct mapRemotes function based on the server state.
|
|
65
|
-
const mapRemotesFunction = options.isServer ?
|
|
63
|
+
const mapRemotesFunction = options.isServer ? module_federation_1.mapRemotesForSSR : module_federation_1.mapRemotes;
|
|
66
64
|
// Determine the URL function, either from provided options or by using a default.
|
|
67
65
|
const determineRemoteUrlFunction = options.determineRemoteUrl
|
|
68
66
|
? options.determineRemoteUrl
|
|
@@ -70,7 +68,7 @@ async function getModuleFederationConfig(mfConfig, options = { isServer: false }
|
|
|
70
68
|
// Map the remotes if they exist, otherwise default to an empty object.
|
|
71
69
|
let mappedRemotes = {};
|
|
72
70
|
if (mfConfig.remotes && mfConfig.remotes.length > 0) {
|
|
73
|
-
mappedRemotes = mapRemotesFunction(mfConfig.remotes, 'js', determineRemoteUrlFunction);
|
|
71
|
+
mappedRemotes = mapRemotesFunction(mfConfig.remotes, 'js', determineRemoteUrlFunction, true);
|
|
74
72
|
}
|
|
75
73
|
return { sharedLibraries, sharedDependencies, mappedRemotes };
|
|
76
74
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ModuleFederationConfig, NxModuleFederationConfigOverride } from '
|
|
1
|
+
import { ModuleFederationConfig, NxModuleFederationConfigOverride } from '@nx/module-federation';
|
|
2
2
|
import { NxRspackExecutionContext } from '../../config';
|
|
3
3
|
export declare function withModuleFederationForSSR(options: ModuleFederationConfig, configOverride?: NxModuleFederationConfigOverride): Promise<(config: any, { context }: NxRspackExecutionContext) => any>;
|
|
@@ -44,7 +44,7 @@ async function withModuleFederationForSSR(options, configOverride) {
|
|
|
44
44
|
? [
|
|
45
45
|
...(configOverride?.runtimePlugins ?? []),
|
|
46
46
|
require.resolve('@module-federation/node/runtimePlugin'),
|
|
47
|
-
require.resolve('@nx/
|
|
47
|
+
require.resolve('@nx/module-federation/src/utils/plugins/runtime-library-control.plugin.js'),
|
|
48
48
|
]
|
|
49
49
|
: [
|
|
50
50
|
...(configOverride?.runtimePlugins ?? []),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Configuration } from '@rspack/core';
|
|
2
|
-
import { ModuleFederationConfig, NxModuleFederationConfigOverride } from '
|
|
2
|
+
import { ModuleFederationConfig, NxModuleFederationConfigOverride } from '@nx/module-federation';
|
|
3
3
|
import { NxRspackExecutionContext } from '../../config';
|
|
4
4
|
/**
|
|
5
5
|
* @param {ModuleFederationConfig} options
|
|
@@ -55,7 +55,7 @@ async function withModuleFederation(options, configOverride) {
|
|
|
55
55
|
!options.disableNxRuntimeLibraryControlPlugin
|
|
56
56
|
? [
|
|
57
57
|
...(configOverride?.runtimePlugins ?? []),
|
|
58
|
-
require.resolve('@nx/
|
|
58
|
+
require.resolve('@nx/module-federation/src/utils/plugins/runtime-library-control.plugin.js'),
|
|
59
59
|
]
|
|
60
60
|
: configOverride?.runtimePlugins,
|
|
61
61
|
virtualRuntimeEntry: true,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ProjectGraph } from '@nx/devkit';
|
|
2
|
-
import type { WorkspaceLibrary } from './models';
|
|
3
|
-
export declare function getDependentPackagesForProject(projectGraph: ProjectGraph, name: string): {
|
|
4
|
-
workspaceLibraries: WorkspaceLibrary[];
|
|
5
|
-
npmPackages: string[];
|
|
6
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDependentPackagesForProject = getDependentPackagesForProject;
|
|
4
|
-
const typescript_1 = require("./typescript");
|
|
5
|
-
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
function getDependentPackagesForProject(projectGraph, name) {
|
|
7
|
-
const { npmPackages, workspaceLibraries } = collectDependencies(projectGraph, name);
|
|
8
|
-
return {
|
|
9
|
-
workspaceLibraries: [...workspaceLibraries.values()],
|
|
10
|
-
npmPackages: [...npmPackages],
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function collectDependencies(projectGraph, name, dependencies = {
|
|
14
|
-
workspaceLibraries: new Map(),
|
|
15
|
-
npmPackages: new Set(),
|
|
16
|
-
}, seen = new Set()) {
|
|
17
|
-
if (seen.has(name)) {
|
|
18
|
-
return dependencies;
|
|
19
|
-
}
|
|
20
|
-
seen.add(name);
|
|
21
|
-
(projectGraph.dependencies[name] ?? []).forEach((dependency) => {
|
|
22
|
-
if (dependency.target.startsWith('npm:')) {
|
|
23
|
-
dependencies.npmPackages.add(dependency.target.replace('npm:', ''));
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
dependencies.workspaceLibraries.set(dependency.target, {
|
|
27
|
-
name: dependency.target,
|
|
28
|
-
root: projectGraph.nodes[dependency.target].data.root,
|
|
29
|
-
importKey: getLibraryImportPath(dependency.target, projectGraph),
|
|
30
|
-
});
|
|
31
|
-
collectDependencies(projectGraph, dependency.target, dependencies, seen);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return dependencies;
|
|
35
|
-
}
|
|
36
|
-
function getLibraryImportPath(library, projectGraph) {
|
|
37
|
-
let buildLibsFromSource = true;
|
|
38
|
-
if (process.env.NX_BUILD_LIBS_FROM_SOURCE) {
|
|
39
|
-
buildLibsFromSource = process.env.NX_BUILD_LIBS_FROM_SOURCE === 'true';
|
|
40
|
-
}
|
|
41
|
-
const libraryNode = projectGraph.nodes[library];
|
|
42
|
-
let sourceRoots = [libraryNode.data.sourceRoot];
|
|
43
|
-
if (!buildLibsFromSource && process.env.NX_BUILD_TARGET) {
|
|
44
|
-
const buildTarget = (0, devkit_1.parseTargetString)(process.env.NX_BUILD_TARGET, projectGraph);
|
|
45
|
-
sourceRoots = (0, devkit_1.getOutputsForTargetAndConfiguration)(buildTarget, {}, libraryNode);
|
|
46
|
-
}
|
|
47
|
-
const tsConfigPathMappings = (0, typescript_1.readTsPathMappings)();
|
|
48
|
-
for (const [key, value] of Object.entries(tsConfigPathMappings)) {
|
|
49
|
-
for (const src of sourceRoots) {
|
|
50
|
-
if (value.find((path) => path.startsWith(src))) {
|
|
51
|
-
return key;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type ProjectGraph } from '@nx/devkit';
|
|
2
|
-
import { ModuleFederationConfig } from './models';
|
|
3
|
-
interface ModuleFederationExecutorContext {
|
|
4
|
-
projectName: string;
|
|
5
|
-
projectGraph: ProjectGraph;
|
|
6
|
-
root: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function getRemotes(devRemotes: string[], skipRemotes: string[], config: ModuleFederationConfig, context: ModuleFederationExecutorContext, pathToManifestFile?: string): {
|
|
9
|
-
staticRemotes: string[];
|
|
10
|
-
devRemotes: any[];
|
|
11
|
-
dynamicRemotes: any[];
|
|
12
|
-
remotePorts: any[];
|
|
13
|
-
staticRemotePort: number;
|
|
14
|
-
};
|
|
15
|
-
export declare function getModuleFederationConfig(tsconfigPath: string, workspaceRoot: string, projectRoot: string, pluginName?: 'react' | 'angular'): any;
|
|
16
|
-
export {};
|