feat(linter): add support for package based secondary entry points#30809
feat(linter): add support for package based secondary entry points#30809
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
View your CI Pipeline Execution ↗ for commit 0fc58c0.
☁️ Nx Cloud last updated this comment at |
52238cf to
4647209
Compare
| return []; | ||
| } | ||
| const entryPaths: Array<{ path: string; file: string }> = []; | ||
| for (const [key, value] of Object.entries<string>(exports)) { |
There was a problem hiding this comment.
Thanks, let me rework that.
| if (key !== '.' && key !== './') { | ||
| entryPaths.push({ | ||
| path: joinPathFragments(projectRoot, key), | ||
| file: joinPathFragments(projectRoot, value), |
There was a problem hiding this comment.
The value here could be a string, but it could also be an object with conditional exports. It can also be null to disable the entry point from being used.
| projectRoot | ||
| function getEntryPoint(file: string, projectRoot: string): string { | ||
| const packageEntryPoints = getPackageEntryPoints(projectRoot); | ||
| const fileEntryPoint = packageEntryPoints.find( |
There was a problem hiding this comment.
The entry points could have patterns (*), which would require a more complex matching to find whether an import matches a given entry point.
There was a problem hiding this comment.
Let's handle this later if users request it. I'm worried this might impact performance significantly so I would not add it unless requested.
| for (const [key, value] of Object.entries<string>(exports)) { | ||
| if (key !== '.' && key !== './') { | ||
| entryPaths.push({ | ||
| path: joinPathFragments(projectRoot, key), |
There was a problem hiding this comment.
The key could be the condition name of a conditional export.
992695f to
0fc58c0
Compare
…30809) This PR adds support for package.json based secondary entry points and implements fix for situation when package imports base entry point as dynamic dependency and secondary entry point as static dependency. ## Current Behavior When the package is imported from itself, check for a secondary entry point checks only Angular-style secondary entry points. When package is importing from the same library as dynamic import from root and static import from secondary entry point we still get linter errror. ## Expected Behavior Check for secondary entry points should also support standard package.json-based entry points. Importing from the same library as dynamic import from root and static import from secondary entry point should be allowed. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #18552 (cherry picked from commit cd55dfc)
|
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. |
This PR adds support for package.json based secondary entry points and implements fix for situation when package imports base entry point as dynamic dependency and secondary entry point as static dependency.
Current Behavior
When the package is imported from itself, check for a secondary entry point checks only Angular-style secondary entry points.
When package is importing from the same library as dynamic import from root and static import from secondary entry point we still get linter errror.
Expected Behavior
Check for secondary entry points should also support standard package.json-based entry points.
Importing from the same library as dynamic import from root and static import from secondary entry point should be allowed.
Related Issue(s)
Fixes #18552