-
Notifications
You must be signed in to change notification settings - Fork 2.5k
ESLint enforce-module-boundaries rule fails with library split in secondary entry points and mixed loading scenarios #18552
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
Comments
Thank you @edbzn for reporting this. To be honest, this was on our list for a while. We will get to it as soon as possible. |
Thank you for working on this. Is there any update @meeroslav? Much appreciated. |
Sadly not yet |
Hi i have come here to create issue when i saw i had been already created. This is really common for shared libraries with secondary entry points as a code-splitting / tree-shaking implementation. We have several huge applications with libraries (@company/ui for the instance) which are usually small and eagerly loaded (in HTML template of parent components, imported etc)... however there are huge components too, which are usually loaded lazily (with custom dyanimc-component, dynamic import(), or... with the latest defer() angular feature).
defer() is at the moment not possible to use as far as the component is usually loaded as secondary entry point... @meeroslav is it possible to escalate this issue, pllease? |
+1 |
Looks like theres a checkDynamicDependenciesExceptions option, seems you can add lazy loaded imports to this but haven't had the opportunity to try it yet: https://nx.dev/nx-api/eslint-plugin/documents/enforce-module-boundaries |
Yeah, however this will lead to 40 exceptions in our case as far as we have /ui library with lot of components and secondary entry points and ...as far as defer does not work effectively without that and we have lot of "3rd party" huge libraries involved in them (spreadsheets etc.) IT does not sound so "exceptional" then :D |
Not sure if this would cover it, but similarly I would love for the |
Any updates? |
1 similar comment
Any updates? |
I see that secondary entry points do not appear as separate nodes in nx graph. Maybe they should be? |
HI @meeroslav is this issue planned or on any roadmap? |
This issue has been automatically marked as stale because it hasn't had any activity for 6 months. |
Please no. Or opt-in. Every bigger monorepo has hundreds of SEPs... |
This issue will have to be fixed The first one (#30809) solves the problem for Angular, which has a clearly defined secondary entry point definition.
See update below 👇 |
Decided to fix everything in a single PR:
|
…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 issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Uh oh!
There was an error while loading. Please reload this page.
Current Behavior
The ESLint rule enforce-module-boundaries enforce libs to be lazy loaded as far as a dynamic import is detected. This is great for most scenarios, but not working well when a library is split into multiple secondary entry points.
Consider the following scenario where lib A is split into 2 secondary entry points core and feature, and lib B needs to lazy load feature and to statically load core:
Then the enforce-module-boundaries rule is failing because lib A is marked as "lazy", and everything should be lazy loaded as far as a dynamic import is detected.
Expected Behavior
Statically importing core secondary entry points should not throw
static imports of lazy-loaded libraries are forbidden
.Secondary entry points should be taken into account when checking for static imports when a library is considered lazy, allowing the rule to statically import secondary entry points that have not been imported dynamically.
GitHub Repo
https://github.com/edbzn/nx-static-import-issue/tree/main
Steps to Reproduce
nx lint lib-b
Nx Report
Failure Logs
No response
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: