-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
package.json exports violations aren't caught #2960
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
This is known; we don’t support exports yet, because When it is supported there, we will support it here. It’s a best practice anyways to have exports mirror the filesystem for back compatibility, and doing that makes everything work with this plugin, fwiw. |
@ljharb thanks for the quick response, however I disagree about this being a duplicate, and kindly request that this is reopened. #2132 is about missing #2525 barely has any content, but even then its talking about unused code causing an issue. My issue and example project is about attempting to use code that is disallowed by the runtime.
Again, nothing about having the exports mirroring the filesystem or not. Its about encapsulating modules inside of a package |
You're right that it's not an exact duplicate, but they all have the same root cause - exports is not yet supported. I'm quite familiar with the purpose of |
Sorry, I'm still missing what mirroring
backwards compatibility isn't a concern for me at the moment, but I'll pocket this for later, thank you!
This part specifically I'm confused about. In my sample project I'm exporting "./index.mjs" as ".", but my concern has nothing to do with Thanks for your time |
Sorry if I’ve been unclear. I’m not saying to add unwanted entries to exports - I’m saying to make sure that wanted entries have a LHS that matches the RHS. Regardless, until we support exports, we can’t warn on importing things that exports should be restricting. |
since Node 12, it is possible to define a restricted set of
exports
which allow encapsulation of modules in a package. It should be an error if an import of any module not in the set ofexports
is attempted. Otherwise, the error will not be caught until runtime.import/no-internal-modules
andimport/no-restricted-paths
are not sufficient solutions for this issue, as they require manual upkeepI made a sample repository demonstrating the issue. It should be pretty simple to checkout and run
The text was updated successfully, but these errors were encountered: