@nx/rspack 21.3.0-beta.3 → 21.3.0-beta.5
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 +5 -5
- package/src/executors/dev-server/dev-server.impl.js +3 -2
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +3 -3
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +6 -6
- 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 +8 -7
- package/src/executors/rspack/rspack.impl.js +3 -2
- package/src/plugins/utils/apply-web-config.js +5 -4
- package/src/plugins/utils/plugins/normalize-options.d.ts +1 -1
- package/src/plugins/utils/plugins/normalize-options.js +4 -3
- package/src/utils/config.js +2 -1
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": "21.3.0-beta.
|
|
4
|
+
"version": "21.3.0-beta.5",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"generators": "./generators.json",
|
|
25
25
|
"executors": "./executors.json",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@nx/js": "21.3.0-beta.
|
|
28
|
-
"@nx/devkit": "21.3.0-beta.
|
|
29
|
-
"@nx/web": "21.3.0-beta.
|
|
30
|
-
"@nx/module-federation": "21.3.0-beta.
|
|
27
|
+
"@nx/js": "21.3.0-beta.5",
|
|
28
|
+
"@nx/devkit": "21.3.0-beta.5",
|
|
29
|
+
"@nx/web": "21.3.0-beta.5",
|
|
30
|
+
"@nx/module-federation": "21.3.0-beta.5",
|
|
31
31
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
32
32
|
"@rspack/core": "^1.3.8",
|
|
33
33
|
"@rspack/dev-server": "^1.1.1",
|
|
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = runExecutor;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
6
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
6
7
|
const dev_server_1 = require("@rspack/dev-server");
|
|
7
8
|
const create_compiler_1 = require("../../utils/create-compiler");
|
|
8
9
|
const mode_utils_1 = require("../../utils/mode-utils");
|
|
9
|
-
const get_dev_server_config_1 = require("./lib/get-dev-server-config");
|
|
10
10
|
const normalize_options_1 = require("../rspack/lib/normalize-options");
|
|
11
|
+
const get_dev_server_config_1 = require("./lib/get-dev-server-config");
|
|
11
12
|
async function* runExecutor(options, context) {
|
|
12
13
|
process.env.NODE_ENV ??= options.mode ?? 'development';
|
|
13
14
|
if ((0, mode_utils_1.isMode)(process.env.NODE_ENV)) {
|
|
@@ -18,7 +19,7 @@ async function* runExecutor(options, context) {
|
|
|
18
19
|
process.env.NX_BUILD_LIBS_FROM_SOURCE = `${buildOptions.buildLibsFromSource}`;
|
|
19
20
|
process.env.NX_BUILD_TARGET = options.buildTarget;
|
|
20
21
|
const metadata = context.projectsConfigurations.projects[context.projectName];
|
|
21
|
-
const sourceRoot = metadata
|
|
22
|
+
const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(metadata);
|
|
22
23
|
const normalizedBuildOptions = (0, normalize_options_1.normalizeOptions)(buildOptions, context.root, metadata.root, sourceRoot);
|
|
23
24
|
let devServerConfig = (0, get_dev_server_config_1.getDevServerOptions)(context.root, options, normalizedBuildOptions);
|
|
24
25
|
const compiler = await (0, create_compiler_1.createCompiler)({
|
|
@@ -4,11 +4,12 @@ exports.default = moduleFederationDevServer;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
7
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
|
+
const utils_1 = require("@nx/module-federation/src/executors/utils");
|
|
7
9
|
const file_server_impl_1 = tslib_1.__importDefault(require("@nx/web/src/executors/file-server/file-server.impl"));
|
|
8
10
|
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
|
9
11
|
const fs_1 = require("fs");
|
|
10
12
|
const path_1 = require("path");
|
|
11
|
-
const utils_1 = require("@nx/module-federation/src/executors/utils");
|
|
12
13
|
const dev_server_impl_1 = tslib_1.__importDefault(require("../dev-server/dev-server.impl"));
|
|
13
14
|
const lib_1 = require("./lib");
|
|
14
15
|
async function* moduleFederationDevServer(schema, context) {
|
|
@@ -24,8 +25,7 @@ async function* moduleFederationDevServer(schema, context) {
|
|
|
24
25
|
}, context)
|
|
25
26
|
: (0, dev_server_impl_1.default)(options, context);
|
|
26
27
|
const p = context.projectsConfigurations.projects[context.projectName];
|
|
27
|
-
|
|
28
|
-
let pathToManifestFile = (0, path_1.join)(context.root, p.sourceRoot, 'assets/module-federation.manifest.json');
|
|
28
|
+
let pathToManifestFile = (0, path_1.join)(context.root, (0, ts_solution_setup_1.getProjectSourceRoot)(p), 'assets/module-federation.manifest.json');
|
|
29
29
|
if (options.pathToManifestFile) {
|
|
30
30
|
const userPathToManifestFile = (0, path_1.join)(context.root, options.pathToManifestFile);
|
|
31
31
|
if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
|
package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js
CHANGED
|
@@ -3,19 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = moduleFederationSsrDevServer;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const utils_1 = require("@nx/module-federation/src/executors/utils");
|
|
8
|
-
const ssr_dev_server_impl_1 = tslib_1.__importDefault(require("../ssr-dev-server/ssr-dev-server.impl"));
|
|
9
6
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
10
|
-
const
|
|
7
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
|
+
const utils_1 = require("@nx/module-federation/src/executors/utils");
|
|
11
9
|
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
const ssr_dev_server_impl_1 = tslib_1.__importDefault(require("../ssr-dev-server/ssr-dev-server.impl"));
|
|
12
13
|
const lib_1 = require("./lib");
|
|
13
14
|
async function* moduleFederationSsrDevServer(ssrDevServerOptions, context) {
|
|
14
15
|
const options = (0, lib_1.normalizeOptions)(ssrDevServerOptions);
|
|
15
16
|
const iter = (0, ssr_dev_server_impl_1.default)(options, context);
|
|
16
17
|
const projectConfig = context.projectsConfigurations.projects[context.projectName];
|
|
17
|
-
|
|
18
|
-
let pathToManifestFile = (0, path_1.join)(context.root, projectConfig.sourceRoot, 'assets/module-federation.manifest.json');
|
|
18
|
+
let pathToManifestFile = (0, path_1.join)(context.root, (0, ts_solution_setup_1.getProjectSourceRoot)(projectConfig), 'assets/module-federation.manifest.json');
|
|
19
19
|
if (options.pathToManifestFile) {
|
|
20
20
|
const userPathToManifestFile = (0, path_1.join)(context.root, options.pathToManifestFile);
|
|
21
21
|
if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
|
package/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExecutorContext } from 'nx/src/config/misc-interfaces';
|
|
2
1
|
import { StaticRemotesConfig } from '@nx/module-federation/src/utils';
|
|
2
|
+
import { ExecutorContext } from 'nx/src/config/misc-interfaces';
|
|
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
|
@@ -5,19 +5,20 @@ exports.default = moduleFederationStaticServer;
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
7
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
8
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
9
|
+
const utils_1 = require("@nx/module-federation/src/executors/utils");
|
|
10
|
+
const utils_2 = require("@nx/module-federation/src/utils");
|
|
8
11
|
const file_server_impl_1 = tslib_1.__importDefault(require("@nx/web/src/executors/file-server/file-server.impl"));
|
|
9
12
|
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
|
10
13
|
const child_process_1 = require("child_process");
|
|
11
14
|
const fs_1 = require("fs");
|
|
12
15
|
const path_1 = require("path");
|
|
13
|
-
const utils_1 = require("@nx/module-federation/src/utils");
|
|
14
|
-
const utils_2 = require("@nx/module-federation/src/executors/utils");
|
|
15
16
|
function getBuildAndServeOptionsFromServeTarget(serveTarget, context) {
|
|
16
17
|
const target = (0, devkit_1.parseTargetString)(serveTarget, context);
|
|
17
18
|
const serveOptions = (0, devkit_1.readTargetOptions)(target, context);
|
|
18
19
|
const buildTarget = (0, devkit_1.parseTargetString)(serveOptions.buildTarget, context);
|
|
19
20
|
const buildOptions = (0, devkit_1.readTargetOptions)(buildTarget, context);
|
|
20
|
-
let pathToManifestFile = (0, path_1.join)(context.root, context.projectGraph.nodes[context.projectName].data
|
|
21
|
+
let pathToManifestFile = (0, path_1.join)(context.root, (0, ts_solution_setup_1.getProjectSourceRoot)(context.projectGraph.nodes[context.projectName].data), 'assets/module-federation.manifest.json');
|
|
21
22
|
if (serveOptions.pathToManifestFile) {
|
|
22
23
|
const userPathToManifestFile = (0, path_1.join)(context.root, serveOptions.pathToManifestFile);
|
|
23
24
|
if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
|
|
@@ -169,15 +170,15 @@ async function* moduleFederationStaticServer(schema, context) {
|
|
|
169
170
|
// Get the remotes from the module federation config
|
|
170
171
|
const p = context.projectsConfigurations.projects[context.projectName];
|
|
171
172
|
const options = getBuildAndServeOptionsFromServeTarget(schema.serveTarget, context);
|
|
172
|
-
const moduleFederationConfig = (0,
|
|
173
|
-
const remotes = (0,
|
|
173
|
+
const moduleFederationConfig = (0, utils_2.getModuleFederationConfig)(options.buildOptions.tsConfig, context.root, p.root, 'react');
|
|
174
|
+
const remotes = (0, utils_2.getRemotes)([], options.serveOptions.skipRemotes, moduleFederationConfig, {
|
|
174
175
|
projectName: context.projectName,
|
|
175
176
|
projectGraph: context.projectGraph,
|
|
176
177
|
root: context.root,
|
|
177
178
|
}, options.pathToManifestFile);
|
|
178
|
-
const staticRemotesConfig = (0,
|
|
179
|
+
const staticRemotesConfig = (0, utils_2.parseStaticRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
|
|
179
180
|
options.serveOptions.staticRemotesPort ??= remotes.staticRemotePort;
|
|
180
|
-
const mappedLocationsOfStaticRemotes = await (0,
|
|
181
|
+
const mappedLocationsOfStaticRemotes = await (0, utils_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options.serveOptions);
|
|
181
182
|
// Build the host
|
|
182
183
|
const hostUrlSegment = (0, path_1.basename)(options.buildOptions.outputPath);
|
|
183
184
|
const mappedLocationOfHost = `http${options.serveOptions.ssl ? 's' : ''}://${options.serveOptions.host}:${options.serveOptions.staticRemotesPort}/${hostUrlSegment}`;
|
|
@@ -4,16 +4,17 @@ exports.default = runExecutor;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
6
6
|
const js_1 = require("@nx/js");
|
|
7
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
7
8
|
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
8
10
|
const create_compiler_1 = require("../../utils/create-compiler");
|
|
9
11
|
const mode_utils_1 = require("../../utils/mode-utils");
|
|
10
12
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
11
|
-
const path_1 = require("path");
|
|
12
13
|
async function* runExecutor(options, context) {
|
|
13
14
|
process.env.NODE_ENV ??= options.mode ?? 'production';
|
|
14
15
|
options.target ??= 'web';
|
|
15
16
|
const metadata = context.projectsConfigurations.projects[context.projectName];
|
|
16
|
-
const sourceRoot = metadata
|
|
17
|
+
const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(metadata);
|
|
17
18
|
const normalizedOptions = (0, normalize_options_1.normalizeOptions)(options, context.root, metadata.root, sourceRoot);
|
|
18
19
|
if ((0, mode_utils_1.isMode)(process.env.NODE_ENV)) {
|
|
19
20
|
normalizedOptions.mode = process.env.NODE_ENV;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.applyWebConfig = applyWebConfig;
|
|
4
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
4
5
|
const core_1 = require("@rspack/core");
|
|
5
|
-
const write_index_html_plugin_1 = require("../write-index-html-plugin");
|
|
6
|
-
const instantiate_script_plugins_1 = require("./instantiate-script-plugins");
|
|
7
6
|
const path_1 = require("path");
|
|
7
|
+
const write_index_html_plugin_1 = require("../write-index-html-plugin");
|
|
8
8
|
const hash_format_1 = require("./hash-format");
|
|
9
|
-
const
|
|
9
|
+
const instantiate_script_plugins_1 = require("./instantiate-script-plugins");
|
|
10
10
|
const stylesheet_loaders_1 = require("./loaders/stylesheet-loaders");
|
|
11
|
+
const normalize_entry_1 = require("./normalize-entry");
|
|
11
12
|
function applyWebConfig(options, config = {}, { useNormalizedEntry, } = {}) {
|
|
12
13
|
if (global.NX_GRAPH_CREATION)
|
|
13
14
|
return;
|
|
@@ -17,7 +18,7 @@ function applyWebConfig(options, config = {}, { useNormalizedEntry, } = {}) {
|
|
|
17
18
|
options.generateIndexHtml ??= true;
|
|
18
19
|
options.index = options.index
|
|
19
20
|
? (0, path_1.join)(options.root, options.index)
|
|
20
|
-
: (0, path_1.join)(options.root, options.projectGraph.nodes[options.projectName].data
|
|
21
|
+
: (0, path_1.join)(options.root, (0, ts_solution_setup_1.getProjectSourceRoot)(options.projectGraph.nodes[options.projectName].data), 'index.html');
|
|
21
22
|
options.styles ??= [];
|
|
22
23
|
options.scripts ??= [];
|
|
23
24
|
const isProd = process.env.NODE_ENV === 'production' || options.mode === 'production';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetGlobPattern, FileReplacement,
|
|
1
|
+
import { AssetGlobPattern, FileReplacement, NormalizedNxAppRspackPluginOptions, NxAppRspackPluginOptions } from '../models';
|
|
2
2
|
export declare function normalizeOptions(options: NxAppRspackPluginOptions): NormalizedNxAppRspackPluginOptions;
|
|
3
3
|
export declare function normalizeAssets(assets: any[], root: string, sourceRoot: string, projectRoot: string, resolveRelativePathsToProjectRoot?: boolean): AssetGlobPattern[];
|
|
4
4
|
export declare function normalizeFileReplacements(root: string, fileReplacements: FileReplacement[]): FileReplacement[];
|
|
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.normalizeOptions = normalizeOptions;
|
|
4
4
|
exports.normalizeAssets = normalizeAssets;
|
|
5
5
|
exports.normalizeFileReplacements = normalizeFileReplacements;
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
9
10
|
function normalizeOptions(options) {
|
|
10
11
|
const combinedPluginAndMaybeExecutorOptions = {};
|
|
11
12
|
const isProd = process.env.NODE_ENV === 'production';
|
|
@@ -48,7 +49,7 @@ function normalizeOptions(options) {
|
|
|
48
49
|
// executor options take precedence (especially for overriding with CLI args)
|
|
49
50
|
originalTargetOptions);
|
|
50
51
|
}
|
|
51
|
-
const sourceRoot =
|
|
52
|
+
const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(projectNode.data);
|
|
52
53
|
if (!combinedPluginAndMaybeExecutorOptions.main) {
|
|
53
54
|
throw new Error(`Missing "main" option for the entry file. Set this option in your Nx rspack plugin.`);
|
|
54
55
|
}
|
package/src/utils/config.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.isNxRspackComposablePlugin = isNxRspackComposablePlugin;
|
|
|
5
5
|
exports.composePlugins = composePlugins;
|
|
6
6
|
exports.composePluginsSync = composePluginsSync;
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
9
|
const configuration_1 = require("nx/src/config/configuration");
|
|
9
10
|
exports.nxRspackComposablePlugin = 'nxRspackComposablePlugin';
|
|
10
11
|
function isNxRspackComposablePlugin(a) {
|
|
@@ -49,7 +50,7 @@ function ensureNxRspackExecutionContext(ctx) {
|
|
|
49
50
|
ctx.options ??= {
|
|
50
51
|
root: devkit_1.workspaceRoot,
|
|
51
52
|
projectRoot: projectNode.data.root,
|
|
52
|
-
sourceRoot:
|
|
53
|
+
sourceRoot: (0, ts_solution_setup_1.getProjectSourceRoot)(projectNode.data),
|
|
53
54
|
// These aren't actually needed since NxRspackPlugin and withNx both support them being undefined.
|
|
54
55
|
assets: undefined,
|
|
55
56
|
outputFileName: undefined,
|