Commit 251a7d9
fix(js): improve
## Current Behavior
The `@nx/js/typescript` plugin exhibits the following wrong behaviors
when it comes to determining whether a project is buildable:
- Having a custom conditional export other than `development` pointing
to a source file means the project is not buildable
- Having any conditional export pointing to source files means the
project is not buildable
- It falls back to check against included files when `outDir` is defined
The above creates issues where some buildable libraries are not
identified.
## Expected Behavior
The `@nx/js/typescript` plugin should behave as follows (simplified)
when it comes to determining whether a project is buildable:
- If `outFile` is defined:
- If the `.` entry point is defined and it's pointing to the `outFile`
or any of its conditional exports are pointing to the `outFile`, it's
buildable
- If `exports` is not defined and `main` or `module` are defined and
pointing to the `outFile`, it's buildable
- Otherwise, it's not buildable
- Otherwise, if `outDir` is defined:
- If the `.` entry point is defined and it's pointing to a path
contained in the `outDir` or any of its conditional exports are pointing
to a path contained in the `outDir`, it's buildable
- If `exports` is not defined and `main` or `module` are defined and
pointing to a path contained in the `outDir`, it's buildable
- Otherwise, it's not buildable
- Otherwise (no `outFile` and no `outDir`):
- If the `.` entry point is defined and it's pointing to a path not
matched by the `files` or `include` patterns or any of its conditional
exports are pointing to a path not matched by the `files` or `include`
patterns, it's buildable
- If `exports` is not defined and `main` or `module` are defined and
pointing to a path not matched by the `files` or `include` patterns,
it's buildable
- Otherwise, it's not buildable
The above also ensures that custom conditional exports are not a factor,
given that all that is needed is that at least one conditional export is
deemed non-buildable.
## Related Issue(s)
Fixes #32116
Fixes #32290
(cherry picked from commit 4bf937e)@nx/js/typescript plugin check for buildable libraries (#32405)1 parent 2b4dea3 commit 251a7d9
3 files changed
Lines changed: 878 additions & 130 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6064 | 6064 | | |
6065 | 6065 | | |
6066 | 6066 | | |
6067 | | - | |
| 6067 | + | |
6068 | 6068 | | |
6069 | 6069 | | |
6070 | 6070 | | |
| |||
6094 | 6094 | | |
6095 | 6095 | | |
6096 | 6096 | | |
6097 | | - | |
| 6097 | + | |
6098 | 6098 | | |
6099 | 6099 | | |
6100 | 6100 | | |
| |||
6150 | 6150 | | |
6151 | 6151 | | |
6152 | 6152 | | |
6153 | | - | |
| 6153 | + | |
| 6154 | + | |
| 6155 | + | |
| 6156 | + | |
| 6157 | + | |
| 6158 | + | |
| 6159 | + | |
| 6160 | + | |
| 6161 | + | |
| 6162 | + | |
| 6163 | + | |
| 6164 | + | |
| 6165 | + | |
6154 | 6166 | | |
6155 | 6167 | | |
6156 | 6168 | | |
| |||
0 commit comments