@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
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findExistingTargetsInProject = findExistingTargetsInProject;
|
|
4
|
-
exports.
|
|
5
|
-
exports.addOrChangeServeTarget = addOrChangeServeTarget;
|
|
4
|
+
exports.assertNoRemovedExecutorTargets = assertNoRemovedExecutorTargets;
|
|
6
5
|
exports.writeRspackConfigFile = writeRspackConfigFile;
|
|
7
6
|
exports.deleteWebpackConfig = deleteWebpackConfig;
|
|
8
7
|
exports.moveAndEditIndexHtml = moveAndEditIndexHtml;
|
|
@@ -16,7 +15,6 @@ exports.determineTsConfig = determineTsConfig;
|
|
|
16
15
|
const internal_1 = require("@nx/devkit/internal");
|
|
17
16
|
const devkit_1 = require("@nx/devkit");
|
|
18
17
|
const internal_2 = require("@nx/js/internal");
|
|
19
|
-
const has_plugin_1 = require("./has-plugin");
|
|
20
18
|
function findExistingTargetsInProject(targets, userProvidedTargets) {
|
|
21
19
|
const output = {
|
|
22
20
|
validFoundTargetName: {},
|
|
@@ -25,24 +23,8 @@ function findExistingTargetsInProject(targets, userProvidedTargets) {
|
|
|
25
23
|
alreadyHasNxRspackTargets: {},
|
|
26
24
|
};
|
|
27
25
|
const supportedExecutors = {
|
|
28
|
-
build: [
|
|
29
|
-
|
|
30
|
-
'@nrwl/webpack:webpack',
|
|
31
|
-
'@nrwl/rollup:rollup',
|
|
32
|
-
'@nrwl/web:rollup',
|
|
33
|
-
'@nrwl/vite:build',
|
|
34
|
-
'@nx/webpack:webpack',
|
|
35
|
-
'@nx/rollup:rollup',
|
|
36
|
-
'@nx/web:rollup',
|
|
37
|
-
'@nx/vite:build',
|
|
38
|
-
],
|
|
39
|
-
serve: [
|
|
40
|
-
'@nxext/vite:dev',
|
|
41
|
-
'@nrwl/webpack:dev-server',
|
|
42
|
-
'@nrwl/vite:dev-server',
|
|
43
|
-
'@nx/webpack:dev-server',
|
|
44
|
-
'@nx/vite:dev-server',
|
|
45
|
-
],
|
|
26
|
+
build: ['@nxext/vite:build'],
|
|
27
|
+
serve: ['@nxext/vite:dev'],
|
|
46
28
|
};
|
|
47
29
|
const unsupportedExecutors = [
|
|
48
30
|
'@nx/js:babel',
|
|
@@ -120,74 +102,27 @@ function findExistingTargetsInProject(targets, userProvidedTargets) {
|
|
|
120
102
|
}
|
|
121
103
|
return output;
|
|
122
104
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
105
|
+
// A leftover target on one of these can't run, and it shadows the inferred
|
|
106
|
+
// target with the same name, so converting around it leaves a broken project.
|
|
107
|
+
const removedConvertibleExecutors = [
|
|
108
|
+
'@nrwl/rollup:rollup',
|
|
109
|
+
'@nrwl/vite:build',
|
|
110
|
+
'@nrwl/vite:dev-server',
|
|
111
|
+
'@nrwl/webpack:dev-server',
|
|
112
|
+
'@nrwl/webpack:webpack',
|
|
113
|
+
'@nx/rollup:rollup',
|
|
114
|
+
'@nx/vite:build',
|
|
115
|
+
'@nx/vite:dev-server',
|
|
116
|
+
'@nx/webpack:dev-server',
|
|
117
|
+
'@nx/webpack:webpack',
|
|
118
|
+
];
|
|
119
|
+
function assertNoRemovedExecutorTargets(projectName, targets) {
|
|
120
|
+
const removedTargets = Object.entries(targets ?? {})
|
|
121
|
+
.filter(([, target]) => removedConvertibleExecutors.includes(target.executor))
|
|
122
|
+
.map(([targetName, target]) => `${targetName} (${target.executor})`);
|
|
123
|
+
if (removedTargets.length) {
|
|
124
|
+
throw new Error(`The project ${projectName} has targets using removed executors: ${removedTargets.join(', ')}. Convert them to inferred targets first, for example with "nx g @nx/workspace:infer-targets --project=${projectName}".`);
|
|
132
125
|
}
|
|
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
126
|
}
|
|
192
127
|
function writeRspackConfigFile(tree, options, stylePreprocessorOptions) {
|
|
193
128
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
@@ -198,17 +133,12 @@ function createConfig(tree, options) {
|
|
|
198
133
|
const buildOptions = createBuildOptions(tree, options, project);
|
|
199
134
|
const defaultConfig = generateDefaultConfig(project, buildOptions);
|
|
200
135
|
if (options.framework === 'react') {
|
|
201
|
-
return generateReactConfig(options);
|
|
202
|
-
}
|
|
203
|
-
else if (isWebFramework(options)) {
|
|
204
|
-
return generateWebConfig(tree, options, defaultConfig);
|
|
136
|
+
return generateReactConfig(tree, options, project, buildOptions);
|
|
205
137
|
}
|
|
206
|
-
else if (options.framework === 'nest') {
|
|
207
|
-
return generateNestConfig(
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
return generateGenericConfig(tree, options, defaultConfig);
|
|
138
|
+
else if (options.framework === 'nest' && !isWebFramework(options)) {
|
|
139
|
+
return generateNestConfig(project, buildOptions);
|
|
211
140
|
}
|
|
141
|
+
return defaultConfig;
|
|
212
142
|
}
|
|
213
143
|
function createBuildOptions(tree, options, project) {
|
|
214
144
|
return {
|
|
@@ -241,41 +171,38 @@ module.exports = {
|
|
|
241
171
|
function isWebFramework(options) {
|
|
242
172
|
return options.framework === 'web' || options.target === 'web';
|
|
243
173
|
}
|
|
244
|
-
function
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
174
|
+
function generateReactConfig(tree, options, project, buildOptions) {
|
|
175
|
+
const assets = ['src/favicon.ico', 'src/assets']
|
|
176
|
+
.map((asset) => (0, devkit_1.joinPathFragments)(project.root, asset))
|
|
177
|
+
.filter((asset) => tree.exists(asset));
|
|
248
178
|
return `
|
|
249
|
-
const {
|
|
250
|
-
|
|
179
|
+
const { NxAppRspackPlugin } = require('@nx/rspack/app-plugin');
|
|
180
|
+
const { NxReactRspackPlugin } = require('@nx/rspack/react-plugin');
|
|
181
|
+
const { join } = require('path');
|
|
182
|
+
|
|
183
|
+
module.exports = {
|
|
184
|
+
output: {
|
|
185
|
+
path: join(__dirname, '${(0, devkit_1.offsetFromRoot)(project.root)}${buildOptions.outputPath}'),
|
|
186
|
+
},
|
|
187
|
+
plugins: [
|
|
188
|
+
new NxAppRspackPlugin({
|
|
189
|
+
tsConfig: '${buildOptions.tsConfig}',
|
|
190
|
+
main: '${buildOptions.main}',
|
|
191
|
+
index: '${(0, devkit_1.joinPathFragments)(project.root, 'src/index.html')}',
|
|
192
|
+
assets: ${JSON.stringify(assets)},${options.stylePreprocessorOptions
|
|
251
193
|
? `
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
194
|
+
stylePreprocessorOptions: ${JSON.stringify(options.stylePreprocessorOptions)},`
|
|
195
|
+
: ''}
|
|
196
|
+
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
|
|
197
|
+
optimization: process.env['NODE_ENV'] === 'production',
|
|
198
|
+
}),
|
|
199
|
+
new NxReactRspackPlugin(),
|
|
200
|
+
],
|
|
201
|
+
};
|
|
259
202
|
`;
|
|
260
203
|
}
|
|
261
|
-
function
|
|
204
|
+
function generateNestConfig(project, buildOptions) {
|
|
262
205
|
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
206
|
const { NxAppRspackPlugin } = require('@nx/rspack/app-plugin');
|
|
280
207
|
const rspack = require('@rspack/core');
|
|
281
208
|
const { join } = require('path');
|
|
@@ -309,48 +236,6 @@ module.exports = {
|
|
|
309
236
|
})
|
|
310
237
|
]
|
|
311
238
|
}`;
|
|
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
239
|
}
|
|
355
240
|
function deleteWebpackConfig(tree, projectRoot, webpackConfigFilePath) {
|
|
356
241
|
const webpackConfigPath = webpackConfigFilePath && tree.exists(webpackConfigFilePath)
|
|
@@ -427,52 +312,52 @@ function getViteConfigPathForProject(tree, projectName, target) {
|
|
|
427
312
|
}
|
|
428
313
|
async function handleUnsupportedUserProvidedTargets(userProvidedTargetIsUnsupported, userProvidedTargetName, validFoundTargetName, framework) {
|
|
429
314
|
if (userProvidedTargetIsUnsupported.build && validFoundTargetName.build) {
|
|
430
|
-
await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.build, validFoundTargetName.build, 'build'
|
|
315
|
+
await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.build, validFoundTargetName.build, 'build');
|
|
431
316
|
}
|
|
432
317
|
if (framework !== 'nest' &&
|
|
433
318
|
userProvidedTargetIsUnsupported.serve &&
|
|
434
319
|
validFoundTargetName.serve) {
|
|
435
|
-
await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.serve, validFoundTargetName.serve, 'serve'
|
|
320
|
+
await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.serve, validFoundTargetName.serve, 'serve');
|
|
436
321
|
}
|
|
437
322
|
}
|
|
438
|
-
async function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName, validFoundTargetName, target
|
|
439
|
-
devkit_1.logger.warn(`The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use
|
|
323
|
+
async function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName, validFoundTargetName, target) {
|
|
324
|
+
devkit_1.logger.warn(`The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use Rspack.
|
|
440
325
|
However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}
|
|
441
326
|
|
|
442
|
-
Please note that converting a potentially non-compatible project to use
|
|
443
|
-
your changes before converting a project to use
|
|
327
|
+
Please note that converting a potentially non-compatible project to use Rspack may result in unexpected behavior. Always commit
|
|
328
|
+
your changes before converting a project to use Rspack, and test the converted project thoroughly before deploying it.
|
|
444
329
|
`);
|
|
445
330
|
const shouldConvert = await (0, internal_1.confirmationPrompt)({
|
|
446
|
-
message: `Should we convert the ${validFoundTargetName} target to use
|
|
331
|
+
message: `Should we convert the ${validFoundTargetName} target to use Rspack?`,
|
|
447
332
|
});
|
|
448
333
|
if (!shouldConvert) {
|
|
449
|
-
throw new Error(`The ${target} target ${userProvidedTargetName} cannot be converted to use
|
|
334
|
+
throw new Error(`The ${target} target ${userProvidedTargetName} cannot be converted to use Rspack.
|
|
450
335
|
Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will
|
|
451
336
|
convert the first one it finds, most probably this one: ${validFoundTargetName})
|
|
452
337
|
|
|
453
|
-
Please note that converting a potentially non-compatible project to use
|
|
454
|
-
your changes before converting a project to use
|
|
338
|
+
Please note that converting a potentially non-compatible project to use Rspack may result in unexpected behavior. Always commit
|
|
339
|
+
your changes before converting a project to use Rspack, and test the converted project thoroughly before deploying it.
|
|
455
340
|
`);
|
|
456
341
|
}
|
|
457
342
|
}
|
|
458
343
|
async function handleUnknownExecutors(projectName) {
|
|
459
344
|
devkit_1.logger.warn(`
|
|
460
345
|
We could not find any targets in project ${projectName} that use executors which
|
|
461
|
-
can be converted to
|
|
346
|
+
can be converted to Rspack.
|
|
462
347
|
|
|
463
348
|
This either means that your project may not have a target
|
|
464
349
|
for building, serving, or testing at all, or that your targets are
|
|
465
350
|
using executors that are not known to Nx.
|
|
466
351
|
|
|
467
|
-
If you still want to convert your project to use
|
|
352
|
+
If you still want to convert your project to use Rspack,
|
|
468
353
|
please make sure to commit your changes before running this generator.
|
|
469
354
|
`);
|
|
470
355
|
const shouldConvert = await (0, internal_1.confirmationPrompt)({
|
|
471
|
-
message: `Should Nx convert your project to use
|
|
356
|
+
message: `Should Nx convert your project to use Rspack?`,
|
|
472
357
|
});
|
|
473
358
|
if (!shouldConvert) {
|
|
474
359
|
throw new Error(`
|
|
475
|
-
Nx could not verify that the executors you are using can be converted to
|
|
360
|
+
Nx could not verify that the executors you are using can be converted to Rspack.
|
|
476
361
|
Please try again with a different project.
|
|
477
362
|
`);
|
|
478
363
|
}
|
|
@@ -484,8 +369,7 @@ function determineFrameworkAndTarget(tree, options, projectRoot, targets) {
|
|
|
484
369
|
if (options.target !== 'node') {
|
|
485
370
|
// Try to infer from jest config if the env is node
|
|
486
371
|
let jestConfigPath;
|
|
487
|
-
if (targets?.test?.
|
|
488
|
-
targets?.test?.options?.jestConfig) {
|
|
372
|
+
if (targets?.test?.options?.jestConfig) {
|
|
489
373
|
jestConfigPath = targets?.test?.options?.jestConfig;
|
|
490
374
|
}
|
|
491
375
|
else {
|
|
@@ -8,4 +8,4 @@ import type { Configuration } from '@rspack/core';
|
|
|
8
8
|
*
|
|
9
9
|
* @param rspackConfig
|
|
10
10
|
*/
|
|
11
|
-
export declare function readRspackOptions(rspackConfig: unknown): Promise<Configuration[]>;
|
|
11
|
+
export declare function readRspackOptions(rspackConfig: unknown, env?: Record<string, unknown>, argv?: Record<string, unknown>): Promise<Configuration[]>;
|
|
@@ -13,7 +13,9 @@ const internal_1 = require("@nx/devkit/internal");
|
|
|
13
13
|
*
|
|
14
14
|
* @param rspackConfig
|
|
15
15
|
*/
|
|
16
|
-
async function readRspackOptions(rspackConfig
|
|
16
|
+
async function readRspackOptions(rspackConfig,
|
|
17
|
+
// A function config gets the production build's env unless told otherwise
|
|
18
|
+
env = { production: true }, argv = {}) {
|
|
17
19
|
const configs = [];
|
|
18
20
|
const resolveConfig = async (config) => {
|
|
19
21
|
if ((0, config_1.isNxRspackComposablePlugin)(config)) {
|
|
@@ -43,9 +45,7 @@ async function readRspackOptions(rspackConfig) {
|
|
|
43
45
|
});
|
|
44
46
|
}
|
|
45
47
|
else if (typeof config === 'function') {
|
|
46
|
-
const resolved = await config(
|
|
47
|
-
production: true, // we want the production build options
|
|
48
|
-
}, {});
|
|
48
|
+
const resolved = await config(env, argv);
|
|
49
49
|
// If the resolved configuration is an array, resolve each configuration
|
|
50
50
|
return Array.isArray(resolved)
|
|
51
51
|
? (await Promise.all(resolved.map(resolveConfig))).flat()
|
|
@@ -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;
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withReact = withReact;
|
|
4
|
-
const with_web_1 = require("./with-web");
|
|
5
|
-
const apply_react_config_1 = require("../plugins/utils/apply-react-config");
|
|
6
4
|
const deprecation_1 = require("./deprecation");
|
|
5
|
+
// TODO(v25): remove the inert config-helper stubs in this file.
|
|
7
6
|
/**
|
|
8
|
-
* @deprecated
|
|
9
|
-
*
|
|
10
|
-
* `nx g @nx/rspack:convert-to-inferred`. See
|
|
11
|
-
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
|
|
7
|
+
* @deprecated Use `NxReactRspackPlugin` from `@nx/rspack/react-plugin`.
|
|
8
|
+
* This inert stub will be removed in Nx v25.
|
|
12
9
|
*/
|
|
13
|
-
function withReact(
|
|
10
|
+
function withReact(_options = {}) {
|
|
14
11
|
(0, deprecation_1.warnRspackComposeHelpersDeprecation)();
|
|
15
|
-
return
|
|
16
|
-
config = (0, with_web_1.withWeb)({ ...opts, cssModules: true })(config, {
|
|
17
|
-
options,
|
|
18
|
-
context,
|
|
19
|
-
});
|
|
20
|
-
(0, apply_react_config_1.applyReactConfig)({}, config);
|
|
21
|
-
return config;
|
|
22
|
-
};
|
|
12
|
+
return (config) => config;
|
|
23
13
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { ExtraEntryPointClass } from './model';
|
|
3
|
-
import { NxRspackExecutionContext } from './config';
|
|
1
|
+
import type { NxComposableRspackPlugin } from './config';
|
|
2
|
+
import type { ExtraEntryPointClass } from './model';
|
|
4
3
|
export interface WithWebOptions {
|
|
5
4
|
baseHref?: string;
|
|
6
5
|
deployUrl?: string;
|
|
@@ -28,9 +27,7 @@ export interface WithWebOptions {
|
|
|
28
27
|
templateParameters?: Record<string, string> | boolean | ((params: Record<string, any>) => Record<string, any> | Promise<Record<string, any>>);
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
|
-
* @deprecated
|
|
32
|
-
*
|
|
33
|
-
* `nx g @nx/rspack:convert-to-inferred`. See
|
|
34
|
-
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
|
|
30
|
+
* @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin`.
|
|
31
|
+
* This inert stub will be removed in Nx v25.
|
|
35
32
|
*/
|
|
36
|
-
export declare function withWeb(
|
|
33
|
+
export declare function withWeb(_options?: WithWebOptions): NxComposableRspackPlugin;
|
|
@@ -1,52 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withWeb = withWeb;
|
|
4
|
-
const apply_web_config_1 = require("../plugins/utils/apply-web-config");
|
|
5
4
|
const deprecation_1 = require("./deprecation");
|
|
6
|
-
|
|
5
|
+
// TODO(v25): remove the inert config-helper stubs in this file.
|
|
7
6
|
/**
|
|
8
|
-
* @deprecated
|
|
9
|
-
*
|
|
10
|
-
* `nx g @nx/rspack:convert-to-inferred`. See
|
|
11
|
-
* https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
|
|
7
|
+
* @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin`.
|
|
8
|
+
* This inert stub will be removed in Nx v25.
|
|
12
9
|
*/
|
|
13
|
-
function withWeb(
|
|
10
|
+
function withWeb(_options = {}) {
|
|
14
11
|
(0, deprecation_1.warnRspackComposeHelpersDeprecation)();
|
|
15
|
-
return
|
|
16
|
-
if (processed.has(config)) {
|
|
17
|
-
return config;
|
|
18
|
-
}
|
|
19
|
-
(0, apply_web_config_1.applyWebConfig)({
|
|
20
|
-
...options,
|
|
21
|
-
...pluginOptions,
|
|
22
|
-
root: context.root,
|
|
23
|
-
projectName: context.projectName,
|
|
24
|
-
targetName: context.targetName,
|
|
25
|
-
configurationName: context.configurationName,
|
|
26
|
-
projectGraph: context.projectGraph,
|
|
27
|
-
useLegacyHtmlPlugin: pluginOptions.useLegacyHtmlPlugin ?? false,
|
|
28
|
-
}, config);
|
|
29
|
-
processed.add(config);
|
|
30
|
-
return config;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function getClientEnvironment(mode) {
|
|
34
|
-
// Grab NODE_ENV and NX_PUBLIC_* environment variables and prepare them to be
|
|
35
|
-
// injected into the application via DefinePlugin in rspack configuration.
|
|
36
|
-
const nxPublicKeyRegex = /^NX_PUBLIC_/i;
|
|
37
|
-
const raw = Object.keys(process.env)
|
|
38
|
-
.filter((key) => nxPublicKeyRegex.test(key))
|
|
39
|
-
.reduce((env, key) => {
|
|
40
|
-
env[key] = process.env[key];
|
|
41
|
-
return env;
|
|
42
|
-
}, {});
|
|
43
|
-
// Stringify all values so we can feed into rspack DefinePlugin
|
|
44
|
-
const stringified = Object.keys(raw).reduce((env, key) => {
|
|
45
|
-
env[`process.env.${key}`] = JSON.stringify(raw[key]);
|
|
46
|
-
return env;
|
|
47
|
-
},
|
|
48
|
-
// Provide a fallback for process.env itself to handle cases where code
|
|
49
|
-
// accesses process.env directly (e.g., in Cypress component testing)
|
|
50
|
-
{ 'process.env': '({})' });
|
|
51
|
-
return { stringified };
|
|
12
|
+
return (config) => config;
|
|
52
13
|
}
|
package/executors.json
CHANGED
|
@@ -1,35 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"executors": {
|
|
4
|
-
"rspack": {
|
|
5
|
-
"implementation": "./dist/src/executors/rspack/rspack.impl",
|
|
6
|
-
"schema": "./dist/src/executors/rspack/schema.json",
|
|
7
|
-
"description": "Run Rspack via an executor for a project."
|
|
8
|
-
},
|
|
9
|
-
"dev-server": {
|
|
10
|
-
"implementation": "./dist/src/executors/dev-server/dev-server.impl",
|
|
11
|
-
"schema": "./dist/src/executors/dev-server/schema.json",
|
|
12
|
-
"description": "Run @rspack/dev-server to serve a project."
|
|
13
|
-
},
|
|
14
4
|
"ssr-dev-server": {
|
|
15
5
|
"implementation": "./dist/src/executors/ssr-dev-server/ssr-dev-server.impl",
|
|
16
6
|
"schema": "./dist/src/executors/ssr-dev-server/schema.json",
|
|
17
7
|
"description": "Serve a SSR application."
|
|
18
|
-
},
|
|
19
|
-
"module-federation-dev-server": {
|
|
20
|
-
"implementation": "./dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl",
|
|
21
|
-
"schema": "./dist/src/executors/module-federation-dev-server/schema.json",
|
|
22
|
-
"description": "Serve a host or remote application."
|
|
23
|
-
},
|
|
24
|
-
"module-federation-ssr-dev-server": {
|
|
25
|
-
"implementation": "./dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl",
|
|
26
|
-
"schema": "./dist/src/executors/module-federation-ssr-dev-server/schema.json",
|
|
27
|
-
"description": "Serve a host application along with it's known remotes."
|
|
28
|
-
},
|
|
29
|
-
"module-federation-static-server": {
|
|
30
|
-
"implementation": "./dist/src/executors/module-federation-static-server/module-federation-static-server.impl",
|
|
31
|
-
"schema": "./dist/src/executors/module-federation-static-server/schema.json",
|
|
32
|
-
"description": "Serve a host and its remotes statically."
|
|
33
8
|
}
|
|
34
9
|
}
|
|
35
10
|
}
|
package/migrations.json
CHANGED
|
@@ -36,6 +36,19 @@
|
|
|
36
36
|
"requires": {
|
|
37
37
|
"@rspack/core": ">=2.0.0"
|
|
38
38
|
}
|
|
39
|
+
},
|
|
40
|
+
"remove-deprecated-executors": {
|
|
41
|
+
"version": "24.0.0-beta.3",
|
|
42
|
+
"description": "Converts targets using the removed `@nx/rspack` executors to inferred tasks; an AI prompt finishes the targets the converter cannot convert safely and validates the project graph.",
|
|
43
|
+
"implementation": "./dist/src/migrations/update-24-0-0/remove-deprecated-executors",
|
|
44
|
+
"prompt": "./dist/src/migrations/update-24-0-0/finish-inferred-conversion.md",
|
|
45
|
+
"documentation": "./dist/src/migrations/update-24-0-0/remove-deprecated-executors.md"
|
|
46
|
+
},
|
|
47
|
+
"update-24-0-0-migrate-compose-plugins": {
|
|
48
|
+
"version": "24.0.0-beta.3",
|
|
49
|
+
"description": "Converts Rspack configs that use the removed `composePlugins`, `withNx`, `withWeb` and `withReact` helpers with `@nx/rspack:convert-config-to-rspack-plugin`, then hands an AI prompt the projects it could not convert and the `.old` configs it left behind.",
|
|
50
|
+
"implementation": "./dist/src/migrations/update-24-0-0/migrate-compose-plugins",
|
|
51
|
+
"prompt": "./dist/src/migrations/update-24-0-0/migrate-compose-plugins.md"
|
|
39
52
|
}
|
|
40
53
|
},
|
|
41
54
|
"packageJsonUpdates": {
|