@nx/js 22.7.0-pr.35019.f500fd7 → 22.7.0-rc.0

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.
Files changed (39) hide show
  1. package/migrations.json +9 -0
  2. package/package.json +8 -9
  3. package/src/executors/node/node.impl.d.ts.map +1 -1
  4. package/src/executors/node/node.impl.js +21 -2
  5. package/src/executors/release-publish/release-publish.impl.d.ts.map +1 -1
  6. package/src/executors/release-publish/release-publish.impl.js +13 -1
  7. package/src/executors/tsc/lib/typescript-compilation.js +0 -1
  8. package/src/generators/init/files/non-ts-solution/__fileName__ +0 -1
  9. package/src/generators/library/files/tsconfig-lib/ts-solution/tsconfig.lib.json__tmpl__ +0 -1
  10. package/src/generators/library/library.d.ts.map +1 -1
  11. package/src/generators/library/library.js +2 -1
  12. package/src/generators/setup-verdaccio/generator.d.ts.map +1 -1
  13. package/src/generators/setup-verdaccio/generator.js +2 -6
  14. package/src/internal.d.ts +1 -0
  15. package/src/internal.d.ts.map +1 -1
  16. package/src/internal.js +3 -1
  17. package/src/plugins/jest/start-local-registry.js +1 -1
  18. package/src/plugins/typescript/plugin.d.ts.map +1 -1
  19. package/src/plugins/typescript/plugin.js +39 -37
  20. package/src/utils/assets/copy-assets-handler.d.ts +3 -1
  21. package/src/utils/assets/copy-assets-handler.d.ts.map +1 -1
  22. package/src/utils/assets/copy-assets-handler.js +6 -38
  23. package/src/utils/assets/normalize-assets.d.ts +26 -0
  24. package/src/utils/assets/normalize-assets.d.ts.map +1 -0
  25. package/src/utils/assets/normalize-assets.js +47 -0
  26. package/src/utils/buildable-libs-utils.d.ts.map +1 -1
  27. package/src/utils/buildable-libs-utils.js +20 -5
  28. package/src/utils/find-npm-dependencies.js +25 -4
  29. package/src/utils/typescript/create-ts-config.d.ts +0 -1
  30. package/src/utils/typescript/create-ts-config.d.ts.map +1 -1
  31. package/src/utils/typescript/create-ts-config.js +0 -5
  32. package/src/utils/typescript/raw-tsconfig.d.ts +36 -0
  33. package/src/utils/typescript/raw-tsconfig.d.ts.map +1 -0
  34. package/src/utils/typescript/raw-tsconfig.js +78 -0
  35. package/src/utils/typescript/ts-config.d.ts +14 -0
  36. package/src/utils/typescript/ts-config.d.ts.map +1 -1
  37. package/src/utils/typescript/ts-config.js +112 -11
  38. package/src/utils/versions.d.ts +2 -2
  39. package/src/utils/versions.js +2 -2
package/migrations.json CHANGED
@@ -107,6 +107,15 @@
107
107
  "alwaysAddToPackageJson": false
108
108
  }
109
109
  }
110
+ },
111
+ "22.6.4": {
112
+ "version": "22.6.4",
113
+ "packages": {
114
+ "verdaccio": {
115
+ "version": "^6.3.2",
116
+ "alwaysAddToPackageJson": false
117
+ }
118
+ }
110
119
  }
111
120
  }
112
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "22.7.0-pr.35019.f500fd7",
3
+ "version": "22.7.0-rc.0",
4
4
  "private": false,
5
5
  "description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
6
6
  "repository": {
@@ -19,7 +19,8 @@
19
19
  "Backend"
20
20
  ],
21
21
  "main": "src/index.js",
22
- "typings": "src/index.d.ts",
22
+ "type": "commonjs",
23
+ "types": "src/index.d.ts",
23
24
  "license": "MIT",
24
25
  "bugs": {
25
26
  "url": "https://github.com/nrwl/nx/issues"
@@ -39,8 +40,8 @@
39
40
  "@babel/preset-env": "^7.23.2",
40
41
  "@babel/preset-typescript": "^7.22.5",
41
42
  "@babel/runtime": "^7.22.6",
42
- "@nx/devkit": "22.7.0-pr.35019.f500fd7",
43
- "@nx/workspace": "22.7.0-pr.35019.f500fd7",
43
+ "@nx/devkit": "22.7.0-rc.0",
44
+ "@nx/workspace": "22.7.0-rc.0",
44
45
  "@zkochan/js-yaml": "0.0.7",
45
46
  "babel-plugin-const-enum": "^1.0.1",
46
47
  "babel-plugin-macros": "^3.1.0",
@@ -53,14 +54,14 @@
53
54
  "jsonc-parser": "3.2.0",
54
55
  "npm-run-path": "^4.0.1",
55
56
  "picocolors": "^1.1.0",
56
- "picomatch": "4.0.2",
57
+ "picomatch": "4.0.4",
57
58
  "semver": "^7.6.3",
58
59
  "source-map-support": "0.5.19",
59
60
  "tinyglobby": "^0.2.12",
60
61
  "tslib": "^2.3.0"
61
62
  },
62
63
  "devDependencies": {
63
- "nx": "22.7.0-pr.35019.f500fd7"
64
+ "nx": "22.7.0-rc.0"
64
65
  },
65
66
  "peerDependencies": {
66
67
  "verdaccio": "^6.0.5"
@@ -72,7 +73,5 @@
72
73
  },
73
74
  "publishConfig": {
74
75
  "access": "public"
75
- },
76
- "types": "src/index.d.ts",
77
- "type": "commonjs"
76
+ }
78
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"node.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/node/node.impl.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAQhB,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAe,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAqB5D,wBAAuB,YAAY,CACjC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe;aAgEb,OAAO;cACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;cA6QhC;AA+HD,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"node.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/node/node.impl.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAQhB,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAe,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAqB5D,wBAAuB,YAAY,CACjC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe;aAgEb,OAAO;cACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;cA6QhC;AAmJD,eAAe,YAAY,CAAC"}
@@ -295,7 +295,11 @@ function calculateResolveMappings(context, options) {
295
295
  const { dependencies } = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(context.taskGraph, context.projectGraph, context.root, parsed.project, parsed.target, parsed.configuration);
296
296
  return dependencies.reduce((m, c) => {
297
297
  if (c.node.type !== 'npm' && c.outputs[0] != null) {
298
- m[c.name] = (0, devkit_1.joinPathFragments)(context.root, c.outputs[0]);
298
+ // `outputs` are cache patterns and may contain globs (e.g. from the
299
+ // inferred `@nx/js/typescript` build target). Strip the glob portion
300
+ // so the runtime require overrides resolve to the actual output dir.
301
+ const outputDir = stripGlobToBaseDir(c.outputs[0]);
302
+ m[c.name] = (0, devkit_1.joinPathFragments)(context.root, outputDir);
299
303
  }
300
304
  return m;
301
305
  }, {});
@@ -329,7 +333,13 @@ function getFileToRun(context, project, buildOptions, buildTargetExecutor) {
329
333
  projectRoot: project.data.root,
330
334
  workspaceRoot: context.root,
331
335
  });
332
- return path.join(outputFilePath, 'main.js');
336
+ // `outputs` are cache patterns and may contain globs (e.g. the inferred
337
+ // `@nx/js/typescript` build target scopes its output to
338
+ // `{projectRoot}/dist/**/*.{js,...}` to avoid caching non-tsc files).
339
+ // Strip the glob portion back to the last path separator before it to
340
+ // recover the base output directory.
341
+ const outputDir = stripGlobToBaseDir(outputFilePath);
342
+ return path.join(outputDir, 'main.js');
333
343
  }
334
344
  const fallbackFile = path.join('dist', project.data.root, 'main.js');
335
345
  devkit_1.logger.warn(`Build option ${chalk_1.default.bold('outputFileName')} not set for ${chalk_1.default.bold(project.name)}. Using fallback value of ${chalk_1.default.bold(fallbackFile)}.`);
