Skip to content
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

fix(nx): resolves file paths by checking if the resolved path exists before proceeding with fallback file matching. #29472

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

estebanfelipep
Copy link

The fallback path resolution was only happening if the resolvedFile was a falsy value, so it was returning inexistent filepaths.

This pull request includes a small but important change to the packages/vite/plugins/nx-tsconfig-paths.plugin.ts file. The change improves the reliability of resolving file paths by checking if the resolved path exists before proceeding with fallback file matching.

Current Behavior

The resolver doesn't resolve the full file path, it ignores the file extension. For example, for a path like this:
import mergeClassNames from '@projects/global/utils/mergeClassNames'

It resolves to
absolutePath.../projects/libs/global/src/utils/mergeClassNames

When vite is building a project, it doesn't find the file and it errors.

This happens because the resolved file path is not a falsy value, thus, it doesn't run the fallback file path matching.

Expected Behavior

What is expected is that it resolves to (notice the file extension)
absolutePath.../projects/libs/global/src/utils/mergeClassNames.ts

Related Issue(s)

The fallback path resolution was only happening if the resolvedFile was a falsy value, so it was returning inexistent filepaths.
@estebanfelipep estebanfelipep requested a review from a team as a code owner December 26, 2024 17:22
Copy link

vercel bot commented Dec 26, 2024

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

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Dec 26, 2024 5:24pm

Copy link

nx-cloud bot commented Dec 26, 2024

View your CI Pipeline Execution ↗ for commit c930f56.

Command Status Duration Result
nx-cloud record -- nx format:check --base=fbd3d... ❌ Failed 22s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 21s View ↗
nx documentation --no-dte ✅ Succeeded 41s View ↗

☁️ Nx Cloud last updated this comment at 2024-12-26 17:29:37 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant