@nx/js 24.1.0-beta.2 → 24.1.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.
@@ -163,7 +163,12 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
163
163
  const npmViewCommand = pm === 'bun'
164
164
  ? {
165
165
  command: 'bun',
166
- args: ['info', packageName, '--json', ...registryArgs],
166
+ args: [
167
+ 'info',
168
+ packageName,
169
+ '--json',
170
+ ...(registry ? [`--registry=${registry}`] : []),
171
+ ],
167
172
  }
168
173
  : {
169
174
  command: 'npm',
@@ -131,15 +131,35 @@ exports.createNodesV2 = [
131
131
  const packageManager = (0, devkit_1.detectPackageManager)(context.workspaceRoot);
132
132
  const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
133
133
  const lockFileName = (0, internal_1.getLockFileName)(packageManager);
134
- const { configFilePaths: validConfigFilePaths, hashes, projectRoots, } = await resolveValidConfigFilesAndHashes(configFilePaths, normalizedOptions, (0, internal_1.hashObject)({ options, isUsingTsSolutionSetup }), context, cache, lockFileName, isUsingTsSolutionSetup);
134
+ // Only the noEmit typecheck target lists its compiler packages as inputs
135
+ const typescriptAliasCandidates = !isUsingTsSolutionSetup && normalizedOptions.typecheck
136
+ ? readRootTypeScriptAliases(context.workspaceRoot)
137
+ : [];
138
+ const lockFile = typescriptAliasCandidates.length
139
+ ? (0, internal_1.readLockFileSnapshot)(context)
140
+ : undefined;
141
+ const { configFilePaths: validConfigFilePaths, hashes, projectRoots, } = await resolveValidConfigFilesAndHashes(configFilePaths, normalizedOptions, (0, internal_1.hashObject)({
142
+ options,
143
+ isUsingTsSolutionSetup,
144
+ typescriptAliasCandidates,
145
+ // Missing when lockfile analysis is off. The per-file hashes read the
146
+ // lockfile separately, so they can't stand in for this read.
147
+ lockFileHash: lockFile?.lockFileHash,
148
+ }), context, cache, lockFileName, isUsingTsSolutionSetup);
135
149
  try {
150
+ const targetsCacheKeys = validConfigFilePaths.map((configFilePath, idx) => `${hashes[idx]}_${configFilePath}`);
151
+ // An input naming a package with no graph node fails the task, and a
152
+ // package manager can leave a declared alias uninstalled. Only targets
153
+ // missing from the cache need the lockfile's nodes.
154
+ const typescriptAliases = lockFile && targetsCacheKeys.some((key) => !targetsCache[key])
155
+ ? typescriptAliasCandidates.filter((name) => lockFile.hasExternalDependency(name))
156
+ : [];
136
157
  return await (0, devkit_1.createNodesFromFiles)((configFilePath, options, context, idx) => {
137
158
  const projectRoot = projectRoots[idx];
138
- const hash = hashes[idx];
139
- const targetsCacheKey = `${hash}_${configFilePath}`;
159
+ const targetsCacheKey = targetsCacheKeys[idx];
140
160
  const absolutePath = (0, node_path_1.join)(context.workspaceRoot, configFilePath);
141
161
  const configContext = getConfigContext(absolutePath, context.workspaceRoot, cache);
142
- targetsCache[targetsCacheKey] ??= buildTscTargets(configContext, options, context, validConfigFilePaths, cache, pmc, isUsingTsSolutionSetup);
162
+ targetsCache[targetsCacheKey] ??= buildTscTargets(configContext, options, context, validConfigFilePaths, cache, pmc, isUsingTsSolutionSetup, typescriptAliases);
143
163
  const { targets } = targetsCache[targetsCacheKey];
144
164
  return {
145
165
  projects: {
@@ -258,7 +278,7 @@ function checkIfConfigFileShouldBeProject(config, cache) {
258
278
  }
259
279
  return true;
260
280
  }
261
- function buildTscTargets(config, options, context, configFiles, cache, pmc, isUsingTsSolutionSetup) {
281
+ function buildTscTargets(config, options, context, configFiles, cache, pmc, isUsingTsSolutionSetup, typescriptAliases) {
262
282
  const targets = {};
263
283
  const namedInputs = (0, internal_1.getNamedInputs)(config.project.root, context);
264
284
  const tsConfig = retrieveTsConfigFromCache(config.absolutePath, context.workspaceRoot, cache);
@@ -281,6 +301,7 @@ function buildTscTargets(config, options, context, configFiles, cache, pmc, isUs
281
301
  pmc,
282
302
  tsConfig: (0, typecheck_target_1.selectTypecheckTsConfig)(siblingFiles.filter((file) => /^tsconfig.*\.json$/.test(file))),
283
303
  compiler,
304
+ typescriptAliases,
284
305
  // Like the framework targets it replaces: `{workspaceRoot}` inputs
285
306
  // would mark the project affected by any root tsconfig change.
286
307
  namedInputs,
@@ -975,6 +996,38 @@ function readTsConfig(tsConfigPath, workspaceRoot, cache) {
975
996
  // to identify the filenames included in the program, which we won't use
976
997
  return ts.parseJsonConfigFileContent(readResult.config, tsSys, (0, node_path_1.dirname)(tsConfigPath));
977
998
  }
999
+ /**
1000
+ * Root package.json dependencies that install `typescript` under another name,
1001
+ * such as `"@typescript/native": "npm:typescript@^7"`. Peer dependencies are
1002
+ * left out. Yarn doesn't install the root's own peers, so a graph node with
1003
+ * that name can come from another dependency.
1004
+ */
1005
+ function readRootTypeScriptAliases(workspaceRoot) {
1006
+ const packageJsonPath = (0, node_path_1.join)(workspaceRoot, 'package.json');
1007
+ if (!(0, node_fs_1.existsSync)(packageJsonPath)) {
1008
+ return [];
1009
+ }
1010
+ const packageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
1011
+ const catalogManager = (0, internal_1.getCatalogManager)(workspaceRoot);
1012
+ const aliases = new Set();
1013
+ for (const section of [
1014
+ 'dependencies',
1015
+ 'devDependencies',
1016
+ 'optionalDependencies',
1017
+ ]) {
1018
+ for (const [name, specifier] of Object.entries(packageJson[section] ?? {})) {
1019
+ const resolvedSpecifier = catalogManager?.isCatalogReference(specifier)
1020
+ ? catalogManager.resolveCatalogReference(workspaceRoot, name, specifier)
1021
+ : specifier;
1022
+ if (name !== 'typescript' &&
1023
+ resolvedSpecifier &&
1024
+ /^npm:typescript(@|$)/.test(resolvedSpecifier)) {
1025
+ aliases.add(name);
1026
+ }
1027
+ }
1028
+ }
1029
+ return [...aliases].sort();
1030
+ }
978
1031
  function normalizePluginOptions(pluginOptions = {}) {
979
1032
  const defaultCompiler = 'tsc';
980
1033
  const compiler = pluginOptions.compiler ?? defaultCompiler;
@@ -18,6 +18,12 @@ export interface TypecheckTargetOptions {
18
18
  * Defaults to `tsc`.
19
19
  */
20
20
  compiler?: string;
21
+ /**
22
+ * Names that install `typescript` through an npm alias, such as
23
+ * `@typescript/native` for `npm:typescript@^7`. The `tsc` binary can come
24
+ * from any of them, so the default inputs of a `tsc` target include them.
25
+ */
26
+ typescriptAliases?: string[];
21
27
  /**
22
28
  * Name of the typecheck target, for the dependency on referenced projects
23
29
  * in `build` mode. Defaults to `typecheck`.
@@ -19,7 +19,7 @@ function createTypecheckTarget(options) {
19
19
  options: { cwd: options.projectRoot },
20
20
  cache: true,
21
21
  inputs: options.inputs ??
22
- getDefaultTypecheckInputs(options.namedInputs ?? {}, compiler),
22
+ getDefaultTypecheckInputs(options.namedInputs ?? {}, compiler, options.typescriptAliases ?? []),
23
23
  metadata: {
24
24
  technologies: options.technologies ?? ['typescript'],
25
25
  description: 'Runs type-checking for the project.',
@@ -66,21 +66,23 @@ function isShellSafeTsConfigName(name) {
66
66
  function getTsConfigArg(tsConfig) {
67
67
  return !tsConfig || tsConfig === DEFAULT_TSCONFIG ? '' : ` ${tsConfig}`;
68
68
  }
69
- function getDefaultTypecheckInputs(namedInputs, compiler) {
69
+ function getDefaultTypecheckInputs(namedInputs, compiler, typescriptAliases) {
70
70
  return [
71
71
  ...('production' in namedInputs
72
72
  ? ['production', '^production']
73
73
  : ['default', '^default']),
74
- { externalDependencies: getCompilerPackages(compiler) },
74
+ {
75
+ externalDependencies: getCompilerPackages(compiler, typescriptAliases),
76
+ },
75
77
  ];
76
78
  }
77
- function getCompilerPackages(compiler) {
79
+ function getCompilerPackages(compiler, typescriptAliases) {
78
80
  switch (compiler) {
79
81
  case 'tsgo':
80
82
  return ['@typescript/native-preview'];
81
83
  case 'vue-tsc':
82
84
  return ['vue-tsc', 'typescript'];
83
85
  default:
84
- return ['typescript'];
86
+ return ['typescript', ...typescriptAliases];
85
87
  }
86
88
  }
package/migrations.json CHANGED
@@ -33,7 +33,7 @@
33
33
  "version": "23.1.0-beta.8",
34
34
  "description": "Adds `\"ignoreDeprecations\": \"6.0\"` to tsconfig files whose compilerOptions (or ts-node.compilerOptions) carry a TypeScript 6 deprecated option value, set directly or inherited through `extends` including from a base this migration does not edit (e.g. moduleResolution node/node10/classic, baseUrl, target es5, esModuleInterop false, outFile, module amd/umd/system/none, alwaysStrict false, allowSyntheticDefaultImports false, downlevelIteration set). Also pins `\"strict\": false`, `\"noUncheckedSideEffectImports\": false`, `\"types\": [\"*\"]`, and `\"esModuleInterop\": false` in chain-root tsconfigs (no \"extends\") that lack each key, preserving pre-TS6 behavior where these defaults changed; `esModuleInterop` false is itself deprecated (removed in TS7) so it also receives `ignoreDeprecations`, deferring the interop change to the TS7 migration. Also adds `ignoreDeprecations` to every `tsconfig.json` (the exact name jest/ts-node auto-resolve when compiling a config file; ts-node injects a deprecated default `target: es5` there, so the load can hit a TS6 error even on a clean config), even one with no deprecated value of its own; a stale local `ignoreDeprecations` (e.g. `5.0`) that would otherwise override the inherited flag is upgraded.",
35
35
  "requires": {
36
- "typescript": ">=6.0.0"
36
+ "typescript": "^6.0.0"
37
37
  },
38
38
  "factory": "./dist/src/migrations/update-23-1-0/add-ignore-deprecations-for-ts6",
39
39
  "documentation": "./dist/src/migrations/update-23-1-0/add-ignore-deprecations-for-ts6.md"
@@ -42,7 +42,7 @@
42
42
  "version": "23.1.0-rc.2",
43
43
  "description": "Sets an explicit `rootDir` on project `tsconfig*.json` files that lack one, pinned to the source directory TypeScript 5 inferred implicitly, so programs keep compiling and emitting the same layout under TypeScript 6, which otherwise hard-fails with TS5011 or TS6059 (for example a spec tsconfig importing another project's source through a `paths` alias). The pin is written even when the inferred directory already equals the tsconfig directory, because tools like ts-jest with `isolatedModules` compile a program per file and re-infer a deeper directory from that subset. The value is computed by the compiler, so emit layout is unchanged. Each config is written on its own; the migration never writes to a shared `extends` base, so a config never inherits a value computed for a sibling. Composite projects are pinned to their own directory: `rootDir` already defaults there under `tsc` so it is a no-op for a real composite build, but ts-jest strips `composite` for its per-file transpile and the explicit value is needed to avoid TS5011 there.",
44
44
  "requires": {
45
- "typescript": ">=6.0.0"
45
+ "typescript": "^6.0.0"
46
46
  },
47
47
  "factory": "./dist/src/migrations/update-23-1-0/set-tsconfig-root-dir-for-ts6",
48
48
  "documentation": "./dist/src/migrations/update-23-1-0/set-tsconfig-root-dir-for-ts6.md"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "24.1.0-beta.2",
3
+ "version": "24.1.0-beta.3",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -162,8 +162,8 @@
162
162
  "@babel/preset-env": "^7.23.2",
163
163
  "@babel/preset-typescript": "^7.22.5",
164
164
  "@babel/runtime": "^7.22.6",
165
- "@nx/devkit": "24.1.0-beta.2",
166
- "@nx/workspace": "24.1.0-beta.2",
165
+ "@nx/devkit": "24.1.0-beta.3",
166
+ "@nx/workspace": "24.1.0-beta.3",
167
167
  "@zkochan/js-yaml": "0.0.7",
168
168
  "babel-plugin-const-enum": "^1.0.1",
169
169
  "babel-plugin-macros": "^3.1.0",
@@ -183,18 +183,20 @@
183
183
  "tslib": "^2.3.0"
184
184
  },
185
185
  "devDependencies": {
186
- "@nx/esbuild": "24.1.0-beta.2",
187
- "@nx/eslint": "24.1.0-beta.2",
188
- "@nx/jest": "24.1.0-beta.2",
189
- "@nx/oxlint": "24.1.0-beta.2",
190
- "@nx/rollup": "24.1.0-beta.2",
191
- "@nx/vite": "24.1.0-beta.2",
192
- "@nx/vitest": "24.1.0-beta.2",
193
- "nx": "24.1.0-beta.2"
186
+ "@nx/esbuild": "24.1.0-beta.3",
187
+ "@nx/eslint": "24.1.0-beta.3",
188
+ "@nx/jest": "24.1.0-beta.3",
189
+ "@nx/oxlint": "24.1.0-beta.3",
190
+ "@nx/rollup": "24.1.0-beta.3",
191
+ "@nx/vite": "24.1.0-beta.3",
192
+ "@nx/vitest": "24.1.0-beta.3",
193
+ "nx": "24.1.0-beta.3"
194
194
  },
195
195
  "peerDependencies": {
196
196
  "@swc/cli": ">=0.6.0 <0.9.0",
197
- "verdaccio": "^6.0.5 || ^7.0.0"
197
+ "verdaccio": "^6.0.5 || ^7.0.0",
198
+ "nx": "24.1.0-beta.3",
199
+ "typescript": "^5.8.0 || ^6.0.0"
198
200
  },
199
201
  "peerDependenciesMeta": {
200
202
  "@swc/cli": {
@@ -202,6 +204,12 @@
202
204
  },
203
205
  "verdaccio": {
204
206
  "optional": true
207
+ },
208
+ "nx": {
209
+ "optional": true
210
+ },
211
+ "typescript": {
212
+ "optional": true
205
213
  }
206
214
  },
207
215
  "publishConfig": {