-
Notifications
You must be signed in to change notification settings - Fork 14
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
How to blacklist specific directories? #46
Comments
This comment has been minimized.
This comment has been minimized.
@ljharb not sure how that is any different to putting additional |
True, it's basically the same. |
Ok, here is one possible way to blacklist that seems to work: {
"name": "a",
"main": "lib",
"exports": {
".": "./lib/index.js",
"./lib/": "./lib/",
"./lib/helpers/": "./this-dir-doesnt-exist/"
}
} For Is there a problem with doing this, will people understand that this fake path is on purpose, and not a mistake? |
Instead of a fake path, what if you do |
Good ideas, here's the results.
Looks like they are both invalid :( |
I think |
Right, but that means it throws - correctly - when you attempt to access the path? |
Sure it throws, but the Even the fake path solution is not ideal in that regard, because the |
To my knowledge "exports" is only applied from the package.json at the top-level of any package. I've experimented with putting package.json in sub-directories and was not able to get node.js to recognize it. In node.js 13.10.0+ the following seems to produce the desired result: "name": "pkg1",
"exports": {
"./lib/": "./lib/",
"./lib/helpers/": {}
} See https://github.com/coreyfarrell/pkg-exports for a demonstration of this, |
Explicitly supporting |
Also, the empty |
I think I'd prefer documenting Not going to block any PR or even discourage creating them. Just in terms of documentation, I think we should pick one. And if |
I've created a PR for further discussion in nodejs/node#32838. |
A common requirement is to expose an entire directory to the public, but not a sub-directory of internal helpers.
For example, with:
How can you make
./lib/helpers/
private?It's possible to move the
helpers
directory out of thelib
directory to be at the same level, but sometimes this is not desirable. For example,graphql-react
has helper files scoped underuniversal
,server
andtest
directories so that they can have seperate.babelrc.js
files for transpilation per environment:https://github.com/jaydenseric/graphql-react/tree/v10.0.0/src
Ideally the helper files could be gathered into
helpers
directories, and blacklisted in place. Moving the helpers out from under the scope of the.babelrc
files would be a hassle, it would mean duplicating the Babel config files, so 3 becomes 6 with repetition.Alternatively, the structure could be changed to
graphql-react/universal/lib/foo.mjs
andgraphql-react/universal/helpers/bar.mjs
, but inserting the extra/lib
into the paths is a breaking change to the existing paths and looks ugly for consumers to write.The text was updated successfully, but these errors were encountered: