@nx/rsbuild 24.0.0-beta.2 → 24.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ exports.initGenerator = initGenerator;
5
5
  exports.initGeneratorInternal = initGeneratorInternal;
6
6
  const internal_1 = require("@nx/devkit/internal");
7
7
  const devkit_1 = require("@nx/devkit");
8
+ const internal_2 = require("@nx/js/internal");
8
9
  const plugin_1 = require("../../plugins/plugin");
9
10
  const versions_1 = require("../../utils/versions");
10
11
  const version_utils_1 = require("../../utils/version-utils");
@@ -24,37 +25,27 @@ function updateDependencies(tree, schema) {
24
25
  }, undefined, schema.keepExistingVersions ?? true);
25
26
  }
26
27
  function initGenerator(tree, schema) {
27
- return initGeneratorInternal(tree, { addPlugin: false, ...schema });
28
+ return initGeneratorInternal(tree, schema);
28
29
  }
29
30
  async function initGeneratorInternal(tree, schema) {
30
31
  (0, assert_supported_rsbuild_version_1.assertSupportedRsbuildVersion)(tree);
31
- const nxJson = (0, devkit_1.readNxJson)(tree);
32
- const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
33
- nxJson.useInferencePlugins !== false;
34
- schema.addPlugin ??= addPluginDefault;
35
- if (schema.addPlugin) {
36
- await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/rsbuild', plugin_1.createNodes, {
37
- buildTargetName: ['build', 'rsbuild:build', 'rsbuild-build'],
38
- devTargetName: ['dev', 'rsbuild:dev', 'rsbuild-dev'],
39
- previewTargetName: ['preview', 'rsbuild:preview', 'rsbuild-preview'],
40
- inspectTargetName: ['inspect', 'rsbuild:inspect', 'rsbuild-inspect'],
41
- typecheckTargetName: [
42
- 'typecheck',
43
- 'rsbuild:typecheck',
44
- 'rsbuild-typecheck',
45
- ],
46
- buildDepsTargetName: [
47
- 'build-deps',
48
- 'rsbuild:build-deps',
49
- 'rsbuild-build-deps',
50
- ],
51
- watchDepsTargetName: [
52
- 'watch-deps',
53
- 'rsbuild:watch-deps',
54
- 'rsbuild-watch-deps',
55
- ],
56
- }, schema.updatePackageScripts);
57
- }
32
+ await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/rsbuild', plugin_1.createNodes, {
33
+ buildTargetName: ['build', 'rsbuild:build', 'rsbuild-build'],
34
+ devTargetName: ['dev', 'rsbuild:dev', 'rsbuild-dev'],
35
+ previewTargetName: ['preview', 'rsbuild:preview', 'rsbuild-preview'],
36
+ inspectTargetName: ['inspect', 'rsbuild:inspect', 'rsbuild-inspect'],
37
+ buildDepsTargetName: [
38
+ 'build-deps',
39
+ 'rsbuild:build-deps',
40
+ 'rsbuild-build-deps',
41
+ ],
42
+ watchDepsTargetName: [
43
+ 'watch-deps',
44
+ 'rsbuild:watch-deps',
45
+ 'rsbuild-watch-deps',
46
+ ],
47
+ }, schema.updatePackageScripts);
48
+ await (0, internal_2.ensureTypescriptPlugin)(tree, schema.updatePackageScripts);
58
49
  const tasks = [];
