RFC: Use package.json exports to "hide" the dist folder for packages and control our exported surface-area #6015
Replies: 4 comments 2 replies
-
+1, once in a while TypeScript auto-imports something from I'm in favor of as much restriction as possible. Keeping the API as minimal as possible means we get the most control over what consumers are able to use. We don't want them to feel comfortable importing miscellaneous |
Beta Was this translation helpful? Give feedback.
-
I'm more than happy to go for option 3 - it was my preferred option! |
Beta Was this translation helpful? Give feedback.
-
cc @JamesHenry @Josh-Cena - I think this RFC is ready to be ratified, unless you'd like to continue the discussion here? |
Beta Was this translation helpful? Give feedback.
-
Cool, looks like we're in agreement on choice 3 here. Thanks all! Converting this back into an issue, and marking as accepting PRs. Edit: #6050 |
Beta Was this translation helpful? Give feedback.
-
Currently we don't use package.json exports, so anyone can import any file in any package by directly referencing a path within the
dist
folder - i.e.This is obviously a sub-par experience for consumers due to the deep path, and is a sub-par experience for us because any file technically forms part of our "external API".
In ESLint v8 they began using exports to lock down their package, and I think we should follow their lead to some degree.
I propose that we follow one of the following options:
1) export all of dist, without the dist
This is the least restrictive thing we could do - it would simply mean consumers needn't include
dist/
in their import path - which is nice as it hides an implementation detail.2) export all, but ban specific things
This is slightly more restrictive, but still very permissive.
This would allow us to build APIs that are intended to be internal only and hide them, whilst still generally allowing all imports without the
dist/
.3) export specific, allowed parts of our API
This is the most restrictive thing we could do as we would ban deep imports except those that we choose. It would also allow us to remove the
dist/
from imports.Beta Was this translation helpful? Give feedback.
All reactions