@@ -348,6 +358,15 @@ function getFileToRun(context, project, buildOptions, buildTargetExecutor) {
348
358
  }
349
359
  return (0, path_1.join)(context.root, buildOptions.outputPath, outputFileName);
350
360
  }
361
+ function stripGlobToBaseDir(pathWithGlob) {
362
+ const globIdx = pathWithGlob.search(/[*?[{(]/);
363
+ if (globIdx === -1) {
364
+ return pathWithGlob.replace(/[\\/]+$/, '');
365
+ }
366
+ const prefix = pathWithGlob.slice(0, globIdx);
367
+ const lastSep = Math.max(prefix.lastIndexOf('/'), prefix.lastIndexOf('\\'));
368
+ return lastSep === -1 ? '' : prefix.slice(0, lastSep);
369
+ }
351
370
  function fileToRunCorrectPath(fileToRun) {
352
371
  if ((0, fileutils_1.fileExists)(fileToRun))
353
372
  return fileToRun;
@@ -1 +1 @@
1
- {"version":3,"file":"release-publish.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/release-publish/release-publish.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAEhB,MAAM,YAAY,CAAC;AAQpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAiBjD,wBAA8B,WAAW,CACvC,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,eAAe;;GAkdzB"}
1
+ {"version":3,"file":"release-publish.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/release-publish/release-publish.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAEhB,MAAM,YAAY,CAAC;AAQpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAiBjD,wBAA8B,WAAW,CACvC,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,eAAe;;GA6dzB"}
@@ -349,7 +349,19 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
349
349
  success: false,
350
350
  };
351
351
  }
352
- const stdoutData = JSON.parse(err.stdout?.toString() || '{}');
352
+ // stdout is not guaranteed to be JSON (e.g. lifecycle script failures).
353
+ // If parsing fails, print raw stderr/stdout so the underlying error is visible to the user.
354
+ let stdoutData;
355
+ try {
356
+ stdoutData = JSON.parse(err.stdout?.toString() || '{}');
357
+ }
358
+ catch {
359
+ console.error(err.stderr?.toString() || '');
360
+ console.error(err.stdout?.toString() || '');
361
+ return {
362
+ success: false,
363
+ };
364
+ }
353
365
  console.error(`${pm} publish error:`);
354
366
  // npm returns error.summary and error.detail
355
367
  if (stdoutData.error?.summary) {
@@ -61,7 +61,6 @@ function* compileTS(context, logger, hooks, reporters) {
61
61
  });
62
62
  const rootNames = Object.keys(context);
63
63
  const solutionBuilder = ts.createSolutionBuilder(solutionBuilderHost, rootNames, {});
64
- // eslint-disable-next-line no-constant-condition
65
64
  while (true) {
66
65
  project = solutionBuilder.getNextInvalidatedProject();
67
66
  if (!project) {
@@ -13,7 +13,6 @@
13
13
  "lib": ["es2020", "dom"],
14
14
  "skipLibCheck": true,
15
15
  "skipDefaultLibCheck": true,
16
- "baseUrl": ".",
17
16
  "paths": {}
18
17
  },
19
18
  "exclude": ["node_modules", "tmp"]
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "extends": "<%= offsetFromRoot %>tsconfig.base.json",
3
3
  "compilerOptions": {
4
- "baseUrl": ".",
5
4
  "rootDir": "src",
6
5
  "outDir": "dist",
7
6
  "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
@@ -1 +1 @@
1
- {"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAUjB,IAAI,EAKL,MAAM,YAAY,CAAC;AAyCpB,OAAO,KAAK,EAEV,sBAAsB,EACtB,iCAAiC,EAClC,MAAM,UAAU,CAAC;AASlB,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAO/B;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAqK/B;AA2HD,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,iCAAiC,EAC/B,MAAM,GACN,QAAQ,GACR,aAAa,GACb,gBAAgB,GAChB,IAAI,GACJ,yBAAyB,GACzB,aAAa,GACb,SAAS,GACT,WAAW,GACX,yBAAyB,CAC5B,CAAC;AAEF,wBAAsB,OAAO,CAC3B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CA4G5B;AA6uBD,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAWjB,IAAI,EAKL,MAAM,YAAY,CAAC;AAyCpB,OAAO,KAAK,EAEV,sBAAsB,EACtB,iCAAiC,EAClC,MAAM,UAAU,CAAC;AASlB,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAO/B;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAqK/B;AA2HD,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,iCAAiC,EAC/B,MAAM,GACN,QAAQ,GACR,aAAa,GACb,gBAAgB,GAChB,IAAI,GACJ,yBAAyB,GACzB,aAAa,GACb,SAAS,GACT,WAAW,GACX,yBAAyB,CAC5B,CAAC;AAEF,wBAAsB,OAAO,CAC3B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CA4G5B;AA+uBD,eAAe,gBAAgB,CAAC"}
@@ -650,7 +650,8 @@ function addProjectDependencies(tree, options) {
650
650
  return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
651
651
  '@nx/esbuild': versions_1.nxVersion,
652
652
  '@types/node': versions_1.typesNodeVersion,
653
- esbuild: versions_1.esbuildVersion,
653
+ esbuild: (0, devkit_1.getDependencyVersionFromPackageJson)(tree, 'esbuild') ??
654
+ versions_1.esbuildVersion,
654
655
  });
655
656
  }
656
657
  else if (options.bundler == 'rollup') {
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/setup-verdaccio/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,IAAI,EAEL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAKzD,wBAAsB,cAAc,CAClC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,6BAA6B,mDA8DvC;AAED,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/setup-verdaccio/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,IAAI,EAEL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAKzD,wBAAsB,cAAc,CAClC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,6BAA6B,mDA0DvC;AAED,eAAe,cAAc,CAAC"}
@@ -6,15 +6,11 @@ const devkit_1 = require("@nx/devkit");
6
6
  const path = tslib_1.__importStar(require("path"));
7
7
  const ts_solution_setup_1 = require("../../utils/typescript/ts-solution-setup");
8
8
  const versions_1 = require("../../utils/versions");
9
- const child_process_1 = require("child_process");
9
+ const npm_config_1 = require("../../utils/npm-config");
10
10
  async function setupVerdaccio(tree, options) {
11
11
  if (!tree.exists('.verdaccio/config.yml')) {
12
12
  (0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), '.verdaccio', {
13
- npmUplinkRegistry: (0, child_process_1.execSync)('npm config get registry', {
14
- windowsHide: true,
15
- })
16
- ?.toString()
17
- ?.trim() ?? 'https://registry.npmjs.org',
13
+ npmUplinkRegistry: (await (0, npm_config_1.getNpmRegistry)(tree.root)) ?? 'https://registry.npmjs.org',
18
14
  });
19
15
  }
20
16
  const verdaccioTarget = {
package/src/internal.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { resolveModuleByImport } from './utils/typescript/ast-utils';
2
+ export { walkTsconfigExtendsChain, type RawTsconfigJsonCache, } from './utils/typescript/raw-tsconfig';
2
3
  export { registerTsProject, registerTsConfigPaths, } from 'nx/src/plugins/js/utils/register';
3
4
  export { TargetProjectLocator, isBuiltinModuleImport, } from 'nx/src/plugins/js/project-graph/build-dependencies/target-project-locator';
4
5
  export { findProjectsNpmDependencies } from 'nx/src/plugins/js/package-json/create-package-json';
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../packages/js/src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,2EAA2E,CAAC;AAEnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,oDAAoD,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../packages/js/src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACL,wBAAwB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,2EAA2E,CAAC;AAEnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,oDAAoD,CAAC"}
package/src/internal.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findProjectsNpmDependencies = exports.isBuiltinModuleImport = exports.TargetProjectLocator = exports.registerTsConfigPaths = exports.registerTsProject = exports.resolveModuleByImport = void 0;
3
+ exports.findProjectsNpmDependencies = exports.isBuiltinModuleImport = exports.TargetProjectLocator = exports.registerTsConfigPaths = exports.registerTsProject = exports.walkTsconfigExtendsChain = exports.resolveModuleByImport = void 0;
4
4
  var ast_utils_1 = require("./utils/typescript/ast-utils");
5
5
  Object.defineProperty(exports, "resolveModuleByImport", { enumerable: true, get: function () { return ast_utils_1.resolveModuleByImport; } });
6
+ var raw_tsconfig_1 = require("./utils/typescript/raw-tsconfig");
7
+ Object.defineProperty(exports, "walkTsconfigExtendsChain", { enumerable: true, get: function () { return raw_tsconfig_1.walkTsconfigExtendsChain; } });
6
8
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
7
9
  var register_1 = require("nx/src/plugins/js/utils/register");
8
10
  Object.defineProperty(exports, "registerTsProject", { enumerable: true, get: function () { return register_1.registerTsProject; } });
@@ -17,7 +17,7 @@ function startLocalRegistry({ localRegistryTarget, storage, verbose, clearStorag
17
17
  throw new Error(`localRegistryTarget is required`);
18
18
  }
19
19
  return new Promise((resolve, reject) => {
20
- const childProcess = (0, child_process_1.fork)(require.resolve('nx'), [
20
+ const childProcess = (0, child_process_1.fork)(require.resolve('nx/bin/nx'), [
21
21
  ...`run ${localRegistryTarget} --location none --clear ${clearStorage ?? true}`.split(' '),
22
22
  ...(storage ? [`--storage`, storage] : []),
23
23
  ], { stdio: 'pipe' });
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/plugins/typescript/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EAInB,MAAM,YAAY,CAAC;AA+BpB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC1B,SAAS,CAAC,EACN,OAAO,GACP;QACE,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACN,KAAK,CAAC,EACF,OAAO,GACP;QACE,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;IACN,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AA2KD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAEF,eAAO,MAAM,WAAW,sBAAsB,CAAC;AAI/C,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,gBAAgB,CA0FzD,CAAC;AAEF,eAAO,MAAM,WAAW,iCAAgB,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/plugins/typescript/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EAInB,MAAM,YAAY,CAAC;AA8BpB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC1B,SAAS,CAAC,EACN,OAAO,GACP;QACE,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACN,KAAK,CAAC,EACF,OAAO,GACP;QACE,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;IACN,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AA0KD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAEF,eAAO,MAAM,WAAW,sBAAsB,CAAC;AAI/C,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,gBAAgB,CA8FzD,CAAC;AAEF,eAAO,MAAM,WAAW,iCAAgB,CAAC"}
@@ -12,7 +12,6 @@ const lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
12
12
  const cache_directory_1 = require("nx/src/utils/cache-directory");
13
13
  const util_1 = require("./util");
14
14
  let ts;
15
- const pmc = (0, devkit_1.getPackageManagerCommand)();
16
15
  const TSCONFIG_CACHE_VERSION = 2;
17
16
  const TS_CONFIG_CACHE_PATH = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, 'tsconfig-files.hash');
18
17
  // Module-level cache store — each invocation gets a unique Symbol key
@@ -123,6 +122,7 @@ exports.createNodesV2 = [
123
122
  const cache = cacheStore.get(cacheKey);
124
123
  initializeTsConfigCache(configFilePaths, context.workspaceRoot, cache);
125
124
  const normalizedOptions = normalizePluginOptions(options);
125
+ const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
126
126
  const { configFilePaths: validConfigFilePaths, hashes, projectRoots, } = await resolveValidConfigFilesAndHashes(configFilePaths, normalizedOptions, optionsHash, context, cache);
127
127
  try {
128
128
  return await (0, devkit_1.createNodesFromFiles)((configFilePath, options, context, idx) => {
@@ -131,7 +131,7 @@ exports.createNodesV2 = [
131
131
  const targetsCacheKey = `${hash}_${configFilePath}`;
132
132
  const absolutePath = (0, node_path_1.join)(context.workspaceRoot, configFilePath);
133
133
  const configContext = getConfigContext(absolutePath, context.workspaceRoot, cache);
134
- targetsCache[targetsCacheKey] ??= buildTscTargets(configContext, options, context, validConfigFilePaths, cache);
134
+ targetsCache[targetsCacheKey] ??= buildTscTargets(configContext, options, context, validConfigFilePaths, cache, pmc);
135
135
  const { targets } = targetsCache[targetsCacheKey];
136
136
  return {
137
137
  projects: {
@@ -244,7 +244,7 @@ function checkIfConfigFileShouldBeProject(config, cache) {
244
244
  }
245
245
  return true;
246
246
  }
247
- function buildTscTargets(config, options, context, configFiles, cache) {
247
+ function buildTscTargets(config, options, context, configFiles, cache, pmc) {
248
248
  const targets = {};
249
249
  const namedInputs = (0, get_named_inputs_1.getNamedInputs)(config.project.root, context);
250
250
  const tsConfig = retrieveTsConfigFromCache(config.absolutePath, context.workspaceRoot, cache);
@@ -456,17 +456,18 @@ function getInputs(namedInputs, config, tsConfig, internalProjectReferences, wor
456
456
  if (excludePaths.size) {
457
457
  inputs.push(...Array.from(excludePaths).map((p) => `!${pathToInputOrOutput((0, devkit_1.joinPathFragments)(config.project.root, p), workspaceRoot, config.project)}`));
458
458
  }
459
- // tsc --build reads .d.ts and .tsbuildinfo files from dependent tasks, not
460
- // the source files of dependencies. This correctly tracks build outputs from
461
- // both external project references and same-project task dependencies (e.g.
462
- // build-native producing .d.ts files that may be excluded from file watching
463
- // via .nxignore. "*.d.ts" are also read from the deps projects sources.
459
+ // tsc --build reads .d.ts/.d.cts/.d.mts and .tsbuildinfo files from dependent
460
+ // tasks, not the source files of dependencies. This correctly tracks build
461
+ // outputs from both external project references and same-project task
462
+ // dependencies (e.g. build-native producing .d.ts files that may be excluded
463
+ // from file watching via .nxignore). Declaration files are also read from
464
+ // the deps projects sources.
464
465
  inputs.push({
465
- dependentTasksOutputFiles: '**/*.{d.ts,tsbuildinfo}',
466
+ dependentTasksOutputFiles: '**/*.{d.ts,d.cts,d.mts,tsbuildinfo}',
466
467
  transitive: true,
467
468
  });
468
469
  inputs.push({
469
- fileset: '**/*.d.ts',
470
+ fileset: '{projectRoot}/**/*.{d.ts,d.cts,d.mts}',
470
471
  dependencies: true,
471
472
  });
472
473
  const externalRefPatterns = getExternalProjectReferenceTsconfigPatterns(tsConfig, internalProjectReferences, workspaceRoot, config.project, cache);
@@ -496,36 +497,21 @@ function getOutputs(config, rootTsConfig, internalProjectReferences, workspaceRo
496
497
  outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(outDir, `${outFileName}.js.map`), workspaceRoot, config.project));
497
498
  outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(outDir, `${outFileName}.d.ts`), workspaceRoot, config.project));
498
499
  outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(outDir, `${outFileName}.d.ts.map`), workspaceRoot, config.project));
499
- // https://www.typescriptlang.org/tsconfig#tsBuildInfoFile
500
- outputs.add(tsConfig.options.tsBuildInfoFile
501
- ? pathToInputOrOutput(tsConfig.options.tsBuildInfoFile, workspaceRoot, config.project)
502
- : pathToInputOrOutput((0, devkit_1.joinPathFragments)(outDir, `${outFileName}.tsbuildinfo`), workspaceRoot, config.project));
503
500
  }
504
501
  else if (tsConfig.options.outDir) {
505
502
  if (emitDeclarationOnly) {
506
- outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, '**/*.d.ts'), workspaceRoot, config.project));
503
+ outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, '**/*.{d.ts,d.cts,d.mts}'), workspaceRoot, config.project));
507
504
  if (tsConfig.options.declarationMap) {
508
- outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, '**/*.d.ts.map'), workspaceRoot, config.project));
505
+ outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, '**/*.{d.ts,d.cts,d.mts}.map'), workspaceRoot, config.project));
509
506
  }
510
507
  }
