-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Private package folders with Yarn PnP #6945
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
I think the best would be for the opposite: whitelisting instead of blacklisting. While PnP did a lot to prevent useless I/O calls, some still are needed simply because of the extension resolution ( But if we assume that packages explicitly describe their entry points, then the resolution can be done without any I/O - the algorithm would just have to check whether the resolution endpoints is meant to exist! {
"entrypoints": [
"./fp/index.js",
"./foo.js",
]
} Or, if you don't want to allow access to anything else than the index (like in your case): {
"entrypoints": [
"./index.js",
]
} |
Yep, as stated in the original comment, a whitelist is fine with me too. Either way, the same result is accomplished so I'm totally happy with this :) |
This would be great, common pain point 👍 |
I have written code to manually detect and prevent this; it would be great to have baked-in support. Regarding whitelist vs blacklist: I'm probably on the extreme side of this, but I would prefer that we disallow importing anything other than |
Closing as this is solved by using the |
Currently, in the JavaScript ecosystem, any file from a package can be required even if it is considered as private API by the package author, for example:
There is no way to hide private API besides compiling a project into a single flat bundle and only exposing the public API. Very few people choose to do this, and it may not be ideal in terms of load times – it may make sense for some packages to have two or three top level modules instead of one.
With Yarn PnP controlling the resolution algorithm it is now possible to prevent access to certain files and folders from other locations. There are two ways to pick a private folder:
private
or similar, orpackage.json
.This would have the effect that only a limited subset of a package is available to the outside, while the package code can still be distributed in a manageable way.
Let me know what you think about this – feel free to create an RFC based on this idea or even better – send a Pull Request with a proposed implementation :)
The text was updated successfully, but these errors were encountered: