@nx/js 22.6.0-beta.11 → 22.6.0-beta.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "22.6.0-beta.11",
3
+ "version": "22.6.0-beta.12",
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": {
@@ -39,8 +39,8 @@
39
39
  "@babel/preset-env": "^7.23.2",
40
40
  "@babel/preset-typescript": "^7.22.5",
41
41
  "@babel/runtime": "^7.22.6",
42
- "@nx/devkit": "22.6.0-beta.11",
43
- "@nx/workspace": "22.6.0-beta.11",
42
+ "@nx/devkit": "22.6.0-beta.12",
43
+ "@nx/workspace": "22.6.0-beta.12",
44
44
  "@zkochan/js-yaml": "0.0.7",
45
45
  "babel-plugin-const-enum": "^1.0.1",
46
46
  "babel-plugin-macros": "^3.1.0",
@@ -60,7 +60,7 @@
60
60
  "tslib": "^2.3.0"
61
61
  },
62
62
  "devDependencies": {
63
- "nx": "22.6.0-beta.11"
63
+ "nx": "22.6.0-beta.12"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "verdaccio": "^6.0.5"
@@ -456,15 +456,21 @@ 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
- if (hasExternalProjectReferences(config.originalPath, tsConfig, workspaceRoot, config.project, cache)) {
460
- // tsc --build reads .d.ts and .tsbuildinfo files from referenced projects
461
- // https://www.typescriptlang.org/docs/handbook/project-references.html#what-is-a-project-reference
462
- inputs.push({
463
- dependentTasksOutputFiles: '**/*.{d.ts,tsbuildinfo}',
464
- });
465
- }
466
- else {
467
- inputs.push('production' in namedInputs ? '^production' : '^default');
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).
464
+ inputs.push({
465
+ dependentTasksOutputFiles: '**/*.{d.ts,tsbuildinfo}',
466
+ transitive: true,
467
+ });
468
+ const externalRefConfigFiles = getExternalProjectReferenceConfigFiles(tsConfig, internalProjectReferences, workspaceRoot, config.project, cache, configFiles);
469
+ if (externalRefConfigFiles.length > 0) {
470
+ // tsc --build also reads the tsconfig files from external project
471
+ // references (and their extended configs) when processing project
472
+ // references, so we need to add them as inputs
473
+ inputs.push(...externalRefConfigFiles.map((p) => pathToInputOrOutput(p, workspaceRoot, config.project)));
468
474
  }
469
475
  // inputs.push({ externalDependencies });
470
476
  return inputs;
@@ -617,33 +623,35 @@ function resolveShallowExternalProjectReferences(tsConfig, workspaceRoot, projec
617
623
  }
618
624
  return projectReferences;
619
625
  }
620
- function hasExternalProjectReferences(tsConfigPath, tsConfig, workspaceRoot, project, cache, seen = new Set()) {
621
- if (!tsConfig.projectReferences?.length) {
622
- return false;
623
- }
624
- seen.add(tsConfigPath);
625
- for (const ref of tsConfig.projectReferences) {
626
- let refConfigPath = ref.path;
627
- if (seen.has(refConfigPath)) {
628
- continue;
629
- }
630
- if (!(0, node_fs_1.existsSync)(refConfigPath)) {
631
- continue;
632
- }
633
- if (!refConfigPath.endsWith('.json')) {
634
- refConfigPath = (0, node_path_1.join)(refConfigPath, 'tsconfig.json');
635
- }
636
- const refContext = getConfigContext(refConfigPath, workspaceRoot, cache);
637
- if (isExternalProjectReference(refContext, project, workspaceRoot, cache)) {
638
- return true;
639
- }
640
- const refTsConfig = retrieveTsConfigFromCache(refConfigPath, workspaceRoot, cache);
641
- const result = hasExternalProjectReferences(refConfigPath, refTsConfig, workspaceRoot, project, cache, seen);
642
- if (result) {
643
- return true;
626
+ /**
627
+ * Collects config file paths from external project references, including their
628
+ * extended config files. It checks the root tsconfig and all internal project
629
+ * references for their direct external references.
630
+ */
631
+ function getExternalProjectReferenceConfigFiles(tsConfig, internalProjectReferences, workspaceRoot, project, cache, existingConfigFiles) {
632
+ const externalRefs = {};
633
+ // Collect direct external references from the root tsconfig
634
+ resolveShallowExternalProjectReferences(tsConfig, workspaceRoot, project, cache, externalRefs);
635
+ // Collect external references from internal project references
636
+ for (const refTsConfig of Object.values(internalProjectReferences)) {
637
+ resolveShallowExternalProjectReferences(refTsConfig, workspaceRoot, project, cache, externalRefs);
638
+ }
639
+ const result = [];
640
+ const seen = new Set();
641
+ for (const [refConfigPath, refTsConfig] of Object.entries(externalRefs)) {
642
+ if (!existingConfigFiles.has(refConfigPath) && !seen.has(refConfigPath)) {
643
+ result.push(refConfigPath);
644
+ seen.add(refConfigPath);
645
+ }
646
+ const extendedFiles = getExtendedConfigFiles(refTsConfig, workspaceRoot, cache);
647
+ for (const extFile of extendedFiles.files) {
648
+ if (!existingConfigFiles.has(extFile) && !seen.has(extFile)) {
649
+ result.push(extFile);
650
+ seen.add(extFile);
651
+ }
644
652
  }
645
653
  }
646
- return false;
654
+ return result;
647
655
  }
648
656
  function isExternalProjectReference(refConfig, project, workspaceRoot, cache) {
649
657
  const owner = cache.configOwners.get(refConfig.relativePath);