511
508
  else {
512
- outputs.add(pathToInputOrOutput(tsConfig.options.outDir, workspaceRoot, config.project));
513
- }
514
- if (tsConfig.options.tsBuildInfoFile) {
515
- if (emitDeclarationOnly ||
516
- !(0, node_path_1.normalize)(tsConfig.options.tsBuildInfoFile).startsWith(`${(0, node_path_1.normalize)(tsConfig.options.outDir)}${node_path_1.sep}`)) {
517
- // https://www.typescriptlang.org/tsconfig#tsBuildInfoFile
518
- outputs.add(pathToInputOrOutput(tsConfig.options.tsBuildInfoFile, workspaceRoot, config.project));
519
- }
520
- }
521
- else if (tsConfig.options.rootDir && tsConfig.options.rootDir !== '.') {
522
- // If rootDir is set, then the tsbuildinfo file will be outside the outDir so we need to add it.
523
- const relativeRootDir = (0, node_path_1.relative)(tsConfig.options.rootDir, (0, node_path_1.join)(workspaceRoot, config.project.root));
524
- outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, relativeRootDir, `*.tsbuildinfo`), workspaceRoot, config.project));
525
- }
526
- else if (emitDeclarationOnly) {
527
- // https://www.typescriptlang.org/tsconfig#tsBuildInfoFile
528
- outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, `${configBaseNameNoExt}.tsbuildinfo`), workspaceRoot, config.project));
509
+ // List specific tsc output extensions instead of claiming the
510
+ // entire outDir, so other tasks that write into the same
511
+ // directory (e.g. copy-assets for .node/.wasm files) don't
512
+ // have their outputs captured by the tsc build cache.
513
+ const jsonExt = tsConfig.options.resolveJsonModule ? ',json' : '';
514
+ outputs.add(pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, `**/*.{js,cjs,mjs,jsx${jsonExt},d.ts,d.cts,d.mts}{,.map}`), workspaceRoot, config.project));
529
515
  }