59
50
  if (!schema.skipPackageJson) {
60
51
  tasks.push(updateDependencies(tree, schema));
@@ -1,7 +1,6 @@
1
1
  export interface InitGeneratorSchema {
2
2
  keepExistingVersions?: boolean;
3
3
  updatePackageScripts?: boolean;
4
- addPlugin?: boolean;
5
4
  skipFormat?: boolean;
6
5
  skipPackageJson?: boolean;
7
6
  }
@@ -0,0 +1,4 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export default function update(tree: Tree): Promise<{
3
+ skipAgentic: boolean;
4
+ }>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = update;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const internal_1 = require("@nx/js/internal");
6
+ async function update(tree) {
7
+ if (!(0, internal_1.registerTypescriptPluginForTypecheck)(tree, '@nx/rsbuild', {
8
+ removeTypecheckTargetName: true,
9
+ })) {
10
+ return { skipAgentic: true };
11
+ }
12
+ await (0, devkit_1.formatFiles)(tree);
13
+ }
@@ -0,0 +1,42 @@
1
+ #### Register `@nx/js/typescript` for typecheck targets
2
+
3
+ `@nx/rsbuild` no longer infers a `typecheck` target in any setup, and `@nx/js/typescript` provides it instead. This migration registers `@nx/js/typescript` with only its typecheck target when the workspace uses `@nx/rsbuild` and doesn't register `@nx/js/typescript` yet, so your projects keep a `typecheck` target.
4
+
5
+ The new registration is added before the framework plugin and reuses its `typecheckTargetName`, and the migration removes that option from the `@nx/rsbuild` registration. Registrations with `typecheckTargetName: false` lose the option without registering `@nx/js/typescript`.
6
+
7
+ #### Sample code changes
8
+
9
+ ##### Before
10
+
11
+ ```json title="nx.json"
12
+ {
13
+ "plugins": [
14
+ {
15
+ "plugin": "@nx/rsbuild",
16
+ "options": {
17
+ "buildTargetName": "build",
18
+ "typecheckTargetName": "typecheck"
19
+ }
20
+ }
21
+ ]
22
+ }
23
+ ```
24
+
25
+ ##### After
26
+
27
+ ```json title="nx.json"
28
+ {
29
+ "plugins": [
30
+ {
31
+ "plugin": "@nx/js/typescript",
32
+ "options": { "typecheck": { "targetName": "typecheck" } }
33
+ },
34
+ {
35
+ "plugin": "@nx/rsbuild",
36
+ "options": {
37
+ "buildTargetName": "build"
38
+ }
39
+ }
40
+ ]
41
+ }
42
+ ```
@@ -4,7 +4,6 @@ export interface RsbuildPluginOptions {
4
4
  devTargetName?: string;
5
5
  previewTargetName?: string;
6
6
  inspectTargetName?: string;
7
- typecheckTargetName?: string;
8
7
  buildDepsTargetName?: string;
9
8
  watchDepsTargetName?: string;
10
9
  }
@@ -7,7 +7,6 @@ const internal_2 = require("@nx/js/internal");
7
7
  const js_1 = require("@nx/js");
8
8
  const fs_1 = require("fs");
9
9
  const path_1 = require("path");
10
- const minimatch_1 = require("minimatch");
11
10
  const rsbuildConfigGlob = '**/rsbuild.config.{js,ts,mjs,mts,cjs,cts}';
12
11
  exports.createNodes = [
13
12
  rsbuildConfigGlob,
@@ -15,18 +14,17 @@ exports.createNodes = [
15
14
  const optionsHash = (0, internal_1.hashObject)(options);
16
15
  const cachePath = (0, path_1.join)(internal_1.workspaceDataDirectory, `rsbuild-${optionsHash}.hash`);
17
16
  const targetsCache = new internal_1.PluginCache(cachePath);
18
- const isUsingTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)();
19
17
  const packageManager = (0, devkit_1.detectPackageManager)(context.workspaceRoot);
20
18
  const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
21
19
  const lockFileName = (0, js_1.getLockFileName)(packageManager);
22
20
  const normalizedOptions = normalizeOptions(options);
23
21
  try {
24
22
  const { entries, preErrors } = await filterRsbuildConfigs(configFilePaths, context);
25
- const projectHashes = await (0, internal_1.calculateHashesForCreateNodes)(entries.map((e) => e.projectRoot), { ...normalizedOptions, isUsingTsSolutionSetup }, context, entries.map(() => [lockFileName]));
23
+ const projectHashes = await (0, internal_1.calculateHashesForCreateNodes)(entries.map((e) => e.projectRoot), normalizedOptions, context, entries.map(() => [lockFileName]));
26
24
  let results = [];
27
25
  let nodeErrors = [];
28
26
  try {
29
- results = await (0, devkit_1.createNodesFromFiles)((configFile, _, ctx, idx) => createNodesInternal(configFile, normalizedOptions, ctx, targetsCache, isUsingTsSolutionSetup, pmc, entries[idx].tsConfigFiles, projectHashes[idx]), entries.map((e) => e.configFile), options, context);
27
+ results = await (0, devkit_1.createNodesFromFiles)((configFile, _, ctx, idx) => createNodesInternal(configFile, normalizedOptions, ctx, targetsCache, pmc, projectHashes[idx]), entries.map((e) => e.configFile), options, context);
30
28
  }
31
29
  catch (e) {
32
30
  if (e instanceof devkit_1.AggregateCreateNodesError) {
@@ -52,10 +50,10 @@ exports.createNodes = [
52
50
  * @deprecated Use {@link createNodes} instead. This will be removed in Nx 24.
53
51
  */
54
52
  exports.createNodesV2 = exports.createNodes;
55
- async function createNodesInternal(configFilePath, normalizedOptions, context, targetsCache, isUsingTsSolutionSetup, pmc, tsConfigFiles, hash) {
53
+ async function createNodesInternal(configFilePath, normalizedOptions, context, targetsCache, pmc, hash) {
56
54
  const projectRoot = (0, path_1.dirname)(configFilePath);
57
55
  if (!targetsCache.has(hash)) {
58
- targetsCache.set(hash, await createRsbuildTargets(configFilePath, projectRoot, normalizedOptions, tsConfigFiles, isUsingTsSolutionSetup, context, pmc));
56
+ targetsCache.set(hash, await createRsbuildTargets(configFilePath, projectRoot, normalizedOptions, context, pmc));
59
57
  }
60
58
  const { targets, metadata } = targetsCache.get(hash);
61
59
  return {
@@ -68,7 +66,7 @@ async function createNodesInternal(configFilePath, normalizedOptions, context, t
68
66
  },
69
67
  };
70
68
  }
71
- async function createRsbuildTargets(configFilePath, projectRoot, options, tsConfigFiles, isUsingTsSolutionSetup, context, pmc) {
69
+ async function createRsbuildTargets(configFilePath, projectRoot, options, context, pmc) {
72
70
  const absoluteConfigFilePath = (0, devkit_1.joinPathFragments)(context.workspaceRoot, configFilePath);
73
71
  // Required lazily: `@rsbuild/core` is an optional peer dependency, so it
74
72
  // may be absent when the plugin is loaded in a workspace that doesn't use
@@ -138,42 +136,6 @@ async function createRsbuildTargets(configFilePath, projectRoot, options, tsConf
138
136
  cwd: projectRoot,
139
137
  },
140
138
  };
141
- if (tsConfigFiles.length) {
142
- const tsConfigToUse = ['tsconfig.app.json', 'tsconfig.lib.json', 'tsconfig.json'].find((t) => tsConfigFiles.includes(t)) ?? tsConfigFiles[0];
143
- targets[options.typecheckTargetName] = {
144
- cache: true,
145
- inputs: [
146
- ...('production' in namedInputs
147
- ? ['production', '^production']
148
- : ['default', '^default']),
149
- { externalDependencies: ['typescript'] },
150
- ],
151
- command: isUsingTsSolutionSetup
152
- ? `tsc --build --emitDeclarationOnly`
153
- : `tsc -p ${tsConfigToUse} --noEmit`,
154
- options: { cwd: (0, devkit_1.joinPathFragments)(projectRoot) },
155
- metadata: {
156
- description: `Runs type-checking for the project.`,
157
- technologies: ['typescript'],
158
- help: {
159
- command: isUsingTsSolutionSetup
160
- ? `${pmc.exec} tsc --build --help`
161
- : `${pmc.exec} tsc -p ${tsConfigToUse} --help`,
162
- example: isUsingTsSolutionSetup
163
- ? { args: ['--force'] }
164
- : { options: { noEmit: true } },
165
- },
166
- },
167
- };
168
- if (isUsingTsSolutionSetup) {
169
- targets[options.typecheckTargetName].dependsOn = [
170
- `^${options.typecheckTargetName}`,
171
- ];
172
- targets[options.typecheckTargetName].syncGenerators = [
173
- '@nx/js:typescript-sync',
174
- ];
175
- }
176
- }
177
139
  (0, internal_2.addBuildAndWatchDepsTargets)(context.workspaceRoot, projectRoot, targets, options, pmc);
178
140
  return { targets, metadata: {} };
179
141
  }
@@ -221,8 +183,7 @@ async function filterRsbuildConfigs(configFiles, context) {
221
183
  !siblingFiles.includes('project.json')) {
222
184
  return null;
223
185
  }
224
- const tsConfigFiles = siblingFiles.filter((p) => (0, minimatch_1.minimatch)(p, 'tsconfig*{.json,.*.json}')) ?? [];
225
- return { configFile, projectRoot, tsConfigFiles };
186
+ return { configFile, projectRoot };
226
187
  }
227
188
  catch (e) {
228
189
  preErrors.push([configFile, e]);
@@ -240,6 +201,5 @@ function normalizeOptions(options) {
240
201
  options.devTargetName ??= 'dev';
241
202
  options.previewTargetName ??= 'preview';
242
203
  options.inspectTargetName ??= 'inspect';
243
- options.typecheckTargetName ??= 'typecheck';
244
204
  return options;
245
205
  }
@@ -1,2 +1,2 @@
1
1
  import { type Tree } from '@nx/devkit';
2
- export declare function getRsbuildE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, isPluginBeingAdded: boolean, e2ePortOverride?: number): Promise<import("@nx/devkit/internal").E2EWebServerDetails>;
2
+ export declare function getRsbuildE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, e2ePortOverride?: number): Promise<import("@nx/devkit/internal").E2EWebServerDetails>;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRsbuildE2EWebServerInfo = getRsbuildE2EWebServerInfo;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const internal_1 = require("@nx/devkit/internal");
6
- async function getRsbuildE2EWebServerInfo(tree, projectName, configFilePath, isPluginBeingAdded, e2ePortOverride) {
6
+ async function getRsbuildE2EWebServerInfo(tree, projectName, configFilePath, e2ePortOverride) {
7
7
  const nxJson = (0, devkit_1.readNxJson)(tree);
8
8
  let e2ePort = e2ePortOverride ?? 4200;
9
9
  const devPort = (0, internal_1.readTargetDefaultsForTarget)('dev', nxJson.targetDefaults)
@@ -22,5 +22,5 @@ async function getRsbuildE2EWebServerInfo(tree, projectName, configFilePath, isP
22
22
  defaultE2EWebServerAddress: `http://localhost:${e2ePort}`,
23
23
  defaultE2ECiBaseUrl: `http://localhost:${e2ePort}`,
24
24
  defaultE2EPort: e2ePort,
25
- }, isPluginBeingAdded);
25
+ });
26
26
  }
package/migrations.json CHANGED
@@ -32,6 +32,12 @@
32
32
  "requires": {
33
33
  "@rsbuild/core": ">=2.0.0"
34
34
  }
35
+ },
36
+ "update-24-0-0-register-typescript-plugin-for-typecheck": {
37
+ "version": "24.0.0-beta.3",
38
+ "description": "Register @nx/js/typescript with its typecheck target in workspaces that use @nx/rsbuild without it, and remove the typecheckTargetName option from @nx/rsbuild, since @nx/rsbuild no longer infers typecheck targets.",
39
+ "implementation": "./dist/src/migrations/update-24-0-0/register-typescript-plugin-for-typecheck",
40
+ "documentation": "./dist/src/migrations/update-24-0-0/register-typescript-plugin-for-typecheck.md"
35
41
  }
36
42
  },
37
43
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nx/rsbuild",
3
3
  "description": "The Nx Plugin for Rsbuild contains an Nx plugin, executors and utilities that support building applications using Rsbuild.",
4
- "version": "24.0.0-beta.2",
4
+ "version": "24.0.0-beta.3",
5
5
  "type": "commonjs",
6
6
  "files": [
7
7
  "dist",
@@ -54,14 +54,14 @@
54
54
  "executors": "./executors.json",
55
55
  "dependencies": {
56
56
  "tslib": "^2.3.0",
57
- "@nx/devkit": "24.0.0-beta.2",
58
- "@nx/js": "24.0.0-beta.2",
57
+ "@nx/devkit": "24.0.0-beta.3",
58
+ "@nx/js": "24.0.0-beta.3",
59
59
  "minimatch": "10.2.5",
60
60
  "semver": "^7.6.3",
61
61
  "@phenomnomnominal/tsquery": "~6.2.0"
62
62
  },
63
63
  "devDependencies": {
64
- "nx": "24.0.0-beta.2"
64
+ "nx": "24.0.0-beta.3"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "@rsbuild/core": "^1.0.0 || ^2.0.0"