@nx/rspack 24.0.0-beta.2 → 24.0.0-beta.4
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/dist/ready-check.d.ts +1 -0
- package/dist/ready-check.js +9 -0
- package/dist/ready-signal.d.ts +1 -0
- package/dist/ready-signal.js +5 -0
- package/dist/src/executors/dev-server/dev-server.impl.js +0 -2
- package/dist/src/executors/rspack/lib/config.js +18 -8
- package/dist/src/generators/configuration/configuration.js +5 -29
- package/dist/src/generators/configuration/schema.json +2 -2
- package/dist/src/generators/convert-config-to-rspack-plugin/convert-config-to-rspack-plugin.js +78 -45
- package/dist/src/generators/convert-config-to-rspack-plugin/lib/extract-rspack-options.d.ts +1 -0
- package/dist/src/generators/convert-config-to-rspack-plugin/lib/extract-rspack-options.js +31 -2
- package/dist/src/generators/convert-config-to-rspack-plugin/schema.json +2 -2
- package/dist/src/generators/convert-to-inferred/convert-to-inferred.js +5 -4
- package/dist/src/generators/convert-to-inferred/utils/build-post-target-transformer.js +13 -5
- package/dist/src/generators/convert-to-inferred/utils/serve-post-target-transformer.js +8 -14
- package/dist/src/generators/convert-webpack/convert-webpack.js +20 -74
- package/dist/src/generators/convert-webpack/lib/transform-plugin-config.d.ts +1 -1
- package/dist/src/generators/convert-webpack/lib/transform-plugin-config.js +47 -69
- package/dist/src/generators/init/init.js +38 -44
- package/dist/src/generators/init/schema.d.ts +0 -1
- package/dist/src/migrations/update-24-0-0/finish-inferred-conversion.md +11 -0
- package/dist/src/migrations/update-24-0-0/inventory.d.ts +9 -0
- package/dist/src/migrations/update-24-0-0/inventory.js +53 -0
- package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.d.ts +10 -0
- package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.js +60 -0
- package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.md +95 -0
- package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.d.ts +6 -0
- package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.js +36 -0
- package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.md +90 -0
- package/dist/src/plugins/nx-app-rspack-plugin/nx-app-rspack-plugin.d.ts +2 -0
- package/dist/src/plugins/nx-app-rspack-plugin/nx-app-rspack-plugin.js +10 -1
- package/dist/src/plugins/plugin.js +21 -0
- package/dist/src/utils/config.d.ts +10 -14
- package/dist/src/utils/config.js +17 -70
- package/dist/src/utils/deprecation.d.ts +1 -6
- package/dist/src/utils/deprecation.js +4 -23
- package/dist/src/utils/dev-server-ready-check.d.ts +48 -0
- package/dist/src/utils/dev-server-ready-check.js +339 -0
- package/dist/src/utils/dev-server-ready-signal.d.ts +29 -0
- package/dist/src/utils/dev-server-ready-signal.js +60 -0
- package/dist/src/utils/e2e-web-server-info-utils.d.ts +1 -1
- package/dist/src/utils/e2e-web-server-info-utils.js +2 -2
- package/dist/src/utils/generator-utils.d.ts +1 -2
- package/dist/src/utils/generator-utils.js +69 -185
- package/dist/src/utils/read-rspack-options.d.ts +1 -1
- package/dist/src/utils/read-rspack-options.js +4 -4
- package/dist/src/utils/with-nx.d.ts +5 -9
- package/dist/src/utils/with-nx.js +5 -32
- package/dist/src/utils/with-react.d.ts +5 -8
- package/dist/src/utils/with-react.js +5 -15
- package/dist/src/utils/with-web.d.ts +5 -8
- package/dist/src/utils/with-web.js +5 -44
- package/executors.json +0 -25
- package/migrations.json +13 -0
- package/package.json +39 -26
- package/dist/module-federation.d.ts +0 -4
- package/dist/module-federation.js +0 -9
- package/dist/src/executors/module-federation-dev-server/lib/index.d.ts +0 -2
- package/dist/src/executors/module-federation-dev-server/lib/index.js +0 -5
- package/dist/src/executors/module-federation-dev-server/lib/normalize-options.d.ts +0 -4
- package/dist/src/executors/module-federation-dev-server/lib/normalize-options.js +0 -19
- package/dist/src/executors/module-federation-dev-server/lib/start-remotes.d.ts +0 -5
- package/dist/src/executors/module-federation-dev-server/lib/start-remotes.js +0 -33
- package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +0 -6
- package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +0 -74
- package/dist/src/executors/module-federation-dev-server/schema.d.ts +0 -25
- package/dist/src/executors/module-federation-dev-server/schema.json +0 -104
- package/dist/src/executors/module-federation-ssr-dev-server/lib/index.d.ts +0 -2
- package/dist/src/executors/module-federation-ssr-dev-server/lib/index.js +0 -5
- package/dist/src/executors/module-federation-ssr-dev-server/lib/normalize-options.d.ts +0 -4
- package/dist/src/executors/module-federation-ssr-dev-server/lib/normalize-options.js +0 -23
- package/dist/src/executors/module-federation-ssr-dev-server/lib/start-remotes.d.ts +0 -5
- package/dist/src/executors/module-federation-ssr-dev-server/lib/start-remotes.js +0 -34
- package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +0 -5
- package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +0 -65
- package/dist/src/executors/module-federation-ssr-dev-server/schema.d.ts +0 -29
- package/dist/src/executors/module-federation-ssr-dev-server/schema.json +0 -85
- package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts +0 -12
- package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.js +0 -237
- package/dist/src/executors/module-federation-static-server/schema.d.ts +0 -3
- package/dist/src/executors/module-federation-static-server/schema.json +0 -16
- package/dist/src/executors/rspack/rspack.impl.d.ts +0 -7
- package/dist/src/executors/rspack/rspack.impl.js +0 -127
- package/dist/src/executors/rspack/schema.json +0 -410
- package/dist/src/generators/convert-webpack/lib/transform-cjs.d.ts +0 -2
- package/dist/src/generators/convert-webpack/lib/transform-cjs.js +0 -263
- package/dist/src/generators/convert-webpack/lib/transform-esm.d.ts +0 -2
- package/dist/src/generators/convert-webpack/lib/transform-esm.js +0 -263
- package/dist/src/utils/has-plugin.d.ts +0 -2
- package/dist/src/utils/has-plugin.js +0 -10
- package/dist/src/utils/module-federation-deprecation.d.ts +0 -6
- package/dist/src/utils/module-federation-deprecation.js +0 -30
|
@@ -2,73 +2,51 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformPluginConfig = transformPluginConfig;
|
|
4
4
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
5
|
-
function transformPluginConfig(tree,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
const importNode = nodes[0];
|
|
54
|
-
webpackConfigContents = `${webpackConfigContents.slice(0, importNode.getStart())}'@nx/rspack/app-plugin'${webpackConfigContents.slice(importNode.getEnd())}`;
|
|
55
|
-
// Convert import { NxAppWebpackPlugin } to import { NxAppRspackPlugin }
|
|
56
|
-
sourceFile = (0, tsquery_1.ast)(webpackConfigContents);
|
|
57
|
-
const WEBPACK_APP_IMPORT_SPECIFIER_SELECTOR = 'ImportSpecifier > Identifier[name=NxAppWebpackPlugin]';
|
|
58
|
-
nodes = (0, tsquery_1.query)(sourceFile, WEBPACK_APP_IMPORT_SPECIFIER_SELECTOR);
|
|
59
|
-
if (nodes.length === 0) {
|
|
60
|
-
return webpackConfigContents;
|
|
61
|
-
}
|
|
62
|
-
const importSpecifier = nodes[0];
|
|
63
|
-
webpackConfigContents = `${webpackConfigContents.slice(0, importSpecifier.getStart())}NxAppRspackPlugin${webpackConfigContents.slice(importSpecifier.getEnd())}`;
|
|
64
|
-
// Convert new NxAppWebpackPlugin() to new NxAppRspackPlugin()
|
|
65
|
-
sourceFile = (0, tsquery_1.ast)(webpackConfigContents);
|
|
66
|
-
const WEBPACK_APP_INSTANTIATION_SELECTOR = 'NewExpression > Identifier[name=NxAppWebpackPlugin]';
|
|
67
|
-
nodes = (0, tsquery_1.query)(sourceFile, WEBPACK_APP_INSTANTIATION_SELECTOR);
|
|
68
|
-
if (nodes.length === 0) {
|
|
69
|
-
return webpackConfigContents;
|
|
70
|
-
}
|
|
71
|
-
const instantiation = nodes[0];
|
|
72
|
-
webpackConfigContents = `${webpackConfigContents.slice(0, instantiation.getStart())}NxAppRspackPlugin${webpackConfigContents.slice(instantiation.getEnd())}`;
|
|
73
|
-
return webpackConfigContents;
|
|
5
|
+
function transformPluginConfig(tree, configPath) {
|
|
6
|
+
let contents = tree.read(configPath, 'utf-8');
|
|
7
|
+
const sourceFile = (0, tsquery_1.ast)(contents);
|
|
8
|
+
const replacements = [];
|
|
9
|
+
for (const [source, destination, fromClass, toClass] of [
|
|
10
|
+
[
|
|
11
|
+
'@nx/webpack/app-plugin',
|
|
12
|
+
'@nx/rspack/app-plugin',
|
|
13
|
+
'NxAppWebpackPlugin',
|
|
14
|
+
'NxAppRspackPlugin',
|
|
15
|
+
],
|
|
16
|
+
[
|
|
17
|
+
'@nx/react/webpack-plugin',
|
|
18
|
+
'@nx/rspack/react-plugin',
|
|
19
|
+
'NxReactWebpackPlugin',
|
|
20
|
+
'NxReactRspackPlugin',
|
|
21
|
+
],
|
|
22
|
+
]) {
|
|
23
|
+
const imports = (0, tsquery_1.query)(sourceFile, `ImportDeclaration > StringLiteral[value="${source}"], CallExpression:has(Identifier[name=require]) > StringLiteral[value="${source}"]`);
|
|
24
|
+
if (!imports.length)
|
|
25
|
+
continue;
|
|
26
|
+
for (const node of imports) {
|
|
27
|
+
replacements.push({
|
|
28
|
+
start: node.getStart(),
|
|
29
|
+
end: node.getEnd(),
|
|
30
|
+
text: `'${destination}'`,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
for (const node of (0, tsquery_1.query)(sourceFile, `Identifier[name=${fromClass}]`)) {
|
|
34
|
+
replacements.push({
|
|
35
|
+
start: node.getStart(),
|
|
36
|
+
end: node.getEnd(),
|
|
37
|
+
text: toClass,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
for (const node of (0, tsquery_1.query)(sourceFile, 'ImportDeclaration > StringLiteral[value=webpack]')) {
|
|
42
|
+
replacements.push({
|
|
43
|
+
start: node.getStart(),
|
|
44
|
+
end: node.getEnd(),
|
|
45
|
+
text: "'@rspack/core'",
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
for (const { start, end, text } of replacements.sort((a, b) => b.start - a.start)) {
|
|
49
|
+
contents = contents.slice(0, start) + text + contents.slice(end);
|
|
50
|
+
}
|
|
51
|
+
tree.write(configPath, contents);
|
|
74
52
|
}
|
|
@@ -12,50 +12,44 @@ const assert_supported_rspack_version_1 = require("../../utils/assert-supported-
|
|
|
12
12
|
async function rspackInitGenerator(tree, schema) {
|
|
13
13
|
(0, assert_supported_rspack_version_1.assertSupportedRspackVersion)(tree);
|
|
14
14
|
const tasks = [];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
'watch-deps',
|
|
54
|
-
'rspack:watch-deps',
|
|
55
|
-
'rspack-watch-deps',
|
|
56
|
-
],
|
|
57
|
-
}, schema.updatePackageScripts);
|
|
58
|
-
}
|
|
15
|
+
await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/rspack/plugin', plugin_1.createNodes, {
|
|
16
|
+
buildTargetName: [
|
|
17
|
+
'build',
|
|
18
|
+
'rspack:build',
|
|
19
|
+
'build:rspack',
|
|
20
|
+
'rspack-build',
|
|
21
|
+
'build-rspack',
|
|
22
|
+
],
|
|
23
|
+
serveTargetName: [
|
|
24
|
+
'serve',
|
|
25
|
+
'rspack:serve',
|
|
26
|
+
'serve:rspack',
|
|
27
|
+
'rspack-serve',
|
|
28
|
+
'serve-rspack',
|
|
29
|
+
],
|
|
30
|
+
serveStaticTargetName: [
|
|
31
|
+
'serve-static',
|
|
32
|
+
'rspack:serve-static',
|
|
33
|
+
'rspack-serve-static',
|
|
34
|
+
],
|
|
35
|
+
previewTargetName: [
|
|
36
|
+
'preview',
|
|
37
|
+
'rspack:preview',
|
|
38
|
+
'preview:rspack',
|
|
39
|
+
'rspack-preview',
|
|
40
|
+
'preview-rspack',
|
|
41
|
+
],
|
|
42
|
+
buildDepsTargetName: [
|
|
43
|
+
'build-deps',
|
|
44
|
+
'rspack:build-deps',
|
|
45
|
+
'rspack-build-deps',
|
|
46
|
+
],
|
|
47
|
+
watchDepsTargetName: [
|
|
48
|
+
'watch-deps',
|
|
49
|
+
'rspack:watch-deps',
|
|
50
|
+
'rspack-watch-deps',
|
|
51
|
+
],
|
|
52
|
+
}, schema.updatePackageScripts);
|
|
59
53
|
const jsInitTask = await (0, js_1.initGenerator)(tree, {
|
|
60
54
|
...schema,
|
|
61
55
|
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Replace removed @nx/rspack executors with inferred tasks
|
|
2
|
+
|
|
3
|
+
Nx 24 removed `@nx/rspack:rspack`, `@nx/rspack:dev-server` (including old `@nrwl` aliases).
|
|
4
|
+
|
|
5
|
+
Before changing anything, check for leftover work: a project target, a package.json target or a `targetDefaults` entry still uses a removed executor, or the advisory context reports a conversion error. If none applies, make no changes and stop. Treat each advisory-context item as pending work.
|
|
6
|
+
|
|
7
|
+
1. Inspect all affected projects and workspace defaults. Repair config-loading errors first. Do not restore executor registrations or install older Nx packages.
|
|
8
|
+
2. Register `@nx/rspack/plugin` with options/includes that preserve custom target names and mixed inferred/explicit projects. Replace remaining removed-executor targets, including those in package.json and filtered targetDefaults. Transfer their behavior before removing obsolete defaults. Preserve configurations, dependencies, cache inputs/outputs and environment behavior. Do not silently delete unsupported options or unrelated targets. Migrate old @nrwl aliases too.
|
|
9
|
+
3. Run project graph creation with the daemon and graph cache disabled (`NX_DAEMON=false NX_CACHE_PROJECT_GRAPH=false`), using the workspace package manager. Inspect resolved project targets and verify each migrated entrypoint exists and is inferred (a thin alias to an inferred target is acceptable). Resolve graph errors before completing this migration, even if task validation was skipped. Configs must load for subsequent migrations.
|
|
10
|
+
4. By default run relevant real builds/tests with task cache disabled, including alternate configurations. Honor an existing preference to skip expensive task validation; otherwise offer that option when validation is slow. Skipping expensive tasks never skips conversion or the graph check. Report each skipped task as unverified. Never weaken assertions or change application behavior to make checks pass.
|
|
11
|
+
5. Report converted projects, graph validation, task results and any skipped checks. Unconverted targets or a broken graph mean the migration is incomplete. Investigate task failures and distinguish missing environment prerequisites from conversion regressions; do not claim a working workspace with unresolved regressions.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inventoryComposePlugins = inventoryComposePlugins;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const CONFIG_EXTENSIONS = ['js', 'cjs', 'mjs', 'ts', 'cts', 'mts'];
|
|
6
|
+
const REMOVED_HELPERS = /\b(composePlugins|composePluginsSync|withNx|withWeb|withReact)\b/;
|
|
7
|
+
// Left by an earlier conversion; the wrapped `.old` config still calls the helpers.
|
|
8
|
+
const LEGACY_WRAPPER = /\buseLegacyNxPlugin\b/;
|
|
9
|
+
function inventoryComposePlugins(tree) {
|
|
10
|
+
const usages = [];
|
|
11
|
+
for (const [name, project] of (0, devkit_1.getProjects)(tree)) {
|
|
12
|
+
const configs = [...collectConfigPaths(tree, project)].map((path) => ({
|
|
13
|
+
path,
|
|
14
|
+
source: tree.read(path, 'utf-8') ?? '',
|
|
15
|
+
}));
|
|
16
|
+
const configPaths = configs
|
|
17
|
+
.filter(({ source }) => REMOVED_HELPERS.test(source) || LEGACY_WRAPPER.test(source))
|
|
18
|
+
.map(({ path }) => path);
|
|
19
|
+
if (!configPaths.length)
|
|
20
|
+
continue;
|
|
21
|
+
usages.push({
|
|
22
|
+
name,
|
|
23
|
+
root: project.root,
|
|
24
|
+
configPaths: configPaths.sort(),
|
|
25
|
+
usesHelpers: configs.some(({ source }) => REMOVED_HELPERS.test(source)),
|
|
26
|
+
usesExecutor: Object.values(project.targets ?? {}).some((target) => target.executor === '@nx/rspack:rspack'),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return usages;
|
|
30
|
+
}
|
|
31
|
+
function collectConfigPaths(tree, project) {
|
|
32
|
+
const paths = new Set();
|
|
33
|
+
for (const target of Object.values(project.targets ?? {})) {
|
|
34
|
+
for (const options of [
|
|
35
|
+
target.options,
|
|
36
|
+
...Object.values(target.configurations ?? {}),
|
|
37
|
+
]) {
|
|
38
|
+
const configured = options?.rspackConfig;
|
|
39
|
+
// A package path such as `@nx/react/plugins/webpack` resolves to the stubs
|
|
40
|
+
// rather than a workspace file; the prompt gives those projects a config.
|
|
41
|
+
if (typeof configured === 'string' && tree.exists(configured)) {
|
|
42
|
+
paths.add(configured);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
for (const extension of CONFIG_EXTENSIONS) {
|
|
47
|
+
const conventional = `${project.root}/rspack.config.${extension}`;
|
|
48
|
+
if (tree.exists(conventional)) {
|
|
49
|
+
paths.add(conventional);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return paths;
|
|
53
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
export default function migrateComposePlugins(tree: Tree): Promise<{
|
|
3
|
+
skipAgentic: boolean;
|
|
4
|
+
nextSteps?: undefined;
|
|
5
|
+
agentContext?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
skipAgentic?: undefined;
|
|
8
|
+
nextSteps: string[];
|
|
9
|
+
agentContext: string[];
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = migrateComposePlugins;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const convert_config_to_rspack_plugin_1 = require("../../generators/convert-config-to-rspack-plugin/convert-config-to-rspack-plugin");
|
|
6
|
+
const inventory_1 = require("./inventory");
|
|
7
|
+
const CONVERTER = '@nx/rspack:convert-config-to-rspack-plugin';
|
|
8
|
+
async function migrateComposePlugins(tree) {
|
|
9
|
+
const usages = (0, inventory_1.inventoryComposePlugins)(tree);
|
|
10
|
+
if (!usages.length) {
|
|
11
|
+
return { skipAgentic: true };
|
|
12
|
+
}
|
|
13
|
+
const converted = [];
|
|
14
|
+
const remaining = [];
|
|
15
|
+
for (const usage of usages) {
|
|
16
|
+
if (!usage.usesHelpers) {
|
|
17
|
+
converted.push(usage);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
await (0, convert_config_to_rspack_plugin_1.convertConfigToRspackPluginGenerator)(tree, {
|
|
22
|
+
project: usage.name,
|
|
23
|
+
skipFormat: true,
|
|
24
|
+
});
|
|
25
|
+
converted.push(usage);
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
remaining.push({ usage, reason: e.message });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (converted.length) {
|
|
32
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
nextSteps: nextSteps(converted, remaining),
|
|
36
|
+
agentContext: agentContext(converted, remaining),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function nextSteps(converted, remaining) {
|
|
40
|
+
const steps = [];
|
|
41
|
+
if (converted.length) {
|
|
42
|
+
steps.push(`Inline the \`rspack.config.old.*\` files that ${CONVERTER} left behind in ${converted.length} project(s), then drop \`useLegacyNxPlugin\`.`);
|
|
43
|
+
}
|
|
44
|
+
if (remaining.length) {
|
|
45
|
+
steps.push(`Migrate ${remaining.length} project(s) off the removed rspack config helpers by hand: ${remaining
|
|
46
|
+
.map(({ usage }) => usage.name)
|
|
47
|
+
.join(', ')}.`);
|
|
48
|
+
}
|
|
49
|
+
return steps;
|
|
50
|
+
}
|
|
51
|
+
function agentContext(converted, remaining) {
|
|
52
|
+
const context = [];
|
|
53
|
+
if (converted.length) {
|
|
54
|
+
context.push(`${CONVERTER} converted these projects. Each one now has a standard config whose \`useLegacyNxPlugin\` call still loads the renamed \`.old\` config, so the helper callbacks it holds have to move into the new config before the \`.old\` file can go:`, ...converted.map((usage) => `- ${usage.name} (${usage.root}): ${usage.configPaths.join(', ')}`));
|
|
55
|
+
}
|
|
56
|
+
if (remaining.length) {
|
|
57
|
+
context.push(`${CONVERTER} could not convert these projects, so their configs are untouched and still call the removed helpers. Rewrite each one by hand:`, ...remaining.map(({ usage, reason }) => `- ${usage.name} (${usage.root}): ${usage.configPaths.join(', ')} - ${reason}`));
|
|
58
|
+
}
|
|
59
|
+
return context;
|
|
60
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Migrate Rspack compose helpers
|
|
2
|
+
|
|
3
|
+
Nx v24 removed `composePlugins`, `composePluginsSync`, `withNx`, `withWeb`, and Rspack
|
|
4
|
+
`withReact`. Their exports remain as inert stubs so existing configs still load while Nx
|
|
5
|
+
builds the project graph. They do not configure builds, and a config that loads is not a
|
|
6
|
+
working build.
|
|
7
|
+
|
|
8
|
+
`@nx/rspack:convert-config-to-rspack-plugin` already ran. The agent context lists the
|
|
9
|
+
projects it converted, including configs an earlier conversion left wrapped in
|
|
10
|
+
`useLegacyNxPlugin`, and, separately, the projects it could not convert with the reason
|
|
11
|
+
for each. Work only on those projects and the files they import. Do not re-inventory the
|
|
12
|
+
workspace, and do not run the converter again.
|
|
13
|
+
|
|
14
|
+
Preserve the installed Rspack version, bundler, targets, configurations, and commands.
|
|
15
|
+
Nx 24 also removed the `@nx/rspack:rspack` executor. Its targets are converted to inferred
|
|
16
|
+
`@nx/rspack/plugin` tasks by a separate migration, so do not add it back or keep a target on it.
|
|
17
|
+
|
|
18
|
+
## Baseline
|
|
19
|
+
|
|
20
|
+
This workspace is already on v24, so the old helpers no longer build here. To compare
|
|
21
|
+
against the previous behavior, check out the commit before the upgrade in a separate git
|
|
22
|
+
worktree, install with its lockfile, and build there. Do not downgrade this workspace. If
|
|
23
|
+
you cannot build a baseline, say so in your report rather than calling the comparison a
|
|
24
|
+
pass. Record build commands, output locations, assets, entry points, and any observable
|
|
25
|
+
custom behavior.
|
|
26
|
+
|
|
27
|
+
## Projects the converter handled
|
|
28
|
+
|
|
29
|
+
Each one now has a standard config built around `NxAppRspackPlugin`, plus a
|
|
30
|
+
`useLegacyNxPlugin(require('./rspack.config.old.*'), options)` entry that still loads the
|
|
31
|
+
renamed old config. The old config composes its remaining callbacks through a local
|
|
32
|
+
`composeLegacyPlugins` helper the converter inlined. Two things are left:
|
|
33
|
+
|
|
34
|
+
- Move what the old config still does into the new config, then delete the `.old` file and
|
|
35
|
+
drop `useLegacyNxPlugin`.
|
|
36
|
+
- `useLegacyNxPlugin` runs at `beforeCompile`. That is too late to register rules, entries,
|
|
37
|
+
or plugins, so anything the old config set through those is already not applying the way
|
|
38
|
+
it used to. Check each one against the baseline instead of trusting the converted build.
|
|
39
|
+
|
|
40
|
+
Also check the options the converter copied into the new config. It reads them out of the
|
|
41
|
+
old `withNx` call as written, so values that depended on the executor or on environment
|
|
42
|
+
variables are not represented, and workspace-relative paths may need adjusting: native
|
|
43
|
+
plugin options resolve against the project and config directory, while executor options
|
|
44
|
+
were workspace-relative.
|
|
45
|
+
|
|
46
|
+
## Projects the converter skipped
|
|
47
|
+
|
|
48
|
+
The agent context gives a reason per project. Those configs are untouched and still call
|
|
49
|
+
the removed helpers, so rewrite each one.
|
|
50
|
+
|
|
51
|
+
Use a standard Rspack configuration with `NxAppRspackPlugin` from
|
|
52
|
+
`@nx/rspack/app-plugin`. For React apps also use `NxReactRspackPlugin` from
|
|
53
|
+
`@nx/rspack/react-plugin`. Do not add React configuration to Node or plain web apps, and
|
|
54
|
+
do not change frameworks or upgrade dependencies to simplify the rewrite.
|
|
55
|
+
|
|
56
|
+
Map the effective old options onto those plugins and standard Rspack properties, reading
|
|
57
|
+
the installed plugin types rather than assuming. Preserve precedence between target
|
|
58
|
+
options, named configurations, helper options, and custom callbacks. Preserve compiler
|
|
59
|
+
choice, aliases, CSS, SVG rules, assets, externals, file replacements, source maps,
|
|
60
|
+
optimization, public paths, output filenames, and dev-server behavior. Set output hashing
|
|
61
|
+
explicitly where the old helper defaults differ from the plugin defaults; a build that
|
|
62
|
+
succeeds with renamed entry files is not output parity.
|
|
63
|
+
|
|
64
|
+
Inferred targets run the Rspack CLI, which calls a function export with `(env, argv)`.
|
|
65
|
+
Represent the options the executor used to supply in the config itself. Use config
|
|
66
|
+
functions or separate configs where values vary by configuration.
|
|
67
|
+
|
|
68
|
+
For custom composable functions, move the function into user-owned code and supply the
|
|
69
|
+
options and context it needs explicitly. A local adapter exposing `apply(compiler)` can
|
|
70
|
+
work, but an `apply` object belongs in `config.plugins`; exporting it as the whole config
|
|
71
|
+
is invalid, and a top-level config function must return a config object or supported array.
|
|
72
|
+
Preserve execution order and whether each callback mutates its input or returns a
|
|
73
|
+
replacement. Await asynchronous transforms and propagate failures rather than leaving a
|
|
74
|
+
pending promise.
|
|
75
|
+
|
|
76
|
+
## Module Federation
|
|
77
|
+
|
|
78
|
+
Projects using Nx Module Federation are out of scope here. `@nx/module-federation` ships
|
|
79
|
+
its own v24 migration; follow that one. Do not remove federation, disable the project, or
|
|
80
|
+
report success for it from this migration.
|
|
81
|
+
|
|
82
|
+
## Verify and finish
|
|
83
|
+
|
|
84
|
+
1. Rebuild the project graph without its disk cache and confirm the same projects and
|
|
85
|
+
targets are still discoverable.
|
|
86
|
+
2. Run each affected build, development and production and any alternate configurations,
|
|
87
|
+
without reusing cached task outputs. Exercise Node startup where it applies, plus tests
|
|
88
|
+
and dev-server or HMR behavior.
|
|
89
|
+
3. Compare emitted files against the baseline: custom assets and markers, entry points,
|
|
90
|
+
aliases, CSS and SVG handling, externals, and output paths. Compare content where hashes
|
|
91
|
+
differ. A zero exit code is not enough.
|
|
92
|
+
4. Search the active configs and their imports for the removed helpers again. An already
|
|
93
|
+
migrated config needs no further change.
|
|
94
|
+
5. Report the commands you ran, the output you checked, and anything still unresolved. Do
|
|
95
|
+
not delete tests, custom behavior, or targets to get a green result.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
|
+
const convert_config_to_rspack_plugin_1 = require("../../generators/convert-config-to-rspack-plugin/convert-config-to-rspack-plugin");
|
|
7
|
+
const inventory_1 = require("./inventory");
|
|
8
|
+
function update(tree) {
|
|
9
|
+
return (0, internal_1.migrateRemovedExecutors)(tree, [
|
|
10
|
+
'@nx/rspack:rspack',
|
|
11
|
+
'@nx/rspack:dev-server',
|
|
12
|
+
'@nrwl/rspack:rspack',
|
|
13
|
+
'@nrwl/rspack:dev-server',
|
|
14
|
+
], async (tree, options) => {
|
|
15
|
+
await convertHelperConfigs(tree);
|
|
16
|
+
const { convertToInferred } = require('../../generators/convert-to-inferred/convert-to-inferred');
|
|
17
|
+
return convertToInferred(tree, options);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
// convert-to-inferred skips configs built on the removed helpers, so convert
|
|
21
|
+
// those first. migrate-compose-plugins reports the `.old` configs left behind.
|
|
22
|
+
async function convertHelperConfigs(tree) {
|
|
23
|
+
for (const usage of (0, inventory_1.inventoryComposePlugins)(tree)) {
|
|
24
|
+
if (!usage.usesExecutor || !usage.usesHelpers)
|
|
25
|
+
continue;
|
|
26
|
+
try {
|
|
27
|
+
await (0, convert_config_to_rspack_plugin_1.convertConfigToRspackPluginGenerator)(tree, {
|
|
28
|
+
project: usage.name,
|
|
29
|
+
skipFormat: true,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
devkit_1.logger.warn(`Could not convert the rspack config helpers in ${usage.name}: ${e.message}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#### Convert `@nx/rspack` build and dev-server targets to inferred tasks
|
|
2
|
+
|
|
3
|
+
Nx 24 removes the `@nx/rspack:rspack` and `@nx/rspack:dev-server` executors and their `@nrwl` aliases. The migration registers `@nx/rspack/plugin` in `nx.json` and converts the targets that use those executors to inferred tasks. It moves the executor options into `rspack.config.*`. A target with nothing left to override is removed from project configuration. When several projects share the same remaining options, those options move to a `targetDefaults` entry scoped to the plugin. `targetDefaults` entries keyed by a removed executor are removed once no target uses that executor.
|
|
4
|
+
|
|
5
|
+
The migration lists the targets the converter cannot convert safely. In agentic runs, an AI prompt finishes them and validates the project graph.
|
|
6
|
+
|
|
7
|
+
The `@nx/rspack:ssr-dev-server` executor stays.
|
|
8
|
+
|
|
9
|
+
#### Sample code changes
|
|
10
|
+
|
|
11
|
+
The example shows the `build` target. Its options move into `rspack.config.*`, so only the configuration names stay on the target.
|
|
12
|
+
|
|
13
|
+
##### Before
|
|
14
|
+
|
|
15
|
+
```json title="apps/app1/project.json"
|
|
16
|
+
{
|
|
17
|
+
"name": "app1",
|
|
18
|
+
"targets": {
|
|
19
|
+
"build": {
|
|
20
|
+
"executor": "@nx/rspack:rspack",
|
|
21
|
+
"options": {
|
|
22
|
+
"rspackConfig": "apps/app1/rspack.config.js",
|
|
23
|
+
"outputPath": "dist/apps/app1",
|
|
24
|
+
"index": "apps/app1/src/index.html",
|
|
25
|
+
"main": "apps/app1/src/main.tsx",
|
|
26
|
+
"tsConfig": "apps/app1/tsconfig.app.json",
|
|
27
|
+
"assets": ["apps/app1/src/favicon.ico", "apps/app1/src/assets"],
|
|
28
|
+
"styles": ["apps/app1/src/styles.scss"],
|
|
29
|
+
"scripts": []
|
|
30
|
+
},
|
|
31
|
+
"configurations": {
|
|
32
|
+
"development": {
|
|
33
|
+
"extractLicenses": false,
|
|
34
|
+
"optimization": false,
|
|
35
|
+
"sourceMap": true,
|
|
36
|
+
"vendorChunk": true
|
|
37
|
+
},
|
|
38
|
+
"production": {
|
|
39
|
+
"fileReplacements": [
|
|
40
|
+
{
|
|
41
|
+
"replace": "apps/app1/src/environments/environment.ts",
|
|
42
|
+
"with": "apps/app1/src/environments/environment.prod.ts"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"optimization": true,
|
|
46
|
+
"outputHashing": "all",
|
|
47
|
+
"sourceMap": false,
|
|
48
|
+
"namedChunks": false,
|
|
49
|
+
"extractLicenses": true,
|
|
50
|
+
"vendorChunk": false
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"defaultConfiguration": "production"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
##### After
|
|
60
|
+
|
|
61
|
+
```json title="apps/app1/project.json"
|
|
62
|
+
{
|
|
63
|
+
"name": "app1",
|
|
64
|
+
"targets": {
|
|
65
|
+
"build": {
|
|
66
|
+
"configurations": {
|
|
67
|
+
"development": {},
|
|
68
|
+
"production": {}
|
|
69
|
+
},
|
|
70
|
+
"defaultConfiguration": "production"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```json title="nx.json"
|
|
77
|
+
{
|
|
78
|
+
"plugins": [
|
|
79
|
+
{
|
|
80
|
+
"plugin": "@nx/rspack/plugin",
|
|
81
|
+
"options": {
|
|
82
|
+
"buildTargetName": "build",
|
|
83
|
+
"previewTargetName": "preview",
|
|
84
|
+
"serveStaticTargetName": "serve-static",
|
|
85
|
+
"serveTargetName": "serve"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
```
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Compiler } from '@rspack/core';
|
|
2
2
|
import type { NxAppRspackPluginOptions } from '../utils/models';
|
|
3
|
+
import { READY_SIGNAL_PLUGIN } from '../../utils/dev-server-ready-signal';
|
|
3
4
|
/**
|
|
4
5
|
* This plugin provides features to build Node and Web applications.
|
|
5
6
|
* - TS Support (including tsconfig paths
|
|
@@ -11,6 +12,7 @@ import type { NxAppRspackPluginOptions } from '../utils/models';
|
|
|
11
12
|
*/
|
|
12
13
|
export declare class NxAppRspackPlugin {
|
|
13
14
|
private readonly options;
|
|
15
|
+
readonly [READY_SIGNAL_PLUGIN] = true;
|
|
14
16
|
constructor(options?: NxAppRspackPluginOptions);
|
|
15
17
|
apply(compiler: Compiler): void;
|
|
16
18
|
}
|