530
516
  }
531
517
  else if (tsConfig.raw?.include?.length ||
@@ -544,14 +530,30 @@ function getOutputs(config, rootTsConfig, internalProjectReferences, workspaceRo
544
530
  outputs.add((0, devkit_1.joinPathFragments)('{projectRoot}', '**/*.d.ts.map'));
545
531
  outputs.add((0, devkit_1.joinPathFragments)('{projectRoot}', '**/*.d.cts.map'));
546
532
  outputs.add((0, devkit_1.joinPathFragments)('{projectRoot}', '**/*.d.mts.map'));
547
- // https://www.typescriptlang.org/tsconfig#tsBuildInfoFile
548
- outputs.add(tsConfig.options.tsBuildInfoFile
549
- ? pathToInputOrOutput(tsConfig.options.tsBuildInfoFile, workspaceRoot, config.project)
550
- : (0, devkit_1.joinPathFragments)('{projectRoot}', `${configBaseNameNoExt}.tsbuildinfo`));
551
533
  }
534
+ // tsc --build always produces a tsbuildinfo file.
535
+ outputs.add(getTsBuildInfoOutputPath(tsConfig, configBaseNameNoExt, workspaceRoot, config.project));
552
536
  });
553
537
  return Array.from(outputs);
554
538
  }
