@nx/rspack 23.2.0-beta.0 → 23.2.0-beta.10
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/module-federation-static-server/module-federation-static-server.impl.d.ts +1 -1
- package/dist/src/generators/convert-to-inferred/convert-to-inferred.d.ts +1 -2
- package/dist/src/generators/convert-to-inferred/convert-to-inferred.js +2 -3
- package/dist/src/plugins/generate-package-json-plugin.js +6 -9
- package/dist/src/plugins/plugin.js +27 -30
- package/dist/src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.js +2 -2
- package/dist/src/plugins/utils/apply-base-config.js +3 -4
- package/dist/src/plugins/utils/apply-web-config.js +3 -3
- package/dist/src/plugins/utils/loaders/stylesheet-loaders.d.ts +2 -0
- package/dist/src/plugins/utils/loaders/stylesheet-loaders.js +5 -0
- package/dist/src/plugins/utils/plugins/generate-package-json-plugin.js +6 -9
- package/dist/src/plugins/utils/plugins/rspack-nx-build-coordination-plugin.js +8 -9
- package/dist/src/utils/config.js +2 -2
- package/dist/src/utils/create-compiler.d.ts +1 -1
- package/dist/src/utils/create-compiler.js +4 -2
- package/dist/src/utils/generator-utils.js +6 -13
- package/dist/src/utils/load-rspack-core.d.ts +2 -0
- package/dist/src/utils/load-rspack-core.js +10 -0
- package/dist/src/utils/read-rspack-options.js +2 -2
- package/package.json +9 -10
package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
1
2
|
import { StaticRemotesConfig } from '@nx/module-federation/internal';
|
|
2
|
-
import { ExecutorContext } from 'nx/src/config/misc-interfaces';
|
|
3
3
|
import { ModuleFederationDevServerOptions } from '../module-federation-dev-server/schema';
|
|
4
4
|
import { ModuleFederationStaticServerSchema } from './schema';
|
|
5
5
|
export declare function startProxies(staticRemotesConfig: StaticRemotesConfig, hostServeOptions: ModuleFederationDevServerOptions, mappedLocationOfHost: string, mappedLocationsOfRemotes: Record<string, string>, sslOptions?: {
|
|
@@ -8,7 +8,6 @@ const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
|
8
8
|
const plugin_1 = require("../../plugins/plugin");
|
|
9
9
|
const versions_1 = require("../../utils/versions");
|
|
10
10
|
const utils_1 = require("./utils");
|
|
11
|
-
const devkit_exports_1 = require("nx/src/devkit-exports");
|
|
12
11
|
const assert_supported_rspack_version_1 = require("../../utils/assert-supported-rspack-version");
|
|
13
12
|
async function convertToInferred(tree, options) {
|
|
14
13
|
(0, assert_supported_rspack_version_1.assertSupportedRspackVersion)(tree);
|
|
@@ -97,12 +96,12 @@ function createCollectingLogger() {
|
|
|
97
96
|
loggedMessages.forEach((messages, method) => {
|
|
98
97
|
messages.forEach((message) => {
|
|
99
98
|
if (!filter || filter(message)) {
|
|
100
|
-
|
|
99
|
+
devkit_1.logger[method](message);
|
|
101
100
|
}
|
|
102
101
|
});
|
|
103
102
|
});
|
|
104
103
|
};
|
|
105
|
-
return new Proxy({ ...
|
|
104
|
+
return new Proxy({ ...devkit_1.logger, loggedMessages, flushLogs }, {
|
|
106
105
|
get(target, property) {
|
|
107
106
|
const originalMethod = target[property];
|
|
108
107
|
if (typeof originalMethod === 'function') {
|
|
@@ -36,16 +36,13 @@ class GeneratePackageJsonPlugin {
|
|
|
36
36
|
helperDependencies: helperDependencies.map((dep) => dep.target),
|
|
37
37
|
});
|
|
38
38
|
packageJson.main = packageJson.main ?? this.options.outputFileName;
|
|
39
|
-
compilation.emitAsset('package.json', new sources.RawSource((0, devkit_1.serializeJson)(packageJson)));
|
|
40
39
|
const packageManager = (0, devkit_1.detectPackageManager)(this.context.root);
|
|
41
|
-
|
|
42
|
-
compilation
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
compilation.emitAsset((0, js_1.getLockFileName)(packageManager), new sources.RawSource((0, js_1.createLockFile)(packageJson, this.projectGraph, packageManager)));
|
|
48
|
-
}
|
|
40
|
+
(0, js_1.generatePrunedDeployOutput)(packageJson, this.projectGraph, this.projectGraph.nodes[this.context.projectName].data.root, {
|
|
41
|
+
emit: (assetPath, content) => compilation.emitAsset(assetPath, new sources.RawSource(content)),
|
|
42
|
+
packageManager,
|
|
43
|
+
workspaceRoot: this.context.root,
|
|
44
|
+
});
|
|
45
|
+
compilation.emitAsset('package.json', new sources.RawSource((0, devkit_1.serializeJson)(packageJson)));
|
|
49
46
|
});
|
|
50
47
|
});
|
|
51
48
|
}
|
|
@@ -6,9 +6,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
6
6
|
const js_1 = require("@nx/js");
|
|
7
7
|
const internal_2 = require("@nx/js/internal");
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
|
-
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
10
|
-
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
11
|
-
const package_manager_1 = require("nx/src/utils/package-manager");
|
|
12
9
|
const path_1 = require("path");
|
|
13
10
|
const read_rspack_options_1 = require("../utils/read-rspack-options");
|
|
14
11
|
const resolve_user_defined_rspack_config_1 = require("../utils/resolve-user-defined-rspack-config");
|
|
@@ -20,15 +17,16 @@ const rspackConfigGlob = '**/rspack.config.{js,ts,mjs,mts,cjs,cts}';
|
|
|
20
17
|
exports.createNodes = [
|
|
21
18
|
rspackConfigGlob,
|
|
22
19
|
async (configFilePaths, options, context) => {
|
|
23
|
-
const optionsHash = (0,
|
|
24
|
-
const cachePath = (0, path_1.join)(
|
|
20
|
+
const optionsHash = (0, internal_1.hashObject)(options);
|
|
21
|
+
const cachePath = (0, path_1.join)(internal_1.workspaceDataDirectory, `rspack-${optionsHash}.hash`);
|
|
25
22
|
const targetsCache = new internal_1.PluginCache(cachePath);
|
|
26
23
|
const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)();
|
|
27
24
|
const packageManager = (0, devkit_1.detectPackageManager)(context.workspaceRoot);
|
|
28
|
-
const pmc = (0,
|
|
25
|
+
const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
|
29
26
|
const lockFileName = (0, js_1.getLockFileName)(packageManager);
|
|
27
|
+
const includePnpmMajorRuntimeInput = (0, internal_2.shouldIncludePnpmMajorRuntimeInput)(packageManager, context.workspaceRoot);
|
|
30
28
|
try {
|
|
31
|
-
return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, targetsCache, isTsSolutionSetup, pmc, lockFileName), configFilePaths, options, context);
|
|
29
|
+
return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, targetsCache, isTsSolutionSetup, packageManager, pmc, lockFileName, includePnpmMajorRuntimeInput), configFilePaths, options, context);
|
|
32
30
|
}
|
|
33
31
|
finally {
|
|
34
32
|
targetsCache.writeToDisk();
|
|
@@ -39,7 +37,7 @@ exports.createNodes = [
|
|
|
39
37
|
* @deprecated Use {@link createNodes} instead. This will be removed in Nx 24.
|
|
40
38
|
*/
|
|
41
39
|
exports.createNodesV2 = exports.createNodes;
|
|
42
|
-
async function createNodesInternal(configFilePath, options, context, targetsCache, isTsSolutionSetup, pmc, lockFileName) {
|
|
40
|
+
async function createNodesInternal(configFilePath, options, context, targetsCache, isTsSolutionSetup, packageManager, pmc, lockFileName, includePnpmMajorRuntimeInput) {
|
|
43
41
|
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
44
42
|
// Do not create a project if package.json and project.json isn't there.
|
|
45
43
|
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
@@ -52,18 +50,18 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
|
|
|
52
50
|
packageJson = (0, devkit_1.readJsonFile)((0, path_1.join)(context.workspaceRoot, projectRoot, 'package.json'));
|
|
53
51
|
}
|
|
54
52
|
const normalizedOptions = normalizeOptions(options);
|
|
55
|
-
const lockFileHash = (0,
|
|
56
|
-
const nodeHash = (0,
|
|
57
|
-
(0,
|
|
53
|
+
const lockFileHash = (0, internal_1.hashFile)((0, path_1.join)(context.workspaceRoot, lockFileName)) ?? '';
|
|
54
|
+
const nodeHash = (0, devkit_1.hashArray)([
|
|
55
|
+
(0, internal_1.hashFile)((0, path_1.join)(context.workspaceRoot, configFilePath)),
|
|
58
56
|
lockFileHash,
|
|
59
|
-
(0,
|
|
60
|
-
(0,
|
|
57
|
+
(0, internal_1.hashObject)({ ...options, isTsSolutionSetup, includePnpmMajorRuntimeInput }),
|
|
58
|
+
(0, internal_1.hashObject)(packageJson),
|
|
61
59
|
]);
|
|
62
60
|
// We do not want to alter how the hash is calculated, so appending the config file path to the hash
|
|
63
61
|
// to prevent vite/vitest files overwriting the target cache created by the other
|
|
64
62
|
const hash = `${nodeHash}_${configFilePath}`;
|
|
65
63
|
if (!targetsCache.has(hash)) {
|
|
66
|
-
targetsCache.set(hash, await createRspackTargets(configFilePath, projectRoot, normalizedOptions, context, isTsSolutionSetup, pmc));
|
|
64
|
+
targetsCache.set(hash, await createRspackTargets(configFilePath, projectRoot, normalizedOptions, context, isTsSolutionSetup, packageManager, pmc, includePnpmMajorRuntimeInput));
|
|
67
65
|
}
|
|
68
66
|
const { targets, metadata } = targetsCache.get(hash);
|
|
69
67
|
return {
|
|
@@ -76,7 +74,7 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
|
|
|
76
74
|
},
|
|
77
75
|
};
|
|
78
76
|
}
|
|
79
|
-
async function createRspackTargets(configFilePath, projectRoot, options, context, isTsSolutionSetup, pmc) {
|
|
77
|
+
async function createRspackTargets(configFilePath, projectRoot, options, context, isTsSolutionSetup, packageManager, pmc, includePnpmMajorRuntimeInput) {
|
|
80
78
|
const namedInputs = (0, internal_1.getNamedInputs)(projectRoot, context);
|
|
81
79
|
const rspackConfig = await (0, resolve_user_defined_rspack_config_1.resolveUserDefinedRspackConfig)((0, path_1.join)(context.workspaceRoot, configFilePath), (0, js_1.getRootTsConfigPath)(), true);
|
|
82
80
|
const rspackOptions = await (0, read_rspack_options_1.readRspackOptions)(rspackConfig);
|
|
@@ -106,21 +104,20 @@ async function createRspackTargets(configFilePath, projectRoot, options, context
|
|
|
106
104
|
},
|
|
107
105
|
cache: true,
|
|
108
106
|
dependsOn: [`^${options.buildTargetName}`],
|
|
109
|
-
inputs:
|
|
110
|
-
|
|
111
|
-
'production',
|
|
112
|
-
'^
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
],
|
|
107
|
+
inputs: [
|
|
108
|
+
...('production' in namedInputs
|
|
109
|
+
? ['production', '^production']
|
|
110
|
+
: ['default', '^default']),
|
|
111
|
+
{
|
|
112
|
+
externalDependencies: ['@rspack/cli'],
|
|
113
|
+
},
|
|
114
|
+
// The build can emit a pruned pnpm deploy output (NxAppRspackPlugin
|
|
115
|
+
// with generatePackageJson), whose install settings come from these
|
|
116
|
+
// otherwise-unhashed root sources.
|
|
117
|
+
...(packageManager === 'pnpm'
|
|
118
|
+
? (0, internal_2.pnpmInstallSettingsInputsForInferredTarget)(includePnpmMajorRuntimeInput)
|
|
119
|
+
: []),
|
|
120
|
+
],
|
|
124
121
|
outputs,
|
|
125
122
|
};
|
|
126
123
|
targets[options.serveTargetName] = {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useLegacyNxPlugin = useLegacyNxPlugin;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const normalize_options_1 = require("../utils/plugins/normalize-options");
|
|
6
|
-
const
|
|
6
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
7
7
|
/**
|
|
8
8
|
* This function is used to wrap the legacy plugin function to be used with the `composePlugins` function.
|
|
9
9
|
* Initially the rspack config would be passed to the legacy plugin function and the options would be passed as a second argument.
|
|
@@ -44,7 +44,7 @@ async function useLegacyNxPlugin(fn, executorOptions) {
|
|
|
44
44
|
root: devkit_1.workspaceRoot,
|
|
45
45
|
projectGraph,
|
|
46
46
|
projectsConfigurations: (0, devkit_1.readProjectsConfigurationFromProjectGraph)(projectGraph),
|
|
47
|
-
nxJsonConfiguration: (0,
|
|
47
|
+
nxJsonConfiguration: (0, internal_1.readNxJsonFromDisk)(devkit_1.workspaceRoot),
|
|
48
48
|
target: project.data.targets[targetName],
|
|
49
49
|
targetName: targetName,
|
|
50
50
|
projectName: projectName,
|
|
@@ -6,6 +6,7 @@ const path = tslib_1.__importStar(require("path"));
|
|
|
6
6
|
const license_webpack_plugin_1 = require("license-webpack-plugin");
|
|
7
7
|
const js_1 = require("@nx/js");
|
|
8
8
|
const version_utils_1 = require("../../utils/version-utils");
|
|
9
|
+
const load_rspack_core_1 = require("../../utils/load-rspack-core");
|
|
9
10
|
const stats_json_plugin_1 = require("./plugins/stats-json-plugin");
|
|
10
11
|
const generate_package_json_plugin_1 = require("./plugins/generate-package-json-plugin");
|
|
11
12
|
const hash_format_1 = require("./hash-format");
|
|
@@ -36,10 +37,8 @@ function applyBaseConfig(options, config = {}, { useNormalizedEntry, compiler, }
|
|
|
36
37
|
options.progress ??= true;
|
|
37
38
|
options.outputHashing ??= 'all';
|
|
38
39
|
// Lazy-require avoids loading @rspack/core (pure ESM in v2) at module
|
|
39
|
-
// parse time, so Jest can still load this file.
|
|
40
|
-
const rspackCore = compiler
|
|
41
|
-
? compiler.rspack
|
|
42
|
-
: require('@rspack/core');
|
|
40
|
+
// parse time, so Jest can still load this file. See load-rspack-core.ts.
|
|
41
|
+
const rspackCore = (0, load_rspack_core_1.loadRspackCore)(compiler);
|
|
43
42
|
applyNxIndependentConfig(options, config, rspackCore);
|
|
44
43
|
// Some of the options only work during actual tasks, not when reading the rspack config during CreateNodes.
|
|
45
44
|
if (global.NX_GRAPH_CREATION)
|
|
@@ -8,15 +8,15 @@ const hash_format_1 = require("./hash-format");
|
|
|
8
8
|
const instantiate_script_plugins_1 = require("./instantiate-script-plugins");
|
|
9
9
|
const stylesheet_loaders_1 = require("./loaders/stylesheet-loaders");
|
|
10
10
|
const normalize_entry_1 = require("./normalize-entry");
|
|
11
|
+
const load_rspack_core_1 = require("../../utils/load-rspack-core");
|
|
11
12
|
function applyWebConfig(options, config = {}, { useNormalizedEntry, compiler, } = {}) {
|
|
12
13
|
if (global.NX_GRAPH_CREATION)
|
|
13
14
|
return;
|
|
14
15
|
// Prefer compiler.rspack when available; otherwise lazy-require
|
|
15
16
|
// @rspack/core (works on Node 22.12+ via require(esm), and keeps the
|
|
16
17
|
// file Jest-loadable since the require is inside the function body).
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
: require('@rspack/core');
|
|
18
|
+
// See load-rspack-core.ts.
|
|
19
|
+
const rspackCore = (0, load_rspack_core_1.loadRspackCore)(compiler);
|
|
20
20
|
const { CssExtractRspackPlugin, DefinePlugin, EnvironmentPlugin, HtmlRspackPlugin, LightningCssMinimizerRspackPlugin, } = rspackCore;
|
|
21
21
|
const cssExtractLoader = CssExtractRspackPlugin.loader;
|
|
22
22
|
// Defaults that was applied from executor schema previously.
|
|
@@ -12,6 +12,8 @@ export declare function getCommonLoadersForCssModules(options: any, includePaths
|
|
|
12
12
|
modules: {
|
|
13
13
|
mode: string;
|
|
14
14
|
getLocalIdent: typeof getCSSModuleLocalIdent;
|
|
15
|
+
namedExport: boolean;
|
|
16
|
+
exportLocalsConvention: string;
|
|
15
17
|
};
|
|
16
18
|
importLoaders: number;
|
|
17
19
|
implementation?: undefined;
|
|
@@ -24,6 +24,11 @@ function getCommonLoadersForCssModules(options, includePaths, cssExtractLoader)
|
|
|
24
24
|
modules: {
|
|
25
25
|
mode: 'local',
|
|
26
26
|
getLocalIdent: get_css_module_local_ident_1.getCSSModuleLocalIdent,
|
|
27
|
+
// css-loader 7 defaults namedExport to true, and to camel-case-only
|
|
28
|
+
// locals when it is off. Generated components import the default
|
|
29
|
+
// export and reference class names as authored, so pin both.
|
|
30
|
+
namedExport: false,
|
|
31
|
+
exportLocalsConvention: 'asIs',
|
|
27
32
|
},
|
|
28
33
|
importLoaders: 1,
|
|
29
34
|
},
|
|
@@ -55,16 +55,13 @@ class GeneratePackageJsonPlugin {
|
|
|
55
55
|
...packageJson.dependencies,
|
|
56
56
|
...runtimeDependencies,
|
|
57
57
|
};
|
|
58
|
-
compilation.emitAsset('package.json', new sources.RawSource((0, devkit_1.serializeJson)(packageJson)));
|
|
59
58
|
const packageManager = (0, devkit_1.detectPackageManager)(this.options.root);
|
|
60
|
-
|
|
61
|
-
compilation
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
compilation.emitAsset((0, js_1.getLockFileName)(packageManager), new sources.RawSource((0, js_1.createLockFile)(packageJson, this.options.projectGraph, packageManager)));
|
|
67
|
-
}
|
|
59
|
+
(0, js_1.generatePrunedDeployOutput)(packageJson, this.options.projectGraph, this.options.projectGraph.nodes[this.options.projectName].data.root, {
|
|
60
|
+
emit: (assetPath, content) => compilation.emitAsset(assetPath, new sources.RawSource(content)),
|
|
61
|
+
packageManager,
|
|
62
|
+
workspaceRoot: this.options.root,
|
|
63
|
+
});
|
|
64
|
+
compilation.emitAsset('package.json', new sources.RawSource((0, devkit_1.serializeJson)(packageJson)));
|
|
68
65
|
});
|
|
69
66
|
});
|
|
70
67
|
}
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RspackNxBuildCoordinationPlugin = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const output_1 = require("nx/src/utils/output");
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
8
7
|
class RspackNxBuildCoordinationPlugin {
|
|
9
8
|
constructor(buildCmd, skipInitialBuild) {
|
|
10
9
|
this.buildCmd = buildCmd;
|
|
@@ -13,11 +12,11 @@ class RspackNxBuildCoordinationPlugin {
|
|
|
13
12
|
if (!skipInitialBuild) {
|
|
14
13
|
this.buildChangedProjects();
|
|
15
14
|
}
|
|
16
|
-
if ((0,
|
|
15
|
+
if ((0, devkit_1.isDaemonEnabled)()) {
|
|
17
16
|
this.startWatchingBuildableLibs();
|
|
18
17
|
}
|
|
19
18
|
else {
|
|
20
|
-
|
|
19
|
+
devkit_1.output.warn({
|
|
21
20
|
title: 'Nx Daemon is not enabled. Buildable libs will not be rebuilt on file changes.',
|
|
22
21
|
});
|
|
23
22
|
}
|
|
@@ -65,8 +64,8 @@ class RspackNxBuildCoordinationPlugin {
|
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
createFileWatcher() {
|
|
68
|
-
const runner = new
|
|
69
|
-
return
|
|
67
|
+
const runner = new internal_1.BatchFunctionRunner(() => this.buildChangedProjects());
|
|
68
|
+
return internal_1.daemonClient.registerFileWatcher({
|
|
70
69
|
watchProjects: 'all',
|
|
71
70
|
}, (err, { changedProjects, changedFiles }) => {
|
|
72
71
|
if (err === 'reconnecting') {
|
|
@@ -78,13 +77,13 @@ class RspackNxBuildCoordinationPlugin {
|
|
|
78
77
|
return;
|
|
79
78
|
}
|
|
80
79
|
else if (err === 'closed') {
|
|
81
|
-
|
|
80
|
+
devkit_1.output.error({
|
|
82
81
|
title: 'Failed to reconnect to daemon after multiple attempts',
|
|
83
82
|
});
|
|
84
83
|
process.exit(1);
|
|
85
84
|
}
|
|
86
85
|
else if (err) {
|
|
87
|
-
|
|
86
|
+
devkit_1.output.error({
|
|
88
87
|
title: `Watch error: ${err?.message ?? 'Unknown'}`,
|
|
89
88
|
});
|
|
90
89
|
}
|
package/dist/src/utils/config.js
CHANGED
|
@@ -6,8 +6,8 @@ exports.composePlugins = composePlugins;
|
|
|
6
6
|
exports.composePluginsSync = composePluginsSync;
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
8
|
const internal_1 = require("@nx/js/internal");
|
|
9
|
-
const configuration_1 = require("nx/src/config/configuration");
|
|
10
9
|
const deprecation_1 = require("./deprecation");
|
|
10
|
+
const internal_2 = require("@nx/devkit/internal");
|
|
11
11
|
exports.nxRspackComposablePlugin = 'nxRspackComposablePlugin';
|
|
12
12
|
function isNxRspackComposablePlugin(a) {
|
|
13
13
|
return a?.[exports.nxRspackComposablePlugin] === true;
|
|
@@ -80,7 +80,7 @@ function ensureNxRspackExecutionContext(ctx) {
|
|
|
80
80
|
targetName,
|
|
81
81
|
configurationName,
|
|
82
82
|
projectsConfigurations: (0, devkit_1.readProjectsConfigurationFromProjectGraph)(projectGraph),
|
|
83
|
-
nxJsonConfiguration: (0,
|
|
83
|
+
nxJsonConfiguration: (0, internal_2.readNxJsonFromDisk)(devkit_1.workspaceRoot),
|
|
84
84
|
cwd: process.cwd(),
|
|
85
85
|
root: devkit_1.workspaceRoot,
|
|
86
86
|
isVerbose: process.env['NX_VERBOSE_LOGGING'] === 'true',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import {
|
|
2
|
+
import type { Compiler, MultiCompiler } from '@rspack/core';
|
|
3
3
|
import { NormalizedRspackExecutorSchema } from '../executors/rspack/schema';
|
|
4
4
|
export declare function createCompiler(options: NormalizedRspackExecutorSchema & {
|
|
5
5
|
devServer?: any;
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createCompiler = createCompiler;
|
|
4
4
|
exports.isMultiCompiler = isMultiCompiler;
|
|
5
|
-
const core_1 = require("@rspack/core");
|
|
6
5
|
const config_1 = require("../executors/rspack/lib/config");
|
|
6
|
+
const load_rspack_core_1 = require("./load-rspack-core");
|
|
7
7
|
async function createCompiler(options, context) {
|
|
8
8
|
const config = await (0, config_1.getRspackConfigs)(options, context);
|
|
9
9
|
if (!options.standardRspackConfigFunction) {
|
|
10
10
|
validateConfig(config);
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
// Lazy-loaded to avoid resolving @rspack/core (pure ESM) before a build runs; see load-rspack-core.ts.
|
|
13
|
+
const { rspack } = (0, load_rspack_core_1.loadRspackCore)();
|
|
14
|
+
return rspack(config);
|
|
13
15
|
}
|
|
14
16
|
function isMultiCompiler(compiler) {
|
|
15
17
|
return 'compilers' in compiler;
|
|
@@ -13,8 +13,9 @@ exports.handleUnknownExecutors = handleUnknownExecutors;
|
|
|
13
13
|
exports.determineFrameworkAndTarget = determineFrameworkAndTarget;
|
|
14
14
|
exports.determineMain = determineMain;
|
|
15
15
|
exports.determineTsConfig = determineTsConfig;
|
|
16
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
16
17
|
const devkit_1 = require("@nx/devkit");
|
|
17
|
-
const
|
|
18
|
+
const internal_2 = require("@nx/js/internal");
|
|
18
19
|
const has_plugin_1 = require("./has-plugin");
|
|
19
20
|
function findExistingTargetsInProject(targets, userProvidedTargets) {
|
|
20
21
|
const output = {
|
|
@@ -129,7 +130,7 @@ function addOrChangeBuildTarget(tree, options, target) {
|
|
|
129
130
|
if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'src/assets'))) {
|
|
130
131
|
assets.push((0, devkit_1.joinPathFragments)(project.root, 'src/assets'));
|
|
131
132
|
}
|
|
132
|
-
const isTsSolutionSetup = (0,
|
|
133
|
+
const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)(tree);
|
|
133
134
|
const buildOptions = {
|
|
134
135
|
target: options.target ?? 'web',
|
|
135
136
|
outputPath: isTsSolutionSetup
|
|
@@ -441,13 +442,9 @@ async function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName
|
|
|
441
442
|
Please note that converting a potentially non-compatible project to use Vite may result in unexpected behavior. Always commit
|
|
442
443
|
your changes before converting a project to use Vite, and test the converted project thoroughly before deploying it.
|
|
443
444
|
`);
|
|
444
|
-
const
|
|
445
|
-
const prompt = new Confirm({
|
|
446
|
-
name: 'question',
|
|
445
|
+
const shouldConvert = await (0, internal_1.confirmationPrompt)({
|
|
447
446
|
message: `Should we convert the ${validFoundTargetName} target to use the @nx/rspack:${executor} executor?`,
|
|
448
|
-
initial: true,
|
|
449
447
|
});
|
|
450
|
-
const shouldConvert = await prompt.run();
|
|
451
448
|
if (!shouldConvert) {
|
|
452
449
|
throw new Error(`The ${target} target ${userProvidedTargetName} cannot be converted to use the @nx/rspack:${executor} executor.
|
|
453
450
|
Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will
|
|
@@ -470,13 +467,9 @@ async function handleUnknownExecutors(projectName) {
|
|
|
470
467
|
If you still want to convert your project to use the @nx/rspack executors,
|
|
471
468
|
please make sure to commit your changes before running this generator.
|
|
472
469
|
`);
|
|
473
|
-
const
|
|
474
|
-
const prompt = new Confirm({
|
|
475
|
-
name: 'question',
|
|
470
|
+
const shouldConvert = await (0, internal_1.confirmationPrompt)({
|
|
476
471
|
message: `Should Nx convert your project to use the @nx/rspack executors?`,
|
|
477
|
-
initial: true,
|
|
478
472
|
});
|
|
479
|
-
const shouldConvert = await prompt.run();
|
|
480
473
|
if (!shouldConvert) {
|
|
481
474
|
throw new Error(`
|
|
482
475
|
Nx could not verify that the executors you are using can be converted to the @nx/rspack executors.
|
|
@@ -485,7 +478,7 @@ async function handleUnknownExecutors(projectName) {
|
|
|
485
478
|
}
|
|
486
479
|
}
|
|
487
480
|
function determineFrameworkAndTarget(tree, options, projectRoot, targets) {
|
|
488
|
-
(0,
|
|
481
|
+
(0, internal_2.ensureTypescript)();
|
|
489
482
|
const { ast, query } = require('@phenomnomnominal/tsquery');
|
|
490
483
|
// First try to infer if the target is node
|
|
491
484
|
if (options.target !== 'node') {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadRspackCore = loadRspackCore;
|
|
4
|
+
// @rspack/core v2 is pure ESM; lazy-require avoids resolving it before a Compiler exists.
|
|
5
|
+
function loadRspackCore(compiler) {
|
|
6
|
+
// Reuse the compiler's already-resolved module to avoid ending up with a second, possibly different copy.
|
|
7
|
+
return compiler
|
|
8
|
+
? compiler.rspack
|
|
9
|
+
: require('@rspack/core');
|
|
10
|
+
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.readRspackOptions = readRspackOptions;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const config_1 = require("./config");
|
|
6
|
-
const
|
|
6
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
7
7
|
/**
|
|
8
8
|
* Reads the Rspack options from a give Rspack configuration. The configuration can be:
|
|
9
9
|
* 1. A single standard config object
|
|
@@ -36,7 +36,7 @@ async function readRspackOptions(rspackConfig) {
|
|
|
36
36
|
root: devkit_1.workspaceRoot,
|
|
37
37
|
cwd: undefined,
|
|
38
38
|
isVerbose: false,
|
|
39
|
-
nxJsonConfiguration: (0,
|
|
39
|
+
nxJsonConfiguration: (0, internal_1.readNxJsonFromDisk)(devkit_1.workspaceRoot),
|
|
40
40
|
projectGraph: null,
|
|
41
41
|
projectsConfigurations: null,
|
|
42
42
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/rspack",
|
|
3
3
|
"description": "The Nx Plugin for Rspack contains executors and generators that support building applications using Rspack.",
|
|
4
|
-
"version": "23.2.0-beta.
|
|
4
|
+
"version": "23.2.0-beta.10",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -130,10 +130,9 @@
|
|
|
130
130
|
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
131
131
|
"autoprefixer": "^10.4.9",
|
|
132
132
|
"browserslist": "^4.26.0",
|
|
133
|
-
"css-loader": "^
|
|
134
|
-
"enquirer": "~2.3.6",
|
|
133
|
+
"css-loader": "^7.1.4",
|
|
135
134
|
"express": "^4.21.2",
|
|
136
|
-
"http-proxy-middleware": "^3.0.
|
|
135
|
+
"http-proxy-middleware": "^3.0.7",
|
|
137
136
|
"less-loader": "^12.2.0",
|
|
138
137
|
"license-webpack-plugin": "^4.0.2",
|
|
139
138
|
"loader-utils": "^2.0.3",
|
|
@@ -152,14 +151,14 @@
|
|
|
152
151
|
"tslib": "^2.3.0",
|
|
153
152
|
"webpack": "5.105.2",
|
|
154
153
|
"webpack-node-externals": "^3.0.0",
|
|
155
|
-
"@nx/devkit": "23.2.0-beta.
|
|
156
|
-
"@nx/js": "23.2.0-beta.
|
|
157
|
-
"@nx/
|
|
158
|
-
"@nx/
|
|
154
|
+
"@nx/devkit": "23.2.0-beta.10",
|
|
155
|
+
"@nx/js": "23.2.0-beta.10",
|
|
156
|
+
"@nx/module-federation": "23.2.0-beta.10",
|
|
157
|
+
"@nx/web": "23.2.0-beta.10"
|
|
159
158
|
},
|
|
160
159
|
"devDependencies": {
|
|
161
|
-
"nx": "23.2.0-beta.
|
|
162
|
-
"@nx/nest": "23.2.0-beta.
|
|
160
|
+
"nx": "23.2.0-beta.10",
|
|
161
|
+
"@nx/nest": "23.2.0-beta.10"
|
|
163
162
|
},
|
|
164
163
|
"peerDependencies": {
|
|
165
164
|
"@rspack/cli": "^1.0.0 || ^2.0.0",
|