@nx/js 23.2.1 → 23.3.0-beta.1

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.
@@ -171,7 +171,10 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
171
171
  stdio: ['ignore', 'pipe', 'pipe'],
172
172
  windowsHide: true,
173
173
  });
174
- const resultJson = JSON.parse(result.toString());
174
+ // `npm view`/`bun info` can exit 0 with empty stdout when the package exists in the registry but has
175
+ // no published versions or dist-tags yet (e.g. GitHub packages). Treat empty output the samme as
176
+ // package not existing yet and continue to the publish step.
177
+ const resultJson = JSON.parse(result.toString().trim() || '{}');
175
178
  const distTags = resultJson['dist-tags'] || {};
176
179
  if (distTags[tag] === currentVersion) {
177
180
  console.warn(`Skipped ${packageTxt} because v${currentVersion} already exists in ${registry} with tag "${tag}"`);
@@ -125,6 +125,7 @@ exports.createNodesV2 = [
125
125
  configOwners: new Map(),
126
126
  projectContexts: new Map(),
127
127
  configContexts: new Map(),
128
+ referenceExpansionCache: new Map(),
128
129
  });
129
130
  const cache = cacheStore.get(cacheKey);
130
131
  initializeTsConfigCache(configFilePaths, context.workspaceRoot, cache);
@@ -701,62 +702,100 @@ function getExternalProjectReferenceTsconfigPatterns(tsConfig, internalProjectRe
701
702
  continue;
702
703
  }
703
704
  visited.add(configPath);