539
+ /**
540
+ * Returns the path to the tsbuildinfo file that tsc --build will produce.
541
+ * tsc always emits this file in build mode (incremental is implicit).
542
+ */
543
+ function getTsBuildInfoOutputPath(tsConfig, configBaseNameNoExt, workspaceRoot, project) {
544
+ if (tsConfig.options.tsBuildInfoFile) {
545
+ return pathToInputOrOutput(tsConfig.options.tsBuildInfoFile, workspaceRoot, project);
546
+ }
547
+ if (tsConfig.options.outFile) {
548
+ const outFileName = (0, node_path_1.basename)(tsConfig.options.outFile, '.js');
549
+ const outDir = (0, node_path_1.relative)(workspaceRoot, (0, node_path_1.dirname)(tsConfig.options.outFile));
550
+ return pathToInputOrOutput((0, devkit_1.joinPathFragments)(outDir, `${outFileName}.tsbuildinfo`), workspaceRoot, project);
551
+ }
552
+ if (tsConfig.options.outDir) {
553
+ return pathToInputOrOutput((0, devkit_1.joinPathFragments)(tsConfig.options.outDir, `${configBaseNameNoExt}.tsbuildinfo`), workspaceRoot, project);
554
+ }
555
+ return (0, devkit_1.joinPathFragments)('{projectRoot}', `${configBaseNameNoExt}.tsbuildinfo`);
556
+ }
555
557
  function pathToInputOrOutput(path, workspaceRoot, project) {
556
558
  const fullProjectRoot = project.absolute;
557
559
  const fullPath = (0, node_path_1.resolve)(workspaceRoot, path);
@@ -1,5 +1,8 @@
1
1
  import { AssetGlob } from './assets';
2
+ import { normalizeAssets, getAssetOutputPath, NormalizedAssetEntry as AssetEntry } from './normalize-assets';
2
3
  import { ChangedFile } from 'nx/src/daemon/client/client';
4
+ export type { AssetEntry };
5
+ export { normalizeAssets, getAssetOutputPath };
3
6
  export type FileEventType = 'create' | 'update' | 'delete';
4
7
  export interface FileEvent {
5
8
  type: FileEventType;
@@ -32,5 +35,4 @@ export declare class CopyAssetsHandler {
32
35
  private filesToEvent;
33
36
  private normalizeAssetPattern;
34
37
  }
35
- export {};
36
38
  //# sourceMappingURL=copy-assets-handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"copy-assets-handler.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/assets/copy-assets-handler.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,WAAW,EAAgB,MAAM,6BAA6B,CAAC;AAGxE,MAAM,MAAM,aAAa,GAAG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B;IA2BnC,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB3C,wBAAwB,IAAI,IAAI;IAgBhC,OAAO,CAAC,yBAAyB;IAa3B,4BAA4B,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC;IA2BnD,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiC9D,OAAO,CAAC,YAAY;IAiBpB,OAAO,CAAC,qBAAqB;CAG9B"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CopyAssetsHandler = exports.defaultFileEventHandler = void 0;
3
+ exports.CopyAssetsHandler = exports.defaultFileEventHandler = exports.getAssetOutputPath = exports.normalizeAssets = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const picomatch = require("picomatch");
6
6
  const node_fs_1 = require("node:fs");
@@ -8,6 +8,9 @@ const pathPosix = tslib_1.__importStar(require("node:path/posix"));
8
8
  const path = tslib_1.__importStar(require("node:path"));
9
9
  const ignore_1 = tslib_1.__importDefault(require("ignore"));
10
10
  const tinyglobby_1 = require("tinyglobby");
11
+ const normalize_assets_1 = require("./normalize-assets");
12
+ Object.defineProperty(exports, "normalizeAssets", { enumerable: true, get: function () { return normalize_assets_1.normalizeAssets; } });
13
+ Object.defineProperty(exports, "getAssetOutputPath", { enumerable: true, get: function () { return normalize_assets_1.getAssetOutputPath; } });
11
14
  const devkit_1 = require("@nx/devkit");
12
15
  const client_1 = require("nx/src/daemon/client/client");
13
16
  const picocolors_1 = require("picocolors");
@@ -49,40 +52,7 @@ class CopyAssetsHandler {
49
52
  if ((0, node_fs_1.existsSync)(nxignore)) {
50
53
  this.ignore.add((0, node_fs_1.readFileSync)(nxignore).toString());
51
54
  }
52
- this.assetGlobs = opts.assets.map((f) => {
53
- let isGlob = false;
54
- let pattern;
55
- // Input and output directories are normalized to be relative to root
56
- let input;
57
- let output;
58
- let ignore = null;
59
- let includeIgnoredFiles = undefined;
60
- const resolvedOutputDir = path.isAbsolute(opts.outputDir)
61
- ? opts.outputDir
62
- : path.resolve(opts.rootDir, opts.outputDir);
63
- if (typeof f === 'string') {
64
- pattern = f;
65
- input = path.relative(opts.rootDir, opts.projectDir);
66
- output = path.relative(opts.rootDir, resolvedOutputDir);
67
- }
68
- else {
69
- isGlob = true;
70
- pattern = pathPosix.join(f.input, f.glob);
71
- input = f.input;
72
- output = pathPosix.join(path.relative(opts.rootDir, resolvedOutputDir), f.output);
73
- if (f.ignore)
74
- ignore = f.ignore.map((ig) => pathPosix.join(f.input, ig));
75
- includeIgnoredFiles = f.includeIgnoredFiles;
76
- }
77
- return {
78
- isGlob,
79
- input,
80
- pattern,
81
- ignore,
82
- output,
83
- includeIgnoredFiles,
84
- };
85
- });
55
+ this.assetGlobs = (0, normalize_assets_1.normalizeAssets)(opts.assets, opts.rootDir, opts.projectDir, opts.outputDir);
86
56
  }
87
57
  async processAllAssetsOnce() {
88
58
  await Promise.all(this.assetGlobs.map(async (ag) => {
@@ -181,12 +151,10 @@ class CopyAssetsHandler {
181
151
  if (!assetGlob.ignore?.some((ig) => picomatch(ig)(src)) &&
182
152
  ((assetGlob.includeIgnoredFiles ?? this.includeIgnoredFiles) ||
183
153
  !this.ignore.ignores(src))) {
184
- const relPath = path.relative(assetGlob.input, src);
185
- const dest = relPath.startsWith('..') ? src : relPath;
186
154
  acc.push({
187
155
  type: 'create',
188
156
  src: path.join(this.rootDir, src),
189
- dest: path.join(this.rootDir, assetGlob.output, dest),
157
+ dest: path.join(this.rootDir, (0, normalize_assets_1.getAssetOutputPath)(src, assetGlob)),
190
158
  });
191
159
  }
192
160
  return acc;
@@ -0,0 +1,26 @@
1
+ export interface AssetGlobInput {
2
+ input: string;
3
+ output: string;
4
+ glob: string;
5
+ ignore?: string[];
6
+ includeIgnoredFiles?: boolean;
7
+ }
8
+ export interface NormalizedAssetEntry {
9
+ isGlob: boolean;
10
+ pattern: string;
11
+ ignore: string[] | null;
12
+ input: string;
13
+ output: string;
14
+ includeIgnoredFiles?: boolean;
15
+ }
16
+ /**
17
+ * Normalize raw asset definitions (strings or objects) into resolved
18
+ * entries with computed input, output, and pattern fields.
19
+ */
20
+ export declare function normalizeAssets(assets: (string | AssetGlobInput)[], rootDir: string, projectDir: string, outputDir: string): NormalizedAssetEntry[];
21
+ /**
22
+ * Compute the output path for a file given its asset entry,
23
+ * matching the dest logic used during file copying.
24
+ */
25
+ export declare function getAssetOutputPath(src: string, assetEntry: NormalizedAssetEntry): string;
26
+ //# sourceMappingURL=normalize-assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-assets.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/assets/normalize-assets.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,EACnC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,oBAAoB,EAAE,CA8BxB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,oBAAoB,GAC/B,MAAM,CAIR"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeAssets = normalizeAssets;
4
+ exports.getAssetOutputPath = getAssetOutputPath;
5
+ const tslib_1 = require("tslib");
6
+ const path = tslib_1.__importStar(require("node:path"));
7
+ const pathPosix = tslib_1.__importStar(require("node:path/posix"));
8
+ /**
9
+ * Normalize raw asset definitions (strings or objects) into resolved
10
+ * entries with computed input, output, and pattern fields.
11
+ */
12
+ function normalizeAssets(assets, rootDir, projectDir, outputDir) {
13
+ const resolvedOutputDir = path.isAbsolute(outputDir)
14
+ ? outputDir
15
+ : path.resolve(rootDir, outputDir);
16
+ return assets.map((f) => {
17
+ if (typeof f === 'string') {
18
+ return {
19
+ isGlob: false,
20
+ pattern: f,
21
+ input: path.relative(rootDir, projectDir),
22
+ output: path.relative(rootDir, resolvedOutputDir),
23
+ ignore: null,
24
+ includeIgnoredFiles: undefined,
25
+ };
26
+ }
27
+ return {
28
+ isGlob: true,
29
+ pattern: pathPosix.join(f.input, f.glob),
30
+ input: f.input,
31
+ output: pathPosix.join(path.relative(rootDir, resolvedOutputDir), f.output),
32
+ ignore: f.ignore
33
+ ? f.ignore.map((ig) => pathPosix.join(f.input, ig))
34
+ : null,
35
+ includeIgnoredFiles: f.includeIgnoredFiles,
36
+ };
37
+ });
38
+ }
39
+ /**
40
+ * Compute the output path for a file given its asset entry,
41
+ * matching the dest logic used during file copying.
42
+ */
43
+ function getAssetOutputPath(src, assetEntry) {
44
+ const relPath = path.relative(assetEntry.input, src);
45
+ const dest = relPath.startsWith('..') ? src : relPath;
46
+ return pathPosix.join(assetEntry.output, dest);
47
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"buildable-libs-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/js/src/utils/buildable-libs-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACxB,uBAAuB,EACvB,SAAS,EACV,MAAM,YAAY,CAAC;AAYpB,OAAO,KAAK,KA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IACnC,oBAAoB,EAAE,6BAA6B,EAAE,CAAC;CACvD,CA8EA;AAkGD;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,GAAG,EAAE,CAAC,iBAAiB,EACvC,YAAY,EAAE,6BAA6B,EAAE,wBAK9C;AAED,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,6BAA6B,EAAE,EAC7C,qBAAqB,GAAE,OAAe,UA2BvC;AAUD,wBAAgB,WAAW,CACzB,YAAY,EAAE,6BAA6B,EAAE,EAC7C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,QAoDhC;AAED;;;GAGG;AACH,wBAAgB,6CAA6C,CAC3D,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,uBAAuB,EAC7B,YAAY,EAAE,6BAA6B,EAAE,EAC7C,gBAAgB,GAAE,cAAc,GAAG,kBAAmC,QAkFvE"}
1
+ {"version":3,"file":"buildable-libs-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/js/src/utils/buildable-libs-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACxB,uBAAuB,EACvB,SAAS,EACV,MAAM,YAAY,CAAC;AAYpB,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAgBtC,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,uBAAuB,GAAG,wBAAwB,CAAC;CAC1D,CAAC;AAEF,wBAAgB,qCAAqC,CACnD,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,SAAS,EAAE,YAAY,EACvB,IAAI,EAAE,MAAM,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,EAAE,6BAA6B,EAAE,EAC7C,qBAAqB,GAAE,OAAe,UAsBvC;AAUD,wBAAgB,WAAW,CACzB,YAAY,EAAE,6BAA6B,EAAE,EAC7C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,QA6DhC;AAED;;;GAGG;AACH,wBAAgB,6CAA6C,CAC3D,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,uBAAuB,EAC7B,YAAY,EAAE,6BAA6B,EAAE,EAC7C,gBAAgB,GAAE,cAAc,GAAG,kBAAmC,QAkFvE"}
@@ -114,7 +114,20 @@ function readTsConfigWithRemappedPaths(originalTsconfigPath, generatedTsconfigPa
114
114
  const normalizedTsConfig = (0, path_1.resolve)(workspaceRoot, originalTsconfigPath);
115
115
  const normalizedGeneratedTsConfigDir = (0, path_1.resolve)(workspaceRoot, (0, path_1.dirname)(generatedTsconfigPath));
116
116
  generatedTsConfig.extends = (0, path_1.relative)(normalizedGeneratedTsConfigDir, normalizedTsConfig);
117
- generatedTsConfig.compilerOptions.paths = computeCompilerOptionsPaths(normalizedTsConfig, dependencies);
117
+ const paths = computeCompilerOptionsPaths(normalizedTsConfig, dependencies);
118
+ // Resolve paths to absolute so they work regardless of the tmp tsconfig
119
+ // location and without needing baseUrl (deprecated in TS 6, removed in TS 7).
120
+ const pathsBase = (0, ts_config_1.resolvePathsBaseUrl)(normalizedTsConfig);
121
+ for (const key of Object.keys(paths)) {
122
+ paths[key] = paths[key].map((p) => {
123
+ if ((0, path_1.isAbsolute)(p)) {
124
+ return p;
125
+ }
126
+ const stripped = p.startsWith('./') ? p.slice(2) : p;
127
+ return (0, path_1.resolve)(pathsBase, stripped).replace(/\\/g, '/');
128
+ });
129
+ }
130
+ generatedTsConfig.compilerOptions.paths = paths;
118
131
  if (process.env.NX_VERBOSE_LOGGING_PATH_MAPPINGS === 'true') {
119
132
  output_1.output.log({
120
133
  title: 'TypeScript path mappings have been rewritten.',
@@ -235,10 +248,6 @@ function createTmpTsConfig(tsconfigPath, workspaceRoot, projectRoot, dependencie
235
248
  }
236
249
  const parsedTSConfig = readTsConfigWithRemappedPaths(tsconfigPath, tmpTsConfigPath, dependencies, workspaceRoot);
237
250
  process.on('exit', () => cleanupTmpTsConfigFile(tmpTsConfigPath));
238
- if (useWorkspaceAsBaseUrl) {
239
- parsedTSConfig.compilerOptions ??= {};
240
- parsedTSConfig.compilerOptions.baseUrl = workspaceRoot;
241
- }
242
251
  (0, devkit_1.writeJsonFile)(tmpTsConfigPath, parsedTSConfig);
243
252
  return (0, path_1.join)(tmpTsConfigPath);
244
253
  }
@@ -285,6 +294,12 @@ function updatePaths(dependencies, paths) {
285
294
  }
286
295
  }
287
296
  });
297
+ // Ensure all path values use ./ prefix for TS 6+ compatibility (no baseUrl)
298
+ for (const key of Object.keys(paths)) {
299
+ paths[key] = paths[key].map((p) => p.startsWith('./') || p.startsWith('../') || p.startsWith('/')
300
+ ? p
301
+ : `./${p}`);
302
+ }
288
303
  }
289
304
  /**
290
305
  * Updates the peerDependencies section in the `dist/lib/xyz/package.json` with
@@ -150,10 +150,10 @@ function collectHelperDependencies(workspaceRoot, sourceProject, projectGraph, b
150
150
  }
151
151
  // For inferred targets or manually added run-commands, check if user is using `tsc` in build target.
152
152
  if (target.executor === 'nx:run-commands' &&
153
- /\btsc\b/.test(target.options.command)) {
154
- const tsConfigFileName = (0, ts_config_1.getRootTsConfigFileName)();
155
- if (tsConfigFileName) {
156
- const tsConfig = (0, ts_config_1.readTsConfig)((0, path_1.join)(workspaceRoot, tsConfigFileName));
153
+ /\b(tsc|tsgo)\b/.test(target.options.command)) {
154
+ const tsConfigPath = resolveTsConfigForRunCommandsTarget(workspaceRoot, sourceProject, target.options);
155
+ if (tsConfigPath) {
156
+ const tsConfig = (0, ts_config_1.readTsConfig)(tsConfigPath);
157
157
  if (tsConfig?.options['importHelpers'] &&
158
158
  projectGraph.externalNodes['npm:tslib']?.type === 'npm') {
159
159
  npmDeps['tslib'] = projectGraph.externalNodes['npm:tslib'].data.version;
@@ -161,3 +161,24 @@ function collectHelperDependencies(workspaceRoot, sourceProject, projectGraph, b
161
161
  }
162
162
  }
163
163
  }
164
+ function resolveTsConfigForRunCommandsTarget(workspaceRoot, sourceProject, targetOptions) {
165
+ const commandTsConfig = extractTsConfigFromCommand(targetOptions.command);
166
+ if (commandTsConfig) {
167
+ const cwd = targetOptions.cwd ?? sourceProject.data.root;
168
+ const cwdAbsolute = (0, path_1.isAbsolute)(cwd) ? cwd : (0, path_1.join)(workspaceRoot, cwd);
169
+ const resolved = (0, path_1.isAbsolute)(commandTsConfig)
170
+ ? commandTsConfig
171
+ : (0, path_1.join)(cwdAbsolute, commandTsConfig);
172
+ if ((0, fileutils_1.fileExists)(resolved))
173
+ return resolved;
174
+ }
175
+ // Preserves prior behavior when the tsconfig can't be determined from the command.
176
+ return (0, ts_config_1.getRootTsConfigPath)();
177
+ }
178
+ // Matches the `<compiler> --build <configName>` shape emitted by the
179
+ // `@nx/js/typescript` plugin. Other shapes fall through to the workspace root
180
+ // tsconfig in the caller.
181
+ function extractTsConfigFromCommand(command) {
182
+ const match = command.match(/(?:^|\s)--build\s+([^\s-]\S*)/);
183
+ return match ? match[1] : null;
184
+ }
@@ -12,7 +12,6 @@ export declare const tsConfigBaseOptions: {
12
12
  lib: string[];
13
13
  skipLibCheck: boolean;
14
14
  skipDefaultLibCheck: boolean;
15
- baseUrl: string;
16
15
  paths: {};
17
16
  };
18
17
  export declare function extractTsConfigBase(host: Tree): void;
@@ -1 +1 @@
1
- {"version":3,"file":"create-ts-config.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/create-ts-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAG9C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;CAe/B,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,QAmC7C"}
1
+ {"version":3,"file":"create-ts-config.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/create-ts-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAG9C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;CAc/B,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,QA+B7C"}
@@ -16,7 +16,6 @@ exports.tsConfigBaseOptions = {
16
16
  lib: ['es2020', 'dom'],
17
17
  skipLibCheck: true,
18
18
  skipDefaultLibCheck: true,
19
- baseUrl: '.',
20
19
  paths: {},
21
20
  };
22
21
  function extractTsConfigBase(host) {
@@ -31,10 +30,6 @@ function extractTsConfigBase(host) {
31
30
  delete tsconfig.compilerOptions[compilerOption];
32
31
  }
33
32
  }
34
- // If we don't set baseDir then builds will fail when more than one projects exist.
35
- if (typeof baseCompilerOptions.baseUrl === 'undefined') {
36
- baseCompilerOptions.baseUrl = '.';
37
- }
38
33
  (0, json_1.writeJson)(host, 'tsconfig.base.json', {
39
34
  compileOnSave: false,
40
35
  compilerOptions: baseCompilerOptions,
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Lightweight tsconfig extends walker that does NOT load the `typescript`
3
+ * package. For full TypeScript-aware parsing (compilerOptions resolution,
4
+ * file lists, project references, etc.) see the `@nx/js/typescript` plugin,
5
+ * which uses `ts.parseJsonConfigFileContent` and a persistent cache.
6
+ */
7
+ /**
8
+ * Cache of raw parsed tsconfig JSON contents, keyed by absolute file path.
9
+ * `null` indicates a file that doesn't exist or failed to parse.
10
+ *
11
+ * Instantiate with `new Map()` and reuse across `walkTsconfigExtendsChain`
12
+ * calls within one `createNodes` invocation to dedupe file reads when many
13
+ * starting points share parent tsconfigs.
14
+ */
15
+ export type RawTsconfigJsonCache = Map<string, unknown | null>;
16
+ /**
17
+ * Walks the `extends` chain of a tsconfig, invoking `visit` for each unique
18
+ * reachable file (entry first, then recursively). Cycle-safe. Files that
19
+ * don't exist or fail to parse are silently skipped.
20
+ *
21
+ * When a tsconfig has multiple `extends` entries they are visited in
22
+ * REVERSE order, so visitors looking for the effective value of an
23
+ * inherited option see the highest-precedence entries first and can
24
+ * return `'stop'` to abort the traversal. Visitors that want to collect
25
+ * every reachable file should always return `'continue'`.
26
+ *
27
+ * @param entryAbsolutePath Absolute, canonical path of the tsconfig to
28
+ * start from. Pass through `path.resolve()` if unsure.
29
+ * @param visit Invoked once per unique reachable tsconfig.
30
+ * @param options.jsonCache Optional shared cache of parsed tsconfig
31
+ * contents. When omitted, the walker uses a fresh internal cache.
32
+ */
33
+ export declare function walkTsconfigExtendsChain(entryAbsolutePath: string, visit: (absolutePath: string, rawJson: unknown) => 'continue' | 'stop', options?: {
34
+ jsonCache?: RawTsconfigJsonCache;
35
+ }): void;
36
+ //# sourceMappingURL=raw-tsconfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw-tsconfig.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/raw-tsconfig.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC;AAE/D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CACtC,iBAAiB,EAAE,MAAM,EACzB,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,UAAU,GAAG,MAAM,EACtE,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,oBAAoB,CAAA;CAAE,GAC7C,IAAI,CAGN"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.walkTsconfigExtendsChain = walkTsconfigExtendsChain;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const node_path_1 = require("node:path");
6
+ /**
7
+ * Walks the `extends` chain of a tsconfig, invoking `visit` for each unique
8
+ * reachable file (entry first, then recursively). Cycle-safe. Files that
9
+ * don't exist or fail to parse are silently skipped.
10
+ *
11
+ * When a tsconfig has multiple `extends` entries they are visited in
12
+ * REVERSE order, so visitors looking for the effective value of an
13
+ * inherited option see the highest-precedence entries first and can
14
+ * return `'stop'` to abort the traversal. Visitors that want to collect
15
+ * every reachable file should always return `'continue'`.
16
+ *
17
+ * @param entryAbsolutePath Absolute, canonical path of the tsconfig to
18
+ * start from. Pass through `path.resolve()` if unsure.
19
+ * @param visit Invoked once per unique reachable tsconfig.
20
+ * @param options.jsonCache Optional shared cache of parsed tsconfig
21
+ * contents. When omitted, the walker uses a fresh internal cache.
22
+ */
23
+ function walkTsconfigExtendsChain(entryAbsolutePath, visit, options) {
24
+ const jsonCache = options?.jsonCache ?? new Map();
25
+ walk(entryAbsolutePath, visit, jsonCache, new Set());
26
+ }
27
+ function walk(absolutePath, visit, jsonCache, visited) {
28
+ if (visited.has(absolutePath))
29
+ return 'continue';
30
+ visited.add(absolutePath);
31
+ const json = readCachedJson(absolutePath, jsonCache);
32
+ if (json === null)
33
+ return 'continue';
34
+ if (visit(absolutePath, json) === 'stop')
35
+ return 'stop';
36
+ const extendsField = json.extends;
37
+ if (!extendsField)
38
+ return 'continue';
39
+ const extendsList = Array.isArray(extendsField)
40
+ ? extendsField
41
+ : [extendsField];
42
+ // Last entry wins per TypeScript precedence; walk in reverse so
43
+ // precedence-aware visitors see the highest-precedence entries first.
44
+ const fromDir = (0, node_path_1.dirname)(absolutePath);
45
+ for (let i = extendsList.length - 1; i >= 0; i--) {
46
+ const ext = extendsList[i];
47
+ if (typeof ext !== 'string' || !ext)
48
+ continue;
49
+ const childPath = resolveExtendsPath(ext, fromDir);
50
+ if (childPath === null)
51
+ continue;
52
+ if (walk(childPath, visit, jsonCache, visited) === 'stop')
53
+ return 'stop';
54
+ }
55
+ return 'continue';
56
+ }
57
+ function readCachedJson(absolutePath, cache) {
58
+ if (cache.has(absolutePath)) {
59
+ return cache.get(absolutePath) ?? null;
60
+ }
61
+ let parsed;
62
+ try {
63
+ parsed = (0, devkit_1.readJsonFile)(absolutePath);
64
+ }
65
+ catch {
66
+ parsed = null;
67
+ }
68
+ cache.set(absolutePath, parsed);
69
+ return parsed;
70
+ }
71
+ function resolveExtendsPath(extendsValue, fromDir) {
72
+ try {
73
+ return require.resolve(extendsValue, { paths: [fromDir] });
74
+ }
75
+ catch {
76
+ return null;
77
+ }
78
+ }
@@ -7,5 +7,19 @@ export declare function getRelativePathToRootTsConfig(tree: Tree, targetPath: st
7
7
  export declare function getRootTsConfigPath(): string | null;
8
8
  export declare function getRootTsConfigFileName(tree?: Tree): string | null;
9
9
  export declare function addTsConfigPath(tree: Tree, importPath: string, lookupPaths: string[]): void;
10
+ /**
11
+ * When `baseUrl` is not set and `paths` are inherited via `extends`,
12
+ * tools like `tsconfig-paths` resolve from the loaded file's directory
13
+ * instead of the file where `paths` is defined. This walks the `extends`
14
+ * chain to find the correct resolution base.
15
+ *
16
+ * Returns the directory that `paths` values should be resolved relative to.
17
+ * Walks the tsconfig `extends` chain to find where `paths` is defined, then
18
+ * looks for the applicable `baseUrl` from that point toward the root of the
19
+ * chain (ignoring child overrides that don't apply to the paths-defining
20
+ * tsconfig). When no `baseUrl` applies, returns the directory of the
21
+ * tsconfig that defines `paths`.
22
+ */
23
+ export declare function resolvePathsBaseUrl(tsconfigPath: string): string;
10
24
  export declare function readTsConfigPaths(tsConfig?: string | ts.ParsedCommandLine): ts.MapLike<string[]>;
11
25
  //# sourceMappingURL=ts-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ts-config.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/ts-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAA6B,MAAM,YAAY,CAAC;AAG7E,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAKtC,wBAAgB,YAAY,CAC1B,YAAY,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,EAAE,CAAC,MAAM,GACd,EAAE,CAAC,iBAAiB,CAatB;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,MAAM,GACnB,EAAE,CAAC,iBAAiB,CAWtB;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAQnE;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAED,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAInD;AAED,wBAAgB,uBAAuB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAYlE;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EAAE,QAiBtB;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,iBAAiB,wBA8BzE"}
1
+ {"version":3,"file":"ts-config.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/ts-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAA6B,MAAM,YAAY,CAAC;AAG7E,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAKtC,wBAAgB,YAAY,CAC1B,YAAY,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,EAAE,CAAC,MAAM,GACd,EAAE,CAAC,iBAAiB,CAatB;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,MAAM,GACnB,EAAE,CAAC,iBAAiB,CAWtB;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAQnE;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAED,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAInD;AAED,wBAAgB,uBAAuB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAYlE;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EAAE,QAiBtB;AASD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAmDhE;AAgCD,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,iBAAiB,wBA+BzE"}
@@ -7,6 +7,7 @@ exports.getRelativePathToRootTsConfig = getRelativePathToRootTsConfig;
7
7
  exports.getRootTsConfigPath = getRootTsConfigPath;
8
8
  exports.getRootTsConfigFileName = getRootTsConfigFileName;
9
9
  exports.addTsConfigPath = addTsConfigPath;
10
+ exports.resolvePathsBaseUrl = resolvePathsBaseUrl;
10
11
  exports.readTsConfigPaths = readTsConfigPaths;
11
12
  const devkit_1 = require("@nx/devkit");
12
13
  const fs_1 = require("fs");
@@ -65,30 +66,130 @@ function addTsConfigPath(tree, importPath, lookupPaths) {
65
66
  if (c.paths[importPath]) {
66
67
  throw new Error(`You already have a library using the import path "${importPath}". Make sure to specify a unique one.`);
67
68
  }
68
- c.paths[importPath] = lookupPaths;
69
+ c.paths[importPath] = lookupPaths.map(ensureRelativePath);
69
70
  return json;
70
71
  });
71
72
  }
73
+ function ensureRelativePath(p) {
74
+ if (p.startsWith('./') || p.startsWith('../') || p.startsWith('/')) {
75
+ return p;
76
+ }
77
+ return `./${p}`;
78
+ }
79
+ /**
80
+ * When `baseUrl` is not set and `paths` are inherited via `extends`,
81
+ * tools like `tsconfig-paths` resolve from the loaded file's directory
82
+ * instead of the file where `paths` is defined. This walks the `extends`
83
+ * chain to find the correct resolution base.
84
+ *
85
+ * Returns the directory that `paths` values should be resolved relative to.
86
+ * Walks the tsconfig `extends` chain to find where `paths` is defined, then
87
+ * looks for the applicable `baseUrl` from that point toward the root of the
88
+ * chain (ignoring child overrides that don't apply to the paths-defining
89
+ * tsconfig). When no `baseUrl` applies, returns the directory of the
90
+ * tsconfig that defines `paths`.
91
+ */
92
+ function resolvePathsBaseUrl(tsconfigPath) {
93
+ const chain = [];
94
+ const queue = [tsconfigPath];
95
+ while (queue.length > 0) {
96
+ const absolute = (0, path_1.resolve)(queue.shift());
97
+ const dir = (0, path_1.dirname)(absolute);
98
+ try {
99
+ const raw = JSON.parse((0, fs_1.readFileSync)(absolute, 'utf-8'));
100
+ chain.push({ dir, raw });
101
+ const exts = raw.extends
102
+ ? Array.isArray(raw.extends)
103
+ ? raw.extends
104
+ : [raw.extends]
105
+ : [];
106
+ for (const ext of exts) {
107
+ const resolved = resolveExtendsPath(ext, dir);
108
+ if (resolved) {
109
+ queue.push(resolved);
110
+ }
111
+ }
112
+ }
113
+ catch {
114
+ // skip unreadable files
115
+ }
116
+ }
117
+ // Find where paths is defined.
118
+ let pathsIndex = -1;
119
+ for (let i = 0; i < chain.length; i++) {
120
+ if (chain[i].raw.compilerOptions?.paths &&
121
+ Object.keys(chain[i].raw.compilerOptions.paths).length > 0) {
122
+ pathsIndex = i;
123
+ break;
124
+ }
125
+ }
126
+ // Find the applicable baseUrl: search from the paths-defining tsconfig
127
+ // toward the root. Child overrides before the paths-defining tsconfig
128
+ // are ignored — they don't apply to the paths that were written for a
129
+ // different baseUrl context.
130
+ const searchStart = pathsIndex >= 0 ? pathsIndex : 0;
131
+ for (let i = searchStart; i < chain.length; i++) {
132
+ if (chain[i].raw.compilerOptions?.baseUrl) {
133
+ return (0, path_1.resolve)(chain[i].dir, chain[i].raw.compilerOptions.baseUrl);
134
+ }
135
+ }
136
+ return pathsIndex >= 0
137
+ ? chain[pathsIndex].dir
138
+ : (0, path_1.dirname)((0, path_1.resolve)(tsconfigPath));
139
+ }
140
+ /**
141
+ * Resolves a tsconfig `extends` entry to an absolute path.
142
+ * Handles relative paths, absolute paths, and package names
143
+ * (e.g., `@tsconfig/node20/tsconfig.json` or `@tsconfig/strictest`).
144
+ * Mirrors TypeScript's resolution: relative/absolute paths are resolved
145
+ * directly (with `.json` fallback), package names use `require.resolve`
146
+ * with a `tsconfig.json` fallback for bare package names.
147
+ */
148
+ function resolveExtendsPath(ext, fromDir) {
149
+ if (ext.startsWith('.') || (0, path_1.isAbsolute)(ext)) {
150
+ let resolved = (0, path_1.resolve)(fromDir, ext);
151
+ if ((0, fs_1.existsSync)(resolved))
152
+ return resolved;
153
+ if (!resolved.endsWith('.json')) {
154
+ resolved += '.json';
155
+ if ((0, fs_1.existsSync)(resolved))
156
+ return resolved;
157
+ }
158
+ return null;
159
+ }
160
+ // Package name — try as-is, then with /tsconfig.json appended
161
+ try {
162
+ return require.resolve(ext, { paths: [fromDir] });
163
+ }
164
+ catch {
165
+ try {
166
+ return require.resolve(`${ext}/tsconfig.json`, { paths: [fromDir] });
167
+ }
168
+ catch {
169
+ return null;
170
+ }
171
+ }
172
+ }
72
173
  function readTsConfigPaths(tsConfig) {
73
174
  tsConfig ??= getRootTsConfigPath();
74
175
  try {
75
- if (!tsModule) {
76
- tsModule = (0, ensure_typescript_1.ensureTypescript)();
77
- }
78
176
  let config;
79
177
  if (typeof tsConfig === 'string') {
178
+ if (!tsModule) {
179
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
180
+ }
80
181
  const configFile = tsModule.readConfigFile(tsConfig, tsModule.sys.readFile);
81
- config = tsModule.parseJsonConfigFileContent(configFile.config, tsModule.sys, (0, path_1.dirname)(tsConfig));
182
+ // Stub `readDirectory` to skip the source-file scan — only `paths` is consumed.
183
+ const parseConfigHost = {
184
+ ...tsModule.sys,
185
+ readDirectory: () => [],
186
+ };
187
+ config = tsModule.parseJsonConfigFileContent(configFile.config, parseConfigHost, (0, path_1.dirname)(tsConfig));
82
188
  }
83
189
  else {
84
190
  config = tsConfig;
85
191
  }
86
- if (config.options?.paths) {
87
- return config.options.paths;
88
- }
89
- else {
90
- return null;
91
- }
192
+ return config.options?.paths ?? null;
92
193
  }
93
194
  catch (e) {
94
195
  return null;
@@ -1,5 +1,5 @@
1
1
  export declare const nxVersion: any;
2
- export declare const esbuildVersion = "^0.19.2";
2
+ export declare const esbuildVersion = "^0.27.0";
3
3
  export declare const prettierVersion = "~3.6.2";
4
4
  export declare const swcCliVersion = "~0.8.0";
5
5
  export declare const swcCoreVersion = "~1.15.5";
@@ -7,7 +7,7 @@ export declare const swcHelpersVersion = "~0.5.18";
7
7
  export declare const swcNodeVersion = "~1.11.1";
8
8
  export declare const tsLibVersion = "^2.3.0";
9
9
  export declare const typesNodeVersion = "20.19.9";
10
- export declare const verdaccioVersion = "^6.0.5";
10
+ export declare const verdaccioVersion = "^6.3.2";
11
11
  export declare const typescriptVersion = "~5.9.2";
12
12
  /**
13
13
  * The minimum version is currently determined from the lowest version
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.supportedTypescriptVersions = exports.typescriptVersion = exports.verdaccioVersion = exports.typesNodeVersion = exports.tsLibVersion = exports.swcNodeVersion = exports.swcHelpersVersion = exports.swcCoreVersion = exports.swcCliVersion = exports.prettierVersion = exports.esbuildVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
- exports.esbuildVersion = '^0.19.2';
5
+ exports.esbuildVersion = '^0.27.0';
6
6
  exports.prettierVersion = '~3.6.2';
7
7
  exports.swcCliVersion = '~0.8.0';
8
8
  exports.swcCoreVersion = '~1.15.5';
@@ -10,7 +10,7 @@ exports.swcHelpersVersion = '~0.5.18';
10
10
  exports.swcNodeVersion = '~1.11.1';
11
11
  exports.tsLibVersion = '^2.3.0';
12
12
  exports.typesNodeVersion = '20.19.9';
13
- exports.verdaccioVersion = '^6.0.5';
13
+ exports.verdaccioVersion = '^6.3.2';
14
14
  // Typescript
15
15
  exports.typescriptVersion = '~5.9.2';
16
16
  /**