Skip to content

fix(core): resolve subpath patterns in package exports correctly when constructing graph #30511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2025

Conversation

leosvelperez
Copy link
Member

Current Behavior

When a package has a subpath pattern like the following:

{
  "exports": {
    "./*": {
      "types": "./dist/lib/*/index.d.ts",
      "import": "./dist/lib/*/index.js",
      "default": "./dist/lib/*/index.js"
    }
  }
}

When constructing the graph the project is not picked as a dependency of others projects that import from the package using a path that matches that subpath pattern. This is currently happening because the current resolution is wrongly using minimatch to match those patterns instead of the Node.js spec for resolving subpath patterns.

Expected Behavior

Subpath patterns should be processed after the Node.js spec and the graph should pick up dependencies when used.

Related Issue(s)

Fixes #30342

@leosvelperez leosvelperez self-assigned this Mar 26, 2025
@leosvelperez leosvelperez requested review from a team as code owners March 26, 2025 18:19
Copy link

vercel bot commented Mar 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview Mar 26, 2025 6:22pm

Copy link

nx-cloud bot commented Mar 26, 2025

View your CI Pipeline Execution ↗ for commit 4c7872c.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 5m 46s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 20s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check --base=1a235... ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 1s View ↗
nx documentation ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-03-27 08:46:43 UTC

@leosvelperez leosvelperez merged commit b3c6d2d into master Apr 2, 2025
12 checks passed
@leosvelperez leosvelperez deleted the core/fix-package-exports-subpath-resolution branch April 2, 2025 08:29
jaysoo pushed a commit that referenced this pull request Apr 2, 2025
… constructing graph (#30511)

## Current Behavior

When a package has a subpath pattern like the following:

```json
{
  "exports": {
    "./*": {
      "types": "./dist/lib/*/index.d.ts",
      "import": "./dist/lib/*/index.js",
      "default": "./dist/lib/*/index.js"
    }
  }
}
```

When constructing the graph the project is not picked as a dependency of
others projects that import from the package using a path that matches
that subpath pattern. This is currently happening because the current
resolution is wrongly using `minimatch` to match those patterns instead
of the [Node.js spec for resolving subpath
patterns](https://nodejs.org/docs/latest-v22.x/api/esm.html#resolution-algorithm-specification).

## Expected Behavior

Subpath patterns should be processed after the [Node.js
spec](https://nodejs.org/docs/latest-v22.x/api/esm.html#resolution-algorithm-specification)
and the graph should pick up dependencies when used.

## Related Issue(s)

Fixes #30342
Copy link

github-actions bot commented Apr 8, 2025

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants