fix(js): correctly validate buildable packages when outDir is outside… #34276
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
… project root
Previously,
isAnyEntryPointPointingToOutDirin the TypeScript plugin assumed that ifoutDirresolves to a path outside the project root, the package is automatically buildable. This caused incorrect behavior when users have base tsconfig in non-standard directories (like.config/), because TypeScript resolvesoutDirrelative to the config file containing it.The fix removes the short-circuit logic and always validates that package.json exports actually point to the resolved outDir.
Closes #34243
Current Behavior
The
isAnyEntryPointPointingToOutDirfunction in the@nx/js/typescriptplugin assumes that ifoutDirresolves to a path outside the project root, the package is automatically buildable. This causes incorrect behavior when:tsconfig.jsonin non-standard directories (like.config/)outDir: "dist"which TypeScript resolves relative to the base config directoryoutDirbecomes.config/distinstead ofpackages/mylib/distpackage.jsonexports don't point to the actual output directoryExpected Behavior
The plugin should always validate that
package.jsonexports actually point to files inside the resolvedoutDir, regardless of whether theoutDiris inside or outside the project root.With this fix:
outDirare correctly identified as buildableoutDir) are correctly identified as non-buildable.config/) get correct build target inference when they properly overrideoutDirin their project's tsconfigRelated Issue(s)
Fixes #34243