704
- const wsRelPath = posixRelative(workspaceRoot, configPath);
705
- const tsConfigData = tsConfigCacheData[wsRelPath]?.data;
706
- if (!tsConfigData) {
707
- continue;
705
+ const expansion = getReferenceExpansion(configPath, ownerProject, workspaceRoot, cache);
706
+ // Extended-config patterns follow the traversal's first-visit semantics.
707
+ for (const extended of expansion.extendedConfigs) {
708
+ if (visited.has(extended.configPath)) {
709
+ continue;
710
+ }
711
+ uniqueRelPaths.add(extended.pattern);
712
+ worklist.push({
713
+ configPath: extended.configPath,
714
+ ownerProject: extended.ownerProject,
715
+ });
716
+ }
717
+ // Reference patterns are collected even when traversal already visited them.
718
+ for (const ref of expansion.projectReferences) {
719
+ if (ref.pattern !== undefined) {
720
+ uniqueRelPaths.add(ref.pattern);
721
+ }
722
+ if (!visited.has(ref.configPath)) {
723
+ worklist.push({
724
+ configPath: ref.configPath,
725
+ ownerProject: ref.ownerProject,
726
+ });
727
+ }
708
728
  }
729
+ }
730
+ return Array.from(uniqueRelPaths).map((relPath) => `^{projectRoot}/${relPath}`);
731
+ }
732
+ /**
733
+ * Returns a config's immediate `extends` and project-reference expansion for
734
+ * the current owner, caching it for reuse within this invocation. Transitive
735
+ * traversal, ordering, and visited checks remain with the caller.
736
+ */
737
+ function getReferenceExpansion(configPath, ownerProject, workspaceRoot, cache) {
738
+ const configKey = posixRelative(workspaceRoot, configPath);
739
+ // Reference classification and relative patterns depend on the owner.
740
+ const ownerKey = ownerProject.normalized;
741
+ let ownerCache = cache.referenceExpansionCache.get(configKey);
742
+ const cached = ownerCache?.get(ownerKey);
743
+ if (cached) {
744
+ return cached;
745
+ }
746
+ const expansion = {
747
+ extendedConfigs: [],
748
+ projectReferences: [],
749
+ };
750
+ const tsConfigData = tsConfigCacheData[configKey]?.data;
751
+ if (tsConfigData) {
709
752
  // Walk `extends` chains for the visited tsconfig. tsc reads extended
710
753
  // configs while resolving project references, so the rel paths must be
711
754
  // emitted as inputs. Workspace-root files (no owning project) are skipped
712
755
  // — those are covered by the local project's own extends walk.
713
- if (tsConfigData.extendedConfigFiles?.length) {
714
- for (const extended of tsConfigData.extendedConfigFiles) {
715
- if (!extended.filePath || visited.has(extended.filePath)) {
716
- continue;
717
- }
718
- const extendedWsRelPath = posixRelative(workspaceRoot, extended.filePath);
719
- if (!tsConfigCacheData[extendedWsRelPath]) {
720
- continue;
721
- }
722
- const extendedContext = getConfigContext(extended.filePath, workspaceRoot, cache);
723
- if (extendedContext.project.root &&
724
- extendedContext.project.root !== '.') {
725
- uniqueRelPaths.add(posixRelative(extendedContext.project.absolute, extended.filePath));
726
- worklist.push({
727
- configPath: extended.filePath,
728
- ownerProject: extendedContext.project,
729
- });
730
- }
756
+ for (const extended of tsConfigData.extendedConfigFiles ?? []) {
757
+ if (!extended.filePath) {
758
+ continue;
759
+ }
760
+ const extendedWsRelPath = posixRelative(workspaceRoot, extended.filePath);
761
+ if (!tsConfigCacheData[extendedWsRelPath]) {
762
+ continue;
763
+ }
764
+ const extendedContext = getConfigContext(extended.filePath, workspaceRoot, cache);
765
+ if (extendedContext.project.root &&
766
+ extendedContext.project.root !== '.') {
767
+ expansion.extendedConfigs.push({
768
+ configPath: extended.filePath,
769
+ ownerProject: extendedContext.project,
770
+ pattern: posixRelative(extendedContext.project.absolute, extended.filePath),
771
+ });
731
772
  }
732
773
  }
733
- if (!tsConfigData.projectReferences?.length) {
734
- continue;
735
- }
736
- for (const ref of tsConfigData.projectReferences) {
774
+ for (const ref of tsConfigData.projectReferences ?? []) {
737
775
  let refPath = ref.path;
738
776
  if (!refPath.endsWith('.json')) {
739
777
  refPath = (0, node_path_1.join)(refPath, 'tsconfig.json');
740
778
  }
741
- // Skip references not found in the tsconfig cache
779
+ // References absent from the invocation's tsconfig data remain ignored.
742
780
  const refWsRelPath = posixRelative(workspaceRoot, refPath);
743
781
  if (!tsConfigCacheData[refWsRelPath]) {
744
782
  continue;
745
783
  }
746
784
  const refContext = getConfigContext(refPath, workspaceRoot, cache);
747
- // Collect paths for references within the same project
748
- if (!isExternalProjectReference(refContext, ownerProject, workspaceRoot, cache)) {
749
- uniqueRelPaths.add(posixRelative(ownerProject.absolute, refPath));
750
- }
751
- if (!visited.has(refPath)) {
752
- worklist.push({
753
- configPath: refPath,
754
- ownerProject: refContext.project,
755
- });
756
- }
785
+ expansion.projectReferences.push({
786
+ configPath: refPath,
787
+ ownerProject: refContext.project,
788
+ // Only references owned by this project contribute input patterns.
789
+ pattern: isExternalProjectReference(refContext, ownerProject, workspaceRoot, cache)
790
+ ? undefined
791
+ : posixRelative(ownerProject.absolute, refPath),
792
+ });
757
793
  }
758
794
  }
759
- return Array.from(uniqueRelPaths).map((relPath) => `^{projectRoot}/${relPath}`);
795
+ ownerCache ??= new Map();
796
+ ownerCache.set(ownerKey, expansion);
797
+ cache.referenceExpansionCache.set(configKey, ownerCache);
798
+ return expansion;
760
799
  }
761
800
  function isExternalProjectReference(refConfig, project, workspaceRoot, cache) {
762
801
  const owner = cache.configOwners.get(refConfig.relativePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "23.2.1",
3
+ "version": "23.3.0-beta.1",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -147,18 +147,18 @@
147
147
  "source-map-support": "0.5.19",
148
148
  "tinyglobby": "^0.2.12",
149
149
  "tslib": "^2.3.0",
150
- "@nx/devkit": "23.2.1",
151
- "@nx/workspace": "23.2.1"
150
+ "@nx/devkit": "23.3.0-beta.1",
151
+ "@nx/workspace": "23.3.0-beta.1"
152
152
  },
153
153
  "devDependencies": {
154
- "@nx/eslint": "23.2.1",
155
- "@nx/esbuild": "23.2.1",
156
- "@nx/jest": "23.2.1",
157
- "@nx/oxlint": "23.2.1",
158
- "@nx/rollup": "23.2.1",
159
- "@nx/vite": "23.2.1",
160
- "@nx/vitest": "23.2.1",
161
- "nx": "23.2.1"
154
+ "@nx/jest": "23.3.0-beta.1",
155
+ "@nx/esbuild": "23.3.0-beta.1",
156
+ "@nx/eslint": "23.3.0-beta.1",
157
+ "@nx/oxlint": "23.3.0-beta.1",
158
+ "@nx/rollup": "23.3.0-beta.1",
159
+ "@nx/vite": "23.3.0-beta.1",
160
+ "@nx/vitest": "23.3.0-beta.1",
161
+ "nx": "23.3.0-beta.1"
162
162
  },
163
163
  "peerDependencies": {
164
164
  "@swc/cli": ">=0.6.0 <0.9.0",