@nx/rspack 19.8.0 → 20.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/LICENSE +1 -1
- package/README.md +70 -34
- package/executors.json +2 -2
- package/module-federation.js +0 -1
- package/package.json +14 -9
- package/plugin.js +0 -1
- package/src/executors/dev-server/dev-server.impl.js +39 -38
- package/src/executors/dev-server/lib/get-dev-server-config.js +1 -3
- package/src/executors/dev-server/lib/serve-path.js +0 -1
- package/src/executors/dev-server/schema.json +3 -9
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +109 -98
- package/src/executors/module-federation-dev-server/schema.json +1 -3
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +153 -148
- package/src/executors/module-federation-ssr-dev-server/schema.json +1 -4
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.js +117 -125
- package/src/executors/rspack/rspack.impl.js +60 -67
- package/src/executors/rspack/schema.json +6 -26
- package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.js +0 -1
- package/src/executors/ssr-dev-server/schema.json +1 -4
- package/src/executors/ssr-dev-server/ssr-dev-server.impl.js +26 -40
- package/src/generators/application/application.js +79 -76
- package/src/generators/application/lib/create-ts-config.js +5 -3
- package/src/generators/application/lib/normalize-options.js +12 -7
- package/src/generators/application/schema.json +1 -0
- package/src/generators/configuration/configuration.js +63 -65
- package/src/generators/configuration/schema.json +2 -1
- package/src/generators/init/init.js +58 -59
- package/src/generators/init/schema.json +2 -1
- package/src/generators/preset/preset.js +26 -29
- package/src/generators/preset/schema.json +1 -0
- package/src/index.js +0 -1
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -7
- package/src/plugins/generate-package-json-plugin.js +1 -3
- package/src/plugins/plugin.js +81 -90
- package/src/utils/config.js +7 -11
- package/src/utils/create-compiler.js +21 -25
- package/src/utils/generator-utils.js +55 -66
- package/src/utils/get-copy-patterns.js +1 -3
- package/src/utils/jest-utils.js +0 -1
- package/src/utils/mode-utils.js +0 -1
- package/src/utils/model.js +0 -1
- package/src/utils/module-federation/build-static.remotes.js +57 -61
- package/src/utils/module-federation/dependencies.js +1 -3
- package/src/utils/module-federation/get-remotes-for-host.js +4 -8
- package/src/utils/module-federation/index.js +0 -1
- package/src/utils/module-federation/models/index.js +0 -1
- package/src/utils/module-federation/package-json.js +0 -1
- package/src/utils/module-federation/parse-static-remotes-config.js +2 -3
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.js +1 -2
- package/src/utils/module-federation/public-api.js +0 -1
- package/src/utils/module-federation/remotes.js +0 -1
- package/src/utils/module-federation/secondary-entry-points.js +4 -5
- package/src/utils/module-federation/share.js +22 -19
- package/src/utils/module-federation/start-remote-proxies.js +0 -1
- package/src/utils/module-federation/start-ssr-remote-proxies.js +0 -1
- package/src/utils/module-federation/typescript.js +6 -6
- package/src/utils/module-federation/with-module-federation/package-json.js +0 -1
- package/src/utils/module-federation/with-module-federation/utils.js +41 -43
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.js +48 -35
- package/src/utils/module-federation/with-module-federation/with-module-federation.js +56 -38
- package/src/utils/normalize-assets.js +5 -3
- package/src/utils/read-rspack-options.js +23 -27
- package/src/utils/resolve-user-defined-rspack-config.js +0 -1
- package/src/utils/versions.js +0 -1
- package/src/utils/with-nx.js +30 -13
- package/src/utils/with-react.js +11 -5
- package/src/utils/with-web.js +20 -11
- package/module-federation.js.map +0 -1
- package/plugin.js.map +0 -1
- package/src/executors/dev-server/dev-server.impl.js.map +0 -1
- package/src/executors/dev-server/lib/get-dev-server-config.js.map +0 -1
- package/src/executors/dev-server/lib/serve-path.js.map +0 -1
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js.map +0 -1
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js.map +0 -1
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.js.map +0 -1
- package/src/executors/rspack/rspack.impl.js.map +0 -1
- package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.js.map +0 -1
- package/src/executors/ssr-dev-server/ssr-dev-server.impl.js.map +0 -1
- package/src/generators/application/application.js.map +0 -1
- package/src/generators/application/lib/create-ts-config.js.map +0 -1
- package/src/generators/application/lib/normalize-options.js.map +0 -1
- package/src/generators/configuration/configuration.js.map +0 -1
- package/src/generators/init/init.js.map +0 -1
- package/src/generators/preset/preset.js.map +0 -1
- package/src/index.js.map +0 -1
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +0 -1
- package/src/plugins/generate-package-json-plugin.js.map +0 -1
- package/src/plugins/plugin.js.map +0 -1
- package/src/utils/config.js.map +0 -1
- package/src/utils/create-compiler.js.map +0 -1
- package/src/utils/generator-utils.js.map +0 -1
- package/src/utils/get-copy-patterns.js.map +0 -1
- package/src/utils/jest-utils.js.map +0 -1
- package/src/utils/mode-utils.js.map +0 -1
- package/src/utils/model.js.map +0 -1
- package/src/utils/module-federation/build-static.remotes.js.map +0 -1
- package/src/utils/module-federation/dependencies.js.map +0 -1
- package/src/utils/module-federation/get-remotes-for-host.js.map +0 -1
- package/src/utils/module-federation/index.js.map +0 -1
- package/src/utils/module-federation/models/index.js.map +0 -1
- package/src/utils/module-federation/package-json.js.map +0 -1
- package/src/utils/module-federation/parse-static-remotes-config.js.map +0 -1
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.js.map +0 -1
- package/src/utils/module-federation/public-api.js.map +0 -1
- package/src/utils/module-federation/remotes.js.map +0 -1
- package/src/utils/module-federation/secondary-entry-points.js.map +0 -1
- package/src/utils/module-federation/share.js.map +0 -1
- package/src/utils/module-federation/start-remote-proxies.js.map +0 -1
- package/src/utils/module-federation/start-ssr-remote-proxies.js.map +0 -1
- package/src/utils/module-federation/typescript.js.map +0 -1
- package/src/utils/module-federation/with-module-federation/package-json.js.map +0 -1
- package/src/utils/module-federation/with-module-federation/utils.js.map +0 -1
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.js.map +0 -1
- package/src/utils/module-federation/with-module-federation/with-module-federation.js.map +0 -1
- package/src/utils/normalize-assets.js.map +0 -1
- package/src/utils/read-rspack-options.js.map +0 -1
- package/src/utils/resolve-user-defined-rspack-config.js.map +0 -1
- package/src/utils/versions.js.map +0 -1
- package/src/utils/with-nx.js.map +0 -1
- package/src/utils/with-react.js.map +0 -1
- package/src/utils/with-web.js.map +0 -1
package/src/utils/config.js
CHANGED
|
@@ -3,24 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.nxRspackComposablePlugin = void 0;
|
|
4
4
|
exports.isNxRspackComposablePlugin = isNxRspackComposablePlugin;
|
|
5
5
|
exports.composePlugins = composePlugins;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
6
|
exports.nxRspackComposablePlugin = 'nxRspackComposablePlugin';
|
|
8
7
|
function isNxRspackComposablePlugin(a) {
|
|
9
|
-
return
|
|
8
|
+
return a?.[exports.nxRspackComposablePlugin] === true;
|
|
10
9
|
}
|
|
11
10
|
function composePlugins(...plugins) {
|
|
12
|
-
return Object.defineProperty(function combined(config, ctx) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return config;
|
|
19
|
-
});
|
|
11
|
+
return Object.defineProperty(async function combined(config, ctx) {
|
|
12
|
+
for (const plugin of plugins) {
|
|
13
|
+
const fn = await plugin;
|
|
14
|
+
config = await fn(config, ctx);
|
|
15
|
+
}
|
|
16
|
+
return config;
|
|
20
17
|
}, exports.nxRspackComposablePlugin, {
|
|
21
18
|
value: true,
|
|
22
19
|
enumerable: false,
|
|
23
20
|
writable: false,
|
|
24
21
|
});
|
|
25
22
|
}
|
|
26
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -6,32 +6,28 @@ const tslib_1 = require("tslib");
|
|
|
6
6
|
const core_1 = require("@rspack/core");
|
|
7
7
|
const path = tslib_1.__importStar(require("path"));
|
|
8
8
|
const resolve_user_defined_rspack_config_1 = require("./resolve-user-defined-rspack-config");
|
|
9
|
-
function createCompiler(options, context) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
return (0, core_1.rspack)(config);
|
|
32
|
-
});
|
|
9
|
+
async function createCompiler(options, context) {
|
|
10
|
+
const pathToConfig = path.join(context.root, options.rspackConfig);
|
|
11
|
+
let userDefinedConfig = {};
|
|
12
|
+
if (options.tsConfig) {
|
|
13
|
+
userDefinedConfig = (0, resolve_user_defined_rspack_config_1.resolveUserDefinedRspackConfig)(pathToConfig, options.tsConfig);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
userDefinedConfig = await Promise.resolve(`${pathToConfig}`).then(s => tslib_1.__importStar(require(s))).then((x) => x.default || x);
|
|
17
|
+
}
|
|
18
|
+
if (typeof userDefinedConfig.then === 'function') {
|
|
19
|
+
userDefinedConfig = await userDefinedConfig;
|
|
20
|
+
}
|
|
21
|
+
let config = {};
|
|
22
|
+
if (typeof userDefinedConfig === 'function') {
|
|
23
|
+
config = await userDefinedConfig({ devServer: options.devServer }, { options, context });
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
config = userDefinedConfig;
|
|
27
|
+
config.devServer ??= options.devServer;
|
|
28
|
+
}
|
|
29
|
+
return (0, core_1.rspack)(config);
|
|
33
30
|
}
|
|
34
31
|
function isMultiCompiler(compiler) {
|
|
35
32
|
return 'compilers' in compiler;
|
|
36
33
|
}
|
|
37
|
-
//# sourceMappingURL=create-compiler.js.map
|
|
@@ -13,7 +13,6 @@ exports.handleUnknownExecutors = handleUnknownExecutors;
|
|
|
13
13
|
exports.determineFrameworkAndTarget = determineFrameworkAndTarget;
|
|
14
14
|
exports.determineMain = determineMain;
|
|
15
15
|
exports.determineTsConfig = determineTsConfig;
|
|
16
|
-
const tslib_1 = require("tslib");
|
|
17
16
|
const devkit_1 = require("@nx/devkit");
|
|
18
17
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
19
18
|
function findExistingTargetsInProject(targets, userProvidedTargets) {
|
|
@@ -83,9 +82,8 @@ function findExistingTargetsInProject(targets, userProvidedTargets) {
|
|
|
83
82
|
// If they have, we check if the executor the target is using is supported
|
|
84
83
|
// If it's not supported, then we set the unsupported flag to true for that target
|
|
85
84
|
function checkUserProvidedTarget(target) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (supportedExecutors[target].includes((_a = targets[userProvidedTargets[target]]) === null || _a === void 0 ? void 0 : _a.executor)) {
|
|
85
|
+
if (userProvidedTargets?.[target]) {
|
|
86
|
+
if (supportedExecutors[target].includes(targets[userProvidedTargets[target]]?.executor)) {
|
|
89
87
|
output.validFoundTargetName[target] = userProvidedTargets[target];
|
|
90
88
|
}
|
|
91
89
|
else {
|
|
@@ -104,8 +102,8 @@ function findExistingTargetsInProject(targets, userProvidedTargets) {
|
|
|
104
102
|
for (const target in targets) {
|
|
105
103
|
const executorName = targets[target].executor;
|
|
106
104
|
const hasRspackTargets = output.alreadyHasNxRspackTargets;
|
|
107
|
-
hasRspackTargets.build
|
|
108
|
-
hasRspackTargets.serve
|
|
105
|
+
hasRspackTargets.build ||= executorName === '@nx/rspack:rspack';
|
|
106
|
+
hasRspackTargets.serve ||= executorName === '@nx/rspack:dev-server';
|
|
109
107
|
const foundTargets = output.validFoundTargetName;
|
|
110
108
|
if (!foundTargets.build &&
|
|
111
109
|
supportedExecutors.build.includes(executorName)) {
|
|
@@ -115,12 +113,12 @@ function findExistingTargetsInProject(targets, userProvidedTargets) {
|
|
|
115
113
|
supportedExecutors.serve.includes(executorName)) {
|
|
116
114
|
foundTargets.serve = target;
|
|
117
115
|
}
|
|
118
|
-
output.projectContainsUnsupportedExecutor
|
|
116
|
+
output.projectContainsUnsupportedExecutor ||=
|
|
117
|
+
unsupportedExecutors.includes(executorName);
|
|
119
118
|
}
|
|
120
119
|
return output;
|
|
121
120
|
}
|
|
122
121
|
function addOrChangeBuildTarget(tree, options, target) {
|
|
123
|
-
var _a, _b;
|
|
124
122
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
125
123
|
const assets = [];
|
|
126
124
|
if (options.target === 'web' &&
|
|
@@ -131,7 +129,7 @@ function addOrChangeBuildTarget(tree, options, target) {
|
|
|
131
129
|
assets.push((0, devkit_1.joinPathFragments)(project.root, 'src/assets'));
|
|
132
130
|
}
|
|
133
131
|
const buildOptions = {
|
|
134
|
-
target:
|
|
132
|
+
target: options.target ?? 'web',
|
|
135
133
|
outputPath: (0, devkit_1.joinPathFragments)('dist',
|
|
136
134
|
// If standalone project then use the project's name in dist.
|
|
137
135
|
project.root === '.' ? project.name : project.root),
|
|
@@ -140,7 +138,7 @@ function addOrChangeBuildTarget(tree, options, target) {
|
|
|
140
138
|
rspackConfig: (0, devkit_1.joinPathFragments)(project.root, 'rspack.config.js'),
|
|
141
139
|
assets,
|
|
142
140
|
};
|
|
143
|
-
|
|
141
|
+
project.targets ??= {};
|
|
144
142
|
project.targets[target] = {
|
|
145
143
|
executor: '@nx/rspack:rspack',
|
|
146
144
|
outputs: ['{options.outputPath}'],
|
|
@@ -160,9 +158,8 @@ function addOrChangeBuildTarget(tree, options, target) {
|
|
|
160
158
|
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
161
159
|
}
|
|
162
160
|
function addOrChangeServeTarget(tree, options, target) {
|
|
163
|
-
var _a;
|
|
164
161
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
165
|
-
|
|
162
|
+
project.targets ??= {};
|
|
166
163
|
project.targets[target] = {
|
|
167
164
|
executor: '@nx/rspack:dev-server',
|
|
168
165
|
options: {
|
|
@@ -250,10 +247,11 @@ function deleteWebpackConfig(tree, projectRoot, webpackConfigFilePath) {
|
|
|
250
247
|
}
|
|
251
248
|
// Maybe add delete vite config?
|
|
252
249
|
function moveAndEditIndexHtml(tree, options, buildTarget) {
|
|
253
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
254
250
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
255
|
-
let indexHtmlPath =
|
|
256
|
-
|
|
251
|
+
let indexHtmlPath = projectConfig.targets?.[buildTarget]?.options?.index ??
|
|
252
|
+
`${projectConfig.root}/src/index.html`;
|
|
253
|
+
let mainPath = projectConfig.targets?.[buildTarget]?.options?.main ??
|
|
254
|
+
`${projectConfig.root}/src/main.ts${options.framework === 'react' ? 'x' : ''}`;
|
|
257
255
|
if (projectConfig.root !== '.') {
|
|
258
256
|
mainPath = mainPath.replace(projectConfig.root, '');
|
|
259
257
|
}
|
|
@@ -297,60 +295,54 @@ function normalizeViteConfigFilePathWithTree(tree, projectRoot, configFile) {
|
|
|
297
295
|
: undefined;
|
|
298
296
|
}
|
|
299
297
|
function getViteConfigPathForProject(tree, projectName, target) {
|
|
300
|
-
var _a, _b, _c;
|
|
301
298
|
let viteConfigPath;
|
|
302
299
|
const { targets, root } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
303
300
|
if (target) {
|
|
304
|
-
viteConfigPath =
|
|
301
|
+
viteConfigPath = targets?.[target]?.options?.configFile;
|
|
305
302
|
}
|
|
306
303
|
else {
|
|
307
304
|
const config = Object.values(targets).find((config) => config.executor === '@nx/rspack:build');
|
|
308
|
-
viteConfigPath =
|
|
305
|
+
viteConfigPath = config?.options?.configFile;
|
|
309
306
|
}
|
|
310
307
|
return normalizeViteConfigFilePathWithTree(tree, root, viteConfigPath);
|
|
311
308
|
}
|
|
312
|
-
function handleUnsupportedUserProvidedTargets(userProvidedTargetIsUnsupported, userProvidedTargetName, validFoundTargetName, framework) {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
});
|
|
309
|
+
async function handleUnsupportedUserProvidedTargets(userProvidedTargetIsUnsupported, userProvidedTargetName, validFoundTargetName, framework) {
|
|
310
|
+
if (userProvidedTargetIsUnsupported.build && validFoundTargetName.build) {
|
|
311
|
+
await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.build, validFoundTargetName.build, 'build', 'rspack');
|
|
312
|
+
}
|
|
313
|
+
if (framework !== 'nest' &&
|
|
314
|
+
userProvidedTargetIsUnsupported.serve &&
|
|
315
|
+
validFoundTargetName.serve) {
|
|
316
|
+
await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.serve, validFoundTargetName.serve, 'serve', 'dev-server');
|
|
317
|
+
}
|
|
323
318
|
}
|
|
324
|
-
function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName, validFoundTargetName, target, executor) {
|
|
325
|
-
|
|
326
|
-
devkit_1.logger.warn(`The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/rspack:${executor} executor.
|
|
319
|
+
async function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName, validFoundTargetName, target, executor) {
|
|
320
|
+
devkit_1.logger.warn(`The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/rspack:${executor} executor.
|
|
327
321
|
However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}
|
|
328
322
|
|
|
329
323
|
Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit
|
|
330
324
|
your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.
|
|
331
325
|
`);
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
326
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
327
|
+
const { Confirm } = require('enquirer');
|
|
328
|
+
const prompt = new Confirm({
|
|
329
|
+
name: 'question',
|
|
330
|
+
message: `Should we convert the ${validFoundTargetName} target to use the @nx/rspack:${executor} executor?`,
|
|
331
|
+
initial: true,
|
|
332
|
+
});
|
|
333
|
+
const shouldConvert = await prompt.run();
|
|
334
|
+
if (!shouldConvert) {
|
|
335
|
+
throw new Error(`The ${target} target ${userProvidedTargetName} cannot be converted to use the @nx/rspack:${executor} executor.
|
|
342
336
|
Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will
|
|
343
337
|
convert the first one it finds, most probably this one: ${validFoundTargetName})
|
|
344
338
|
|
|
345
339
|
Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit
|
|
346
340
|
your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.
|
|
347
341
|
`);
|
|
348
|
-
|
|
349
|
-
});
|
|
342
|
+
}
|
|
350
343
|
}
|
|
351
|
-
function handleUnknownExecutors(projectName) {
|
|
352
|
-
|
|
353
|
-
devkit_1.logger.warn(`
|
|
344
|
+
async function handleUnknownExecutors(projectName) {
|
|
345
|
+
devkit_1.logger.warn(`
|
|
354
346
|
We could not find any targets in project ${projectName} that use executors which
|
|
355
347
|
can be converted to the @nx/rspack executors.
|
|
356
348
|
|
|
@@ -361,24 +353,22 @@ function handleUnknownExecutors(projectName) {
|
|
|
361
353
|
If you still want to convert your project to use the @nx/rspack executors,
|
|
362
354
|
please make sure to commit your changes before running this generator.
|
|
363
355
|
`);
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
356
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
357
|
+
const { Confirm } = require('enquirer');
|
|
358
|
+
const prompt = new Confirm({
|
|
359
|
+
name: 'question',
|
|
360
|
+
message: `Should Nx convert your project to use the @nx/rspack executors?`,
|
|
361
|
+
initial: true,
|
|
362
|
+
});
|
|
363
|
+
const shouldConvert = await prompt.run();
|
|
364
|
+
if (!shouldConvert) {
|
|
365
|
+
throw new Error(`
|
|
374
366
|
Nx could not verify that the executors you are using can be converted to the @nx/rspack executors.
|
|
375
367
|
Please try again with a different project.
|
|
376
368
|
`);
|
|
377
|
-
|
|
378
|
-
});
|
|
369
|
+
}
|
|
379
370
|
}
|
|
380
371
|
function determineFrameworkAndTarget(tree, options, projectRoot, targets) {
|
|
381
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
382
372
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
383
373
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
384
374
|
const { tsquery } = require('@phenomnomnominal/tsquery');
|
|
@@ -386,9 +376,9 @@ function determineFrameworkAndTarget(tree, options, projectRoot, targets) {
|
|
|
386
376
|
if (options.target !== 'node') {
|
|
387
377
|
// Try to infer from jest config if the env is node
|
|
388
378
|
let jestConfigPath;
|
|
389
|
-
if (
|
|
390
|
-
|
|
391
|
-
jestConfigPath =
|
|
379
|
+
if (targets?.test?.executor !== '@nx/jest:jest' &&
|
|
380
|
+
targets?.test?.options?.jestConfig) {
|
|
381
|
+
jestConfigPath = targets?.test?.options?.jestConfig;
|
|
392
382
|
}
|
|
393
383
|
else {
|
|
394
384
|
jestConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, 'jest.config.ts');
|
|
@@ -407,7 +397,7 @@ function determineFrameworkAndTarget(tree, options, projectRoot, targets) {
|
|
|
407
397
|
const appFileContent = tree.read((0, devkit_1.joinPathFragments)(projectRoot, 'src/main.ts'), 'utf-8');
|
|
408
398
|
const file = tsquery.ast(appFileContent);
|
|
409
399
|
const hasNestJsDependency = tsquery(file, `ImportDeclaration:has(StringLiteral[value="@nestjs/common"])`);
|
|
410
|
-
if (
|
|
400
|
+
if (hasNestJsDependency?.length > 0) {
|
|
411
401
|
return { target: 'node', framework: 'nest' };
|
|
412
402
|
}
|
|
413
403
|
}
|
|
@@ -422,7 +412,7 @@ function determineFrameworkAndTarget(tree, options, projectRoot, targets) {
|
|
|
422
412
|
tsConfigPath = determineTsConfig(tree, options);
|
|
423
413
|
}
|
|
424
414
|
const tsConfig = JSON.parse(tree.read(tsConfigPath).toString());
|
|
425
|
-
if (
|
|
415
|
+
if (tsConfig?.compilerOptions?.jsx?.includes('react')) {
|
|
426
416
|
return { target: 'web', framework: 'react' };
|
|
427
417
|
}
|
|
428
418
|
else {
|
|
@@ -452,4 +442,3 @@ function determineTsConfig(tree, options) {
|
|
|
452
442
|
return libJson;
|
|
453
443
|
return (0, devkit_1.joinPathFragments)(project.root, 'tsconfig.json');
|
|
454
444
|
}
|
|
455
|
-
//# sourceMappingURL=generator-utils.js.map
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getCopyPatterns = getCopyPatterns;
|
|
4
4
|
function getCopyPatterns(assets) {
|
|
5
5
|
return assets.map((asset) => {
|
|
6
|
-
var _a;
|
|
7
6
|
return {
|
|
8
7
|
context: asset.input,
|
|
9
8
|
// Now we remove starting slash to make Webpack place it from the output root.
|
|
@@ -14,11 +13,10 @@ function getCopyPatterns(assets) {
|
|
|
14
13
|
'.gitkeep',
|
|
15
14
|
'**/.DS_Store',
|
|
16
15
|
'**/Thumbs.db',
|
|
17
|
-
...(
|
|
16
|
+
...(asset.ignore ?? []),
|
|
18
17
|
],
|
|
19
18
|
dot: true,
|
|
20
19
|
},
|
|
21
20
|
};
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
|
-
//# sourceMappingURL=get-copy-patterns.js.map
|
package/src/utils/jest-utils.js
CHANGED
|
@@ -6,4 +6,3 @@ function updateJestConfigContent(content) {
|
|
|
6
6
|
.replace('transform: {', "transform: {\n '^(?!.*\\\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',")
|
|
7
7
|
.replace(`'babel-jest'`, `['babel-jest', { presets: ['@nx/react/babel'] }]`);
|
|
8
8
|
}
|
|
9
|
-
//# sourceMappingURL=jest-utils.js.map
|
package/src/utils/mode-utils.js
CHANGED
package/src/utils/model.js
CHANGED
|
@@ -1,73 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildStaticRemotes = buildStaticRemotes;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const fs_1 = require("fs");
|
|
6
5
|
const node_child_process_1 = require("node:child_process");
|
|
7
6
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
8
7
|
const logger_1 = require("nx/src/utils/logger");
|
|
9
8
|
const path_1 = require("path");
|
|
10
|
-
function buildStaticRemotes(staticRemotesConfig, nxBin, context, options) {
|
|
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
|
-
|
|
49
|
-
if (stdoutString.includes('Successfully ran target build')) {
|
|
50
|
-
staticProcess.stdout.removeAllListeners('data');
|
|
51
|
-
logger_1.logger.info(`NX Built ${staticRemotesConfig.remotes.length} static remotes`);
|
|
52
|
-
res();
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
staticProcess.stderr.on('data', (data) => logger_1.logger.info(data.toString()));
|
|
56
|
-
staticProcess.once('exit', (code) => {
|
|
57
|
-
stdoutStream.end();
|
|
9
|
+
async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options) {
|
|
10
|
+
if (!staticRemotesConfig.remotes.length) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
logger_1.logger.info(`NX Building ${staticRemotesConfig.remotes.length} static remotes...`);
|
|
14
|
+
const mappedLocationOfRemotes = {};
|
|
15
|
+
for (const app of staticRemotesConfig.remotes) {
|
|
16
|
+
mappedLocationOfRemotes[app] = `http${options.ssl ? 's' : ''}://${options.host}:${options.staticRemotesPort}/${staticRemotesConfig.config[app].urlSegment}`;
|
|
17
|
+
}
|
|
18
|
+
await new Promise((res, rej) => {
|
|
19
|
+
const staticProcess = (0, node_child_process_1.fork)(nxBin, [
|
|
20
|
+
'run-many',
|
|
21
|
+
`--target=build`,
|
|
22
|
+
`--projects=${staticRemotesConfig.remotes.join(',')}`,
|
|
23
|
+
...(context.configurationName
|
|
24
|
+
? [`--configuration=${context.configurationName}`]
|
|
25
|
+
: []),
|
|
26
|
+
...(options.parallel ? [`--parallel=${options.parallel}`] : []),
|
|
27
|
+
], {
|
|
28
|
+
cwd: context.root,
|
|
29
|
+
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
|
30
|
+
});
|
|
31
|
+
// File to debug build failures e.g. 2024-01-01T00_00_0_0Z-build.log'
|
|
32
|
+
const remoteBuildLogFile = (0, path_1.join)(cache_directory_1.workspaceDataDirectory,
|
|
33
|
+
// eslint-disable-next-line
|
|
34
|
+
`${new Date().toISOString().replace(/[:\.]/g, '_')}-build.log`);
|
|
35
|
+
const stdoutStream = (0, fs_1.createWriteStream)(remoteBuildLogFile);
|
|
36
|
+
staticProcess.stdout.on('data', (data) => {
|
|
37
|
+
const ANSII_CODE_REGEX =
|
|
38
|
+
// eslint-disable-next-line no-control-regex
|
|
39
|
+
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
40
|
+
const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
|
|
41
|
+
stdoutStream.write(stdoutString);
|
|
42
|
+
// in addition to writing into the stdout stream, also show error directly in console
|
|
43
|
+
// so the error is easily discoverable. 'ERROR in' is the key word to search in webpack output.
|
|
44
|
+
if (stdoutString.includes('ERROR in')) {
|
|
45
|
+
logger_1.logger.log(stdoutString);
|
|
46
|
+
}
|
|
47
|
+
if (stdoutString.includes('Successfully ran target build')) {
|
|
58
48
|
staticProcess.stdout.removeAllListeners('data');
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
49
|
+
logger_1.logger.info(`NX Built ${staticRemotesConfig.remotes.length} static remotes`);
|
|
50
|
+
res();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
staticProcess.stderr.on('data', (data) => logger_1.logger.info(data.toString()));
|
|
54
|
+
staticProcess.once('exit', (code) => {
|
|
55
|
+
stdoutStream.end();
|
|
56
|
+
staticProcess.stdout.removeAllListeners('data');
|
|
57
|
+
staticProcess.stderr.removeAllListeners('data');
|
|
58
|
+
if (code !== 0) {
|
|
59
|
+
rej(`Remote failed to start. A complete log can be found in: ${remoteBuildLogFile}`);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
res();
|
|
63
|
+
}
|
|
69
64
|
});
|
|
70
|
-
|
|
65
|
+
process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
|
|
66
|
+
process.on('exit', () => staticProcess.kill('SIGTERM'));
|
|
71
67
|
});
|
|
68
|
+
return mappedLocationOfRemotes;
|
|
72
69
|
}
|
|
73
|
-
//# sourceMappingURL=build-static.remotes.js.map
|
|
@@ -14,12 +14,11 @@ function collectDependencies(projectGraph, name, dependencies = {
|
|
|
14
14
|
workspaceLibraries: new Map(),
|
|
15
15
|
npmPackages: new Set(),
|
|
16
16
|
}, seen = new Set()) {
|
|
17
|
-
var _a;
|
|
18
17
|
if (seen.has(name)) {
|
|
19
18
|
return dependencies;
|
|
20
19
|
}
|
|
21
20
|
seen.add(name);
|
|
22
|
-
(
|
|
21
|
+
(projectGraph.dependencies[name] ?? []).forEach((dependency) => {
|
|
23
22
|
if (dependency.target.startsWith('npm:')) {
|
|
24
23
|
dependencies.npmPackages.add(dependency.target.replace('npm:', ''));
|
|
25
24
|
}
|
|
@@ -55,4 +54,3 @@ function getLibraryImportPath(library, projectGraph) {
|
|
|
55
54
|
}
|
|
56
55
|
return undefined;
|
|
57
56
|
}
|
|
58
|
-
//# sourceMappingURL=dependencies.js.map
|
|
@@ -10,7 +10,6 @@ const fs_1 = require("fs");
|
|
|
10
10
|
const find_matching_projects_1 = require("nx/src/utils/find-matching-projects");
|
|
11
11
|
const path_1 = require("path");
|
|
12
12
|
function extractRemoteProjectsFromConfig(config, pathToManifestFile) {
|
|
13
|
-
var _a, _b;
|
|
14
13
|
const remotes = [];
|
|
15
14
|
const dynamicRemotes = [];
|
|
16
15
|
if (pathToManifestFile && (0, fs_1.existsSync)(pathToManifestFile)) {
|
|
@@ -26,13 +25,12 @@ function extractRemoteProjectsFromConfig(config, pathToManifestFile) {
|
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
|
-
const staticRemotes =
|
|
28
|
+
const staticRemotes = config.remotes?.map((r) => (Array.isArray(r) ? r[0] : r)) ?? [];
|
|
30
29
|
remotes.push(...staticRemotes);
|
|
31
30
|
return { remotes, dynamicRemotes };
|
|
32
31
|
}
|
|
33
32
|
function collectRemoteProjects(remote, collected, context) {
|
|
34
|
-
|
|
35
|
-
const remoteProject = (_a = context.projectGraph.nodes[remote]) === null || _a === void 0 ? void 0 : _a.data;
|
|
33
|
+
const remoteProject = context.projectGraph.nodes[remote]?.data;
|
|
36
34
|
if (!context.projectGraph.nodes[remote] || collected.has(remote)) {
|
|
37
35
|
return;
|
|
38
36
|
}
|
|
@@ -44,11 +42,10 @@ function collectRemoteProjects(remote, collected, context) {
|
|
|
44
42
|
remoteProjectRemotes.forEach((r) => collectRemoteProjects(r, collected, context));
|
|
45
43
|
}
|
|
46
44
|
function getRemotes(devRemotes, skipRemotes, config, context, pathToManifestFile) {
|
|
47
|
-
var _a;
|
|
48
45
|
const collectedRemotes = new Set();
|
|
49
46
|
const { remotes, dynamicRemotes } = extractRemoteProjectsFromConfig(config, pathToManifestFile);
|
|
50
47
|
remotes.forEach((r) => collectRemoteProjects(r, collectedRemotes, context));
|
|
51
|
-
const remotesToSkip = new Set((
|
|
48
|
+
const remotesToSkip = new Set((0, find_matching_projects_1.findMatchingProjects)(skipRemotes, context.projectGraph.nodes) ?? []);
|
|
52
49
|
if (remotesToSkip.size > 0) {
|
|
53
50
|
devkit_1.logger.info(`Remotes not served automatically: ${[...remotesToSkip.values()].join(', ')}`);
|
|
54
51
|
}
|
|
@@ -96,8 +93,7 @@ function getModuleFederationConfig(tsconfigPath, workspaceRoot, projectRoot, plu
|
|
|
96
93
|
cleanupTranspiler();
|
|
97
94
|
return config.default || config;
|
|
98
95
|
}
|
|
99
|
-
catch
|
|
96
|
+
catch {
|
|
100
97
|
throw new Error(`Could not load ${moduleFederationConfigPath}. Was this project generated with "@nx/${pluginName}:host"?\nSee: https://nx.dev/concepts/more-concepts/faster-builds-with-module-federation`);
|
|
101
98
|
}
|
|
102
99
|
}
|
|
103
|
-
//# sourceMappingURL=get-remotes-for-host.js.map
|
|
@@ -4,7 +4,7 @@ exports.parseStaticRemotesConfig = parseStaticRemotesConfig;
|
|
|
4
4
|
exports.parseStaticSsrRemotesConfig = parseStaticSsrRemotesConfig;
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
function parseStaticRemotesConfig(staticRemotes, context) {
|
|
7
|
-
if (!
|
|
7
|
+
if (!staticRemotes?.length) {
|
|
8
8
|
return { remotes: [], config: undefined };
|
|
9
9
|
}
|
|
10
10
|
const config = {};
|
|
@@ -18,7 +18,7 @@ function parseStaticRemotesConfig(staticRemotes, context) {
|
|
|
18
18
|
return { remotes: staticRemotes, config };
|
|
19
19
|
}
|
|
20
20
|
function parseStaticSsrRemotesConfig(staticRemotes, context) {
|
|
21
|
-
if (!
|
|
21
|
+
if (!staticRemotes?.length) {
|
|
22
22
|
return { remotes: [], config: undefined };
|
|
23
23
|
}
|
|
24
24
|
const config = {};
|
|
@@ -32,4 +32,3 @@ function parseStaticSsrRemotesConfig(staticRemotes, context) {
|
|
|
32
32
|
}
|
|
33
33
|
return { remotes: staticRemotes, config };
|
|
34
34
|
}
|
|
35
|
-
//# sourceMappingURL=parse-static-remotes-config.js.map
|
|
@@ -43,7 +43,7 @@ const nxRuntimeLibraryControlPlugin = function () {
|
|
|
43
43
|
shareScopeMap[scope][pkgName][version] = remotePkgInfo;
|
|
44
44
|
return remotePkgInfo;
|
|
45
45
|
}
|
|
46
|
-
catch
|
|
46
|
+
catch {
|
|
47
47
|
return originalResolver();
|
|
48
48
|
}
|
|
49
49
|
};
|
|
@@ -52,4 +52,3 @@ const nxRuntimeLibraryControlPlugin = function () {
|
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
54
|
exports.default = nxRuntimeLibraryControlPlugin;
|
|
55
|
-
//# sourceMappingURL=runtime-library-control.plugin.js.map
|