@nx/rspack 24.0.0-beta.1 → 24.0.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/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 +2 -24
- 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.js +4 -1
- 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/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 +0 -2
- package/dist/src/utils/generator-utils.js +45 -167
- 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 +6 -25
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ExecutorContext } from '@nx/devkit';
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
2
|
import type { Configuration } from '@rspack/core';
|
|
3
|
-
import { NormalizedRspackExecutorSchema } from '../executors/rspack/schema';
|
|
3
|
+
import type { NormalizedRspackExecutorSchema } from '../executors/rspack/schema';
|
|
4
4
|
export declare const nxRspackComposablePlugin = "nxRspackComposablePlugin";
|
|
5
5
|
export declare function isNxRspackComposablePlugin(a: unknown): a is AsyncNxComposableRspackPlugin;
|
|
6
6
|
export interface NxRspackExecutionContext {
|
|
@@ -15,22 +15,18 @@ export interface AsyncNxComposableRspackPlugin {
|
|
|
15
15
|
(config: Configuration, ctx: NxRspackExecutionContext): Configuration | Promise<Configuration>;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* @deprecated
|
|
19
|
-
* `@nx/rspack/
|
|
20
|
-
*
|
|
21
|
-
* `nx g @nx/rspack:convert-to-inferred`. See
|
|
22
|
-
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
|
|
18
|
+
* @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin` (or `NxReactRspackPlugin`
|
|
19
|
+
* from `@nx/rspack/react-plugin`).
|
|
20
|
+
* This inert stub will be removed in Nx v25.
|
|
23
21
|
*/
|
|
24
|
-
export declare function composePlugins(...
|
|
22
|
+
export declare function composePlugins(..._plugins: (NxComposableRspackPlugin | AsyncNxComposableRspackPlugin | Promise<NxComposableRspackPlugin | AsyncNxComposableRspackPlugin>)[]): ((config?: Configuration, ctx?: NxRspackExecutionContext) => Promise<Configuration>) & {
|
|
25
23
|
nxRspackComposablePlugin: boolean;
|
|
26
24
|
};
|
|
27
25
|
/**
|
|
28
|
-
* @deprecated
|
|
29
|
-
* `@nx/rspack/
|
|
30
|
-
*
|
|
31
|
-
* `nx g @nx/rspack:convert-to-inferred`. See
|
|
32
|
-
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
|
|
26
|
+
* @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin` (or `NxReactRspackPlugin`
|
|
27
|
+
* from `@nx/rspack/react-plugin`).
|
|
28
|
+
* This inert stub will be removed in Nx v25.
|
|
33
29
|
*/
|
|
34
|
-
export declare function composePluginsSync(...
|
|
30
|
+
export declare function composePluginsSync(..._plugins: NxComposableRspackPlugin[]): ((config?: Configuration, ctx?: NxRspackExecutionContext) => Configuration) & {
|
|
35
31
|
nxRspackComposablePlugin: boolean;
|
|
36
32
|
};
|
package/dist/src/utils/config.js
CHANGED
|
@@ -4,86 +4,33 @@ exports.nxRspackComposablePlugin = void 0;
|
|
|
4
4
|
exports.isNxRspackComposablePlugin = isNxRspackComposablePlugin;
|
|
5
5
|
exports.composePlugins = composePlugins;
|
|
6
6
|
exports.composePluginsSync = composePluginsSync;
|
|
7
|
-
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
const internal_1 = require("@nx/js/internal");
|
|
9
7
|
const deprecation_1 = require("./deprecation");
|
|
10
|
-
const internal_2 = require("@nx/devkit/internal");
|
|
11
8
|
exports.nxRspackComposablePlugin = 'nxRspackComposablePlugin';
|
|
12
9
|
function isNxRspackComposablePlugin(a) {
|
|
13
10
|
return a?.[exports.nxRspackComposablePlugin] === true;
|
|
14
11
|
}
|
|
12
|
+
// TODO(v25): remove the inert config-helper stubs in this file.
|
|
15
13
|
/**
|
|
16
|
-
* @deprecated
|
|
17
|
-
* `@nx/rspack/
|
|
18
|
-
*
|
|
19
|
-
* `nx g @nx/rspack:convert-to-inferred`. See
|
|
20
|
-
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
|
|
14
|
+
* @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin` (or `NxReactRspackPlugin`
|
|
15
|
+
* from `@nx/rspack/react-plugin`).
|
|
16
|
+
* This inert stub will be removed in Nx v25.
|
|
21
17
|
*/
|
|
22
|
-
function composePlugins(...
|
|
18
|
+
function composePlugins(..._plugins) {
|
|
23
19
|
(0, deprecation_1.warnRspackComposeHelpersDeprecation)();
|
|
24
|
-
return Object.assign(async
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (ctx['env']) {
|
|
29
|
-
ensureNxRspackExecutionContext(ctx);
|
|
30
|
-
// Build this from scratch since what rspack passes us is the env, not config,
|
|
31
|
-
// and `withNX()` creates a new config object anyway.
|
|
32
|
-
config = {};
|
|
33
|
-
}
|
|
34
|
-
for (const plugin of plugins) {
|
|
35
|
-
const fn = await plugin;
|
|
36
|
-
config = await fn(config, ctx);
|
|
37
|
-
}
|
|
38
|
-
return config;
|
|
39
|
-
}, {
|
|
40
|
-
[exports.nxRspackComposablePlugin]: true,
|
|
41
|
-
});
|
|
20
|
+
return Object.assign(async (config = {}, ctx) => {
|
|
21
|
+
// Only the legacy Nx executor passes a config; CLIs pass (env, argv).
|
|
22
|
+
return ctx?.context && typeof ctx.context === 'object' ? config : {};
|
|
23
|
+
}, { [exports.nxRspackComposablePlugin]: true });
|
|
42
24
|
}
|
|
43
25
|
/**
|
|
44
|
-
* @deprecated
|
|
45
|
-
* `@nx/rspack/
|
|
46
|
-
*
|
|
47
|
-
* `nx g @nx/rspack:convert-to-inferred`. See
|
|
48
|
-
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
|
|
26
|
+
* @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin` (or `NxReactRspackPlugin`
|
|
27
|
+
* from `@nx/rspack/react-plugin`).
|
|
28
|
+
* This inert stub will be removed in Nx v25.
|
|
49
29
|
*/
|
|
50
|
-
function composePluginsSync(...
|
|
30
|
+
function composePluginsSync(..._plugins) {
|
|
51
31
|
(0, deprecation_1.warnRspackComposeHelpersDeprecation)();
|
|
52
|
-
return Object.assign(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return config;
|
|
57
|
-
}, {
|
|
58
|
-
[exports.nxRspackComposablePlugin]: true,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
function ensureNxRspackExecutionContext(ctx) {
|
|
62
|
-
const projectName = process.env.NX_TASK_TARGET_PROJECT;
|
|
63
|
-
const targetName = process.env.NX_TASK_TARGET_TARGET;
|
|
64
|
-
const configurationName = process.env.NX_TASK_TARGET_CONFIGURATION;
|
|
65
|
-
const projectGraph = (0, devkit_1.readCachedProjectGraph)();
|
|
66
|
-
const projectNode = projectGraph.nodes[projectName];
|
|
67
|
-
ctx.options ??= {
|
|
68
|
-
root: devkit_1.workspaceRoot,
|
|
69
|
-
projectRoot: projectNode.data.root,
|
|
70
|
-
sourceRoot: (0, internal_1.getProjectSourceRoot)(projectNode.data),
|
|
71
|
-
// These aren't actually needed since NxRspackPlugin and withNx both support them being undefined.
|
|
72
|
-
assets: undefined,
|
|
73
|
-
outputFileName: undefined,
|
|
74
|
-
outputPath: undefined,
|
|
75
|
-
rspackConfig: undefined,
|
|
76
|
-
useTsconfigPaths: undefined,
|
|
77
|
-
};
|
|
78
|
-
ctx.context ??= {
|
|
79
|
-
projectName,
|
|
80
|
-
targetName,
|
|
81
|
-
configurationName,
|
|
82
|
-
projectsConfigurations: (0, devkit_1.readProjectsConfigurationFromProjectGraph)(projectGraph),
|
|
83
|
-
nxJsonConfiguration: (0, internal_2.readNxJsonFromDisk)(devkit_1.workspaceRoot),
|
|
84
|
-
cwd: process.cwd(),
|
|
85
|
-
root: devkit_1.workspaceRoot,
|
|
86
|
-
isVerbose: process.env['NX_VERBOSE_LOGGING'] === 'true',
|
|
87
|
-
projectGraph,
|
|
88
|
-
};
|
|
32
|
+
return Object.assign((config = {}, ctx) => {
|
|
33
|
+
// Only the legacy Nx executor passes a config; CLIs pass (env, argv).
|
|
34
|
+
return ctx?.context && typeof ctx.context === 'object' ? config : {};
|
|
35
|
+
}, { [exports.nxRspackComposablePlugin]: true });
|
|
89
36
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const RSPACK_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/rspack:dev-server` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/rspack:convert-to-inferred` to migrate to the `@nx/rspack/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
|
|
3
|
-
export declare function warnRspackExecutorDeprecation(): void;
|
|
4
|
-
export declare function warnRspackDevServerExecutorDeprecation(): void;
|
|
5
|
-
export declare function warnRspackExecutorGenerating(): void;
|
|
6
|
-
export declare const RSPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = "The `composePlugins`, `withNx`, `withWeb`, and `withReact` config helpers from `@nx/rspack` are deprecated and will be removed in Nx v24. They produce an Nx-specific config function that only runs under the `@nx/rspack:rspack` executor. Migrate to a standard rspack config that uses `NxAppRspackPlugin` (from `@nx/rspack/app-plugin`) or `NxReactRspackPlugin` (from `@nx/rspack/react-plugin`) under the inferred `@nx/rspack/plugin` by running `nx g @nx/rspack:convert-to-inferred`. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
|
|
1
|
+
export declare const RSPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = "The compose config helpers from `@nx/rspack` were removed in Nx v24. The remaining exports are inert compatibility stubs and do not configure builds. Migrate to a standard rspack config using `NxAppRspackPlugin` from `@nx/rspack/app-plugin`. Follow the config-helper migration instructions generated by `nx migrate`. Executor conversion is a separate migration.";
|
|
7
2
|
export declare function suppressRspackComposeHelperWarnings<T>(fn: () => T): T;
|
|
8
3
|
export declare function warnRspackComposeHelpersDeprecation(): void;
|
|
@@ -1,31 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RSPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE =
|
|
4
|
-
exports.warnRspackExecutorDeprecation = warnRspackExecutorDeprecation;
|
|
5
|
-
exports.warnRspackDevServerExecutorDeprecation = warnRspackDevServerExecutorDeprecation;
|
|
6
|
-
exports.warnRspackExecutorGenerating = warnRspackExecutorGenerating;
|
|
3
|
+
exports.RSPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = void 0;
|
|
7
4
|
exports.suppressRspackComposeHelperWarnings = suppressRspackComposeHelperWarnings;
|
|
8
5
|
exports.warnRspackComposeHelpersDeprecation = warnRspackComposeHelpersDeprecation;
|
|
9
6
|
const devkit_1 = require("@nx/devkit");
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
exports.RSPACK_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/rspack:rspack` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/rspack:convert-to-inferred` to migrate to the `@nx/rspack/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
|
|
14
|
-
exports.RSPACK_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/rspack:dev-server` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/rspack:convert-to-inferred` to migrate to the `@nx/rspack/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
|
|
15
|
-
function warnRspackExecutorDeprecation() {
|
|
16
|
-
devkit_1.logger.warn(exports.RSPACK_EXECUTOR_DEPRECATION_MESSAGE);
|
|
17
|
-
}
|
|
18
|
-
function warnRspackDevServerExecutorDeprecation() {
|
|
19
|
-
devkit_1.logger.warn(exports.RSPACK_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE);
|
|
20
|
-
}
|
|
21
|
-
function warnRspackExecutorGenerating() {
|
|
22
|
-
devkit_1.logger.warn('Generating targets that use the deprecated `@nx/rspack:rspack` and `@nx/rspack:dev-server` executors. These executors will be removed in Nx v24. Run `nx g @nx/rspack:convert-to-inferred` next to migrate these targets to the `@nx/rspack/plugin` inferred plugin and prevent future generators from emitting executor targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.');
|
|
23
|
-
}
|
|
24
|
-
// TODO(v24): Remove the composePlugins/withNx/withWeb/withReact config helpers.
|
|
25
|
-
// They emit an Nx-specific config function that only runs under the
|
|
26
|
-
// @nx/rspack:rspack executor; the inferred @nx/rspack/plugin works with standard
|
|
27
|
-
// rspack configs built around NxAppRspackPlugin/NxReactRspackPlugin instead.
|
|
28
|
-
exports.RSPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = 'The `composePlugins`, `withNx`, `withWeb`, and `withReact` config helpers from `@nx/rspack` are deprecated and will be removed in Nx v24. They produce an Nx-specific config function that only runs under the `@nx/rspack:rspack` executor. Migrate to a standard rspack config that uses `NxAppRspackPlugin` (from `@nx/rspack/app-plugin`) or `NxReactRspackPlugin` (from `@nx/rspack/react-plugin`) under the inferred `@nx/rspack/plugin` by running `nx g @nx/rspack:convert-to-inferred`. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
|
|
7
|
+
// Helper behavior was removed in v24; exports remain only as inert stubs.
|
|
8
|
+
// Keep their exports loadable so old configs do not block graph creation.
|
|
9
|
+
exports.RSPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = 'The compose config helpers from `@nx/rspack` were removed in Nx v24. The remaining exports are inert compatibility stubs and do not configure builds. Migrate to a standard rspack config using `NxAppRspackPlugin` from `@nx/rspack/app-plugin`. Follow the config-helper migration instructions generated by `nx migrate`. Executor conversion is a separate migration.';
|
|
29
10
|
let composeHelpersWarned = false;
|
|
30
11
|
let suppressDepth = 0;
|
|
31
12
|
// Nx-internal entry points compose these helpers themselves (e.g. the rspack
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type Tree } from '@nx/devkit';
|
|
2
|
-
export declare function getRspackE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string,
|
|
2
|
+
export declare function getRspackE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, e2ePortOverride?: number): Promise<import("@nx/devkit/internal").E2EWebServerDetails>;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getRspackE2EWebServerInfo = getRspackE2EWebServerInfo;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const internal_1 = require("@nx/devkit/internal");
|
|
6
|
-
async function getRspackE2EWebServerInfo(tree, projectName, configFilePath,
|
|
6
|
+
async function getRspackE2EWebServerInfo(tree, projectName, configFilePath, e2ePortOverride) {
|
|
7
7
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
8
8
|
let e2ePort = e2ePortOverride ?? 4200;
|
|
9
9
|
const servePort = (0, internal_1.readTargetDefaultsForTarget)('serve', nxJson.targetDefaults)
|
|
@@ -26,5 +26,5 @@ async function getRspackE2EWebServerInfo(tree, projectName, configFilePath, isPl
|
|
|
26
26
|
defaultE2ECiBaseUrl: `http://localhost:${e2ePort}`,
|
|
27
27
|
defaultE2EPort: e2ePort,
|
|
28
28
|
e2EPortIsExplicit: e2ePortOverride != null,
|
|
29
|
-
}
|
|
29
|
+
});
|
|
30
30
|
}
|
|
@@ -13,8 +13,6 @@ export declare function findExistingTargetsInProject(targets: {
|
|
|
13
13
|
userProvidedTargetIsUnsupported: TargetFlags;
|
|
14
14
|
alreadyHasNxRspackTargets: TargetFlags;
|
|
15
15
|
};
|
|
16
|
-
export declare function addOrChangeBuildTarget(tree: Tree, options: ConfigurationSchema, target: string): void;
|
|
17
|
-
export declare function addOrChangeServeTarget(tree: Tree, options: ConfigurationSchema, target: string): void;
|
|
18
16
|
export declare function writeRspackConfigFile(tree: Tree, options: ConfigurationSchema, stylePreprocessorOptions?: {
|
|
19
17
|
includePaths?: string[];
|
|
20
18
|
}): void;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findExistingTargetsInProject = findExistingTargetsInProject;
|
|
4
|
-
exports.addOrChangeBuildTarget = addOrChangeBuildTarget;
|
|
5
|
-
exports.addOrChangeServeTarget = addOrChangeServeTarget;
|
|
6
4
|
exports.writeRspackConfigFile = writeRspackConfigFile;
|
|
7
5
|
exports.deleteWebpackConfig = deleteWebpackConfig;
|
|
8
6
|
exports.moveAndEditIndexHtml = moveAndEditIndexHtml;
|
|
@@ -16,7 +14,6 @@ exports.determineTsConfig = determineTsConfig;
|
|
|
16
14
|
const internal_1 = require("@nx/devkit/internal");
|
|
17
15
|
const devkit_1 = require("@nx/devkit");
|
|
18
16
|
const internal_2 = require("@nx/js/internal");
|
|
19
|
-
const has_plugin_1 = require("./has-plugin");
|
|
20
17
|
function findExistingTargetsInProject(targets, userProvidedTargets) {
|
|
21
18
|
const output = {
|
|
22
19
|
validFoundTargetName: {},
|
|
@@ -120,75 +117,6 @@ function findExistingTargetsInProject(targets, userProvidedTargets) {
|
|
|
120
117
|
}
|
|
121
118
|
return output;
|
|
122
119
|
}
|
|
123
|
-
function addOrChangeBuildTarget(tree, options, target) {
|
|
124
|
-
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
125
|
-
const assets = [];
|
|
126
|
-
if (options.target === 'web' &&
|
|
127
|
-
tree.exists((0, devkit_1.joinPathFragments)(project.root, 'src/favicon.ico'))) {
|
|
128
|
-
assets.push((0, devkit_1.joinPathFragments)(project.root, 'src/favicon.ico'));
|
|
129
|
-
}
|
|
130
|
-
if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'src/assets'))) {
|
|
131
|
-
assets.push((0, devkit_1.joinPathFragments)(project.root, 'src/assets'));
|
|
132
|
-
}
|
|
133
|
-
const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)(tree);
|
|
134
|
-
const buildOptions = {
|
|
135
|
-
target: options.target ?? 'web',
|
|
136
|
-
outputPath: isTsSolutionSetup
|
|
137
|
-
? (0, devkit_1.joinPathFragments)(project.root, 'dist')
|
|
138
|
-
: (0, devkit_1.joinPathFragments)('dist',
|
|
139
|
-
// If standalone project then use the project's name in dist.
|
|
140
|
-
project.root === '.' ? project.name : project.root),
|
|
141
|
-
index: (0, devkit_1.joinPathFragments)(project.root, 'src/index.html'),
|
|
142
|
-
main: determineMain(tree, options),
|
|
143
|
-
tsConfig: determineTsConfig(tree, options),
|
|
144
|
-
rspackConfig: (0, devkit_1.joinPathFragments)(project.root, 'rspack.config.js'),
|
|
145
|
-
assets,
|
|
146
|
-
};
|
|
147
|
-
const existingProjectConfigurations = {};
|
|
148
|
-
const buildTarget = project.targets.build;
|
|
149
|
-
if (buildTarget && buildTarget.configurations) {
|
|
150
|
-
for (const [configurationName, configuration] of Object.entries(buildTarget.configurations)) {
|
|
151
|
-
existingProjectConfigurations[configurationName] = configuration;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
project.targets ??= {};
|
|
155
|
-
project.targets[target] = {
|
|
156
|
-
executor: '@nx/rspack:rspack',
|
|
157
|
-
outputs: ['{options.outputPath}'],
|
|
158
|
-
defaultConfiguration: 'production',
|
|
159
|
-
options: buildOptions,
|
|
160
|
-
configurations: {
|
|
161
|
-
development: {
|
|
162
|
-
...(existingProjectConfigurations['development'] ?? {}),
|
|
163
|
-
mode: 'development',
|
|
164
|
-
},
|
|
165
|
-
production: {
|
|
166
|
-
...(existingProjectConfigurations['production'] ?? {}),
|
|
167
|
-
mode: 'production',
|
|
168
|
-
optimization: options.target === 'web' ? true : undefined,
|
|
169
|
-
sourceMap: false,
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
174
|
-
}
|
|
175
|
-
function addOrChangeServeTarget(tree, options, target) {
|
|
176
|
-
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
177
|
-
project.targets ??= {};
|
|
178
|
-
project.targets[target] = {
|
|
179
|
-
executor: '@nx/rspack:dev-server',
|
|
180
|
-
options: {
|
|
181
|
-
buildTarget: `${options.project}:build:development`,
|
|
182
|
-
},
|
|
183
|
-
configurations: {
|
|
184
|
-
development: {},
|
|
185
|
-
production: {
|
|
186
|
-
buildTarget: `${options.project}:build:production`,
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
191
|
-
}
|
|
192
120
|
function writeRspackConfigFile(tree, options, stylePreprocessorOptions) {
|
|
193
121
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
194
122
|
tree.write((0, devkit_1.joinPathFragments)(project.root, 'rspack.config.js'), createConfig(tree, { ...options, stylePreprocessorOptions }));
|
|
@@ -198,17 +126,12 @@ function createConfig(tree, options) {
|
|
|
198
126
|
const buildOptions = createBuildOptions(tree, options, project);
|
|
199
127
|
const defaultConfig = generateDefaultConfig(project, buildOptions);
|
|
200
128
|
if (options.framework === 'react') {
|
|
201
|
-
return generateReactConfig(options);
|
|
202
|
-
}
|
|
203
|
-
else if (isWebFramework(options)) {
|
|
204
|
-
return generateWebConfig(tree, options, defaultConfig);
|
|
129
|
+
return generateReactConfig(tree, options, project, buildOptions);
|
|
205
130
|
}
|
|
206
|
-
else if (options.framework === 'nest') {
|
|
207
|
-
return generateNestConfig(
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
return generateGenericConfig(tree, options, defaultConfig);
|
|
131
|
+
else if (options.framework === 'nest' && !isWebFramework(options)) {
|
|
132
|
+
return generateNestConfig(project, buildOptions);
|
|
211
133
|
}
|
|
134
|
+
return defaultConfig;
|
|
212
135
|
}
|
|
213
136
|
function createBuildOptions(tree, options, project) {
|
|
214
137
|
return {
|
|
@@ -241,41 +164,38 @@ module.exports = {
|
|
|
241
164
|
function isWebFramework(options) {
|
|
242
165
|
return options.framework === 'web' || options.target === 'web';
|
|
243
166
|
}
|
|
244
|
-
function
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
167
|
+
function generateReactConfig(tree, options, project, buildOptions) {
|
|
168
|
+
const assets = ['src/favicon.ico', 'src/assets']
|
|
169
|
+
.map((asset) => (0, devkit_1.joinPathFragments)(project.root, asset))
|
|
170
|
+
.filter((asset) => tree.exists(asset));
|
|
248
171
|
return `
|
|
249
|
-
const {
|
|
250
|
-
|
|
172
|
+
const { NxAppRspackPlugin } = require('@nx/rspack/app-plugin');
|
|
173
|
+
const { NxReactRspackPlugin } = require('@nx/rspack/react-plugin');
|
|
174
|
+
const { join } = require('path');
|
|
175
|
+
|
|
176
|
+
module.exports = {
|
|
177
|
+
output: {
|
|
178
|
+
path: join(__dirname, '${(0, devkit_1.offsetFromRoot)(project.root)}${buildOptions.outputPath}'),
|
|
179
|
+
},
|
|
180
|
+
plugins: [
|
|
181
|
+
new NxAppRspackPlugin({
|
|
182
|
+
tsConfig: '${buildOptions.tsConfig}',
|
|
183
|
+
main: '${buildOptions.main}',
|
|
184
|
+
index: '${(0, devkit_1.joinPathFragments)(project.root, 'src/index.html')}',
|
|
185
|
+
assets: ${JSON.stringify(assets)},${options.stylePreprocessorOptions
|
|
251
186
|
? `
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
187
|
+
stylePreprocessorOptions: ${JSON.stringify(options.stylePreprocessorOptions)},`
|
|
188
|
+
: ''}
|
|
189
|
+
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
|
|
190
|
+
optimization: process.env['NODE_ENV'] === 'production',
|
|
191
|
+
}),
|
|
192
|
+
new NxReactRspackPlugin(),
|
|
193
|
+
],
|
|
194
|
+
};
|
|
259
195
|
`;
|
|
260
196
|
}
|
|
261
|
-
function
|
|
197
|
+
function generateNestConfig(project, buildOptions) {
|
|
262
198
|
return `
|
|
263
|
-
const { composePlugins, withNx, withReact } = require('@nx/rspack');
|
|
264
|
-
|
|
265
|
-
module.exports = composePlugins(withNx(), withReact(${stylePreprocessorOptions
|
|
266
|
-
? `
|
|
267
|
-
{
|
|
268
|
-
stylePreprocessorOptions: ${JSON.stringify(stylePreprocessorOptions)},
|
|
269
|
-
}
|
|
270
|
-
`
|
|
271
|
-
: ''}), (config) => {
|
|
272
|
-
return config;
|
|
273
|
-
});
|
|
274
|
-
`;
|
|
275
|
-
}
|
|
276
|
-
function generateNestConfig(tree, options, project, buildOptions) {
|
|
277
|
-
if ((0, has_plugin_1.hasPlugin)(tree) && options.addPlugin !== false) {
|
|
278
|
-
return `
|
|
279
199
|
const { NxAppRspackPlugin } = require('@nx/rspack/app-plugin');
|
|
280
200
|
const rspack = require('@rspack/core');
|
|
281
201
|
const { join } = require('path');
|
|
@@ -309,48 +229,6 @@ module.exports = {
|
|
|
309
229
|
})
|
|
310
230
|
]
|
|
311
231
|
}`;
|
|
312
|
-
}
|
|
313
|
-
return `
|
|
314
|
-
const { composePlugins, withNx } = require('@nx/rspack');
|
|
315
|
-
const rspack = require('@rspack/core');
|
|
316
|
-
|
|
317
|
-
module.exports = composePlugins(withNx(), (config) => {
|
|
318
|
-
config.optimization = {
|
|
319
|
-
minimizer: [
|
|
320
|
-
new rspack.SwcJsMinimizerRspackPlugin({
|
|
321
|
-
minimizerOptions: {
|
|
322
|
-
compress: {
|
|
323
|
-
keep_classnames: true,
|
|
324
|
-
keep_fnames: true,
|
|
325
|
-
},
|
|
326
|
-
mangle: {
|
|
327
|
-
keep_classnames: true,
|
|
328
|
-
keep_fnames: true,
|
|
329
|
-
},
|
|
330
|
-
},
|
|
331
|
-
}),
|
|
332
|
-
],
|
|
333
|
-
};
|
|
334
|
-
return config;
|
|
335
|
-
});
|
|
336
|
-
`;
|
|
337
|
-
}
|
|
338
|
-
function generateGenericConfig(tree, options, defaultConfig) {
|
|
339
|
-
if ((0, has_plugin_1.hasPlugin)(tree)) {
|
|
340
|
-
return defaultConfig;
|
|
341
|
-
}
|
|
342
|
-
return `
|
|
343
|
-
const { composePlugins, withNx${options.stylePreprocessorOptions ? ', withWeb' : ''} } = require('@nx/rspack');
|
|
344
|
-
|
|
345
|
-
module.exports = composePlugins(withNx()${options.stylePreprocessorOptions
|
|
346
|
-
? `,
|
|
347
|
-
withWeb({
|
|
348
|
-
stylePreprocessorOptions: ${JSON.stringify(options.stylePreprocessorOptions)},
|
|
349
|
-
})`
|
|
350
|
-
: ''}, (config) => {
|
|
351
|
-
return config;
|
|
352
|
-
});
|
|
353
|
-
`;
|
|
354
232
|
}
|
|
355
233
|
function deleteWebpackConfig(tree, projectRoot, webpackConfigFilePath) {
|
|
356
234
|
const webpackConfigPath = webpackConfigFilePath && tree.exists(webpackConfigFilePath)
|
|
@@ -427,52 +305,52 @@ function getViteConfigPathForProject(tree, projectName, target) {
|
|
|
427
305
|
}
|
|
428
306
|
async function handleUnsupportedUserProvidedTargets(userProvidedTargetIsUnsupported, userProvidedTargetName, validFoundTargetName, framework) {
|
|
429
307
|
if (userProvidedTargetIsUnsupported.build && validFoundTargetName.build) {
|
|
430
|
-
await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.build, validFoundTargetName.build, 'build'
|
|
308
|
+
await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.build, validFoundTargetName.build, 'build');
|
|
431
309
|
}
|
|
432
310
|
if (framework !== 'nest' &&
|
|
433
311
|
userProvidedTargetIsUnsupported.serve &&
|
|
434
312
|
validFoundTargetName.serve) {
|
|
435
|
-
await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.serve, validFoundTargetName.serve, 'serve'
|
|
313
|
+
await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.serve, validFoundTargetName.serve, 'serve');
|
|
436
314
|
}
|
|
437
315
|
}
|
|
438
|
-
async function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName, validFoundTargetName, target
|
|
439
|
-
devkit_1.logger.warn(`The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use
|
|
316
|
+
async function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName, validFoundTargetName, target) {
|
|
317
|
+
devkit_1.logger.warn(`The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use Rspack.
|
|
440
318
|
However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}
|
|
441
319
|
|
|
442
|
-
Please note that converting a potentially non-compatible project to use
|
|
443
|
-
your changes before converting a project to use
|
|
320
|
+
Please note that converting a potentially non-compatible project to use Rspack may result in unexpected behavior. Always commit
|
|
321
|
+
your changes before converting a project to use Rspack, and test the converted project thoroughly before deploying it.
|
|
444
322
|
`);
|
|
445
323
|
const shouldConvert = await (0, internal_1.confirmationPrompt)({
|
|
446
|
-
message: `Should we convert the ${validFoundTargetName} target to use
|
|
324
|
+
message: `Should we convert the ${validFoundTargetName} target to use Rspack?`,
|
|
447
325
|
});
|
|
448
326
|
if (!shouldConvert) {
|
|
449
|
-
throw new Error(`The ${target} target ${userProvidedTargetName} cannot be converted to use
|
|
327
|
+
throw new Error(`The ${target} target ${userProvidedTargetName} cannot be converted to use Rspack.
|
|
450
328
|
Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will
|
|
451
329
|
convert the first one it finds, most probably this one: ${validFoundTargetName})
|
|
452
330
|
|
|
453
|
-
Please note that converting a potentially non-compatible project to use
|
|
454
|
-
your changes before converting a project to use
|
|
331
|
+
Please note that converting a potentially non-compatible project to use Rspack may result in unexpected behavior. Always commit
|
|
332
|
+
your changes before converting a project to use Rspack, and test the converted project thoroughly before deploying it.
|
|
455
333
|
`);
|
|
456
334
|
}
|
|
457
335
|
}
|
|
458
336
|
async function handleUnknownExecutors(projectName) {
|
|
459
337
|
devkit_1.logger.warn(`
|
|
460
338
|
We could not find any targets in project ${projectName} that use executors which
|
|
461
|
-
can be converted to
|
|
339
|
+
can be converted to Rspack.
|
|
462
340
|
|
|
463
341
|
This either means that your project may not have a target
|
|
464
342
|
for building, serving, or testing at all, or that your targets are
|
|
465
343
|
using executors that are not known to Nx.
|
|
466
344
|
|
|
467
|
-
If you still want to convert your project to use
|
|
345
|
+
If you still want to convert your project to use Rspack,
|
|
468
346
|
please make sure to commit your changes before running this generator.
|
|
469
347
|
`);
|
|
470
348
|
const shouldConvert = await (0, internal_1.confirmationPrompt)({
|
|
471
|
-
message: `Should Nx convert your project to use
|
|
349
|
+
message: `Should Nx convert your project to use Rspack?`,
|
|
472
350
|
});
|
|
473
351
|
if (!shouldConvert) {
|
|
474
352
|
throw new Error(`
|
|
475
|
-
Nx could not verify that the executors you are using can be converted to
|
|
353
|
+
Nx could not verify that the executors you are using can be converted to Rspack.
|
|
476
354
|
Please try again with a different project.
|
|
477
355
|
`);
|
|
478
356
|
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { NxComposableRspackPlugin } from './config';
|
|
2
|
+
import type { NxAppRspackPluginOptions } from '../plugins/utils/models';
|
|
3
3
|
export type WithNxOptions = Partial<NxAppRspackPluginOptions>;
|
|
4
4
|
/**
|
|
5
|
-
* @deprecated
|
|
6
|
-
*
|
|
7
|
-
* `nx g @nx/rspack:convert-to-inferred`. See
|
|
8
|
-
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
|
|
9
|
-
* @param {WithNxOptions} pluginOptions
|
|
10
|
-
* @returns {NxComposableRspackPlugin}
|
|
5
|
+
* @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin`.
|
|
6
|
+
* This inert stub will be removed in Nx v25.
|
|
11
7
|
*/
|
|
12
|
-
export declare function withNx(
|
|
8
|
+
export declare function withNx(_options?: WithNxOptions): NxComposableRspackPlugin;
|
|
@@ -1,40 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withNx = withNx;
|
|
4
|
-
const normalize_assets_1 = require("./normalize-assets");
|
|
5
|
-
const apply_base_config_1 = require("../plugins/utils/apply-base-config");
|
|
6
4
|
const deprecation_1 = require("./deprecation");
|
|
7
|
-
|
|
5
|
+
// TODO(v25): remove the inert config-helper stubs in this file.
|
|
8
6
|
/**
|
|
9
|
-
* @deprecated
|
|
10
|
-
*
|
|
11
|
-
* `nx g @nx/rspack:convert-to-inferred`. See
|
|
12
|
-
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
|
|
13
|
-
* @param {WithNxOptions} pluginOptions
|
|
14
|
-
* @returns {NxComposableRspackPlugin}
|
|
7
|
+
* @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin`.
|
|
8
|
+
* This inert stub will be removed in Nx v25.
|
|
15
9
|
*/
|
|
16
|
-
function withNx(
|
|
10
|
+
function withNx(_options = {}) {
|
|
17
11
|
(0, deprecation_1.warnRspackComposeHelpersDeprecation)();
|
|
18
|
-
return
|
|
19
|
-
if (processed.has(config))
|
|
20
|
-
return config;
|
|
21
|
-
(0, apply_base_config_1.applyBaseConfig)({
|
|
22
|
-
...options,
|
|
23
|
-
...pluginOptions,
|
|
24
|
-
target: options.target ?? 'web',
|
|
25
|
-
assets: options.assets
|
|
26
|
-
? options.assets
|
|
27
|
-
: pluginOptions.assets
|
|
28
|
-
? (0, normalize_assets_1.normalizeAssets)(pluginOptions.assets, options.root, options.sourceRoot)
|
|
29
|
-
: [],
|
|
30
|
-
root: context.root,
|
|
31
|
-
projectName: context.projectName,
|
|
32
|
-
targetName: context.targetName,
|
|
33
|
-
configurationName: context.configurationName,
|
|
34
|
-
projectGraph: context.projectGraph,
|
|
35
|
-
useLegacyHtmlPlugin: pluginOptions.useLegacyHtmlPlugin ?? false,
|
|
36
|
-
}, config);
|
|
37
|
-
processed.add(config);
|
|
38
|
-
return config;
|
|
39
|
-
};
|
|
12
|
+
return (config) => config;
|
|
40
13
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import { WithWebOptions } from './with-web';
|
|
1
|
+
import type { NxComposableRspackPlugin } from './config';
|
|
2
|
+
import type { WithWebOptions } from './with-web';
|
|
4
3
|
export interface WithReactOptions extends WithWebOptions {
|
|
5
4
|
}
|
|
6
5
|
/**
|
|
7
|
-
* @deprecated
|
|
8
|
-
*
|
|
9
|
-
* `nx g @nx/rspack:convert-to-inferred`. See
|
|
10
|
-
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
|
|
6
|
+
* @deprecated Use `NxReactRspackPlugin` from `@nx/rspack/react-plugin`.
|
|
7
|
+
* This inert stub will be removed in Nx v25.
|
|
11
8
|
*/
|
|
12
|
-
export declare function withReact(
|
|
9
|
+
export declare function withReact(_options?: WithReactOptions): NxComposableRspackPlugin;
|