-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add package.json exports
field
#773
Conversation
No problem. Let me know if there is something else I can do to help. I notice skypack is mentioned in #772; FYI importing <script type="module">
import mustache from 'https://cdn.skypack.dev/mustache'; // skypack resolves mustache.js -> transpiles to ESM -> sends back
</script> skypack cdn source: https://cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports/optimized/mustache.js EDIT: Also, I totally sympathize with trying to target multiple environments. This project does so much more than most to make usage seamless. Thanks so much, it's a great library. |
Myeah, I also noticed the skypack story isn't ideal ATM. Guess it works, but let's try and do better 😄 Now that #772 has been merged, I'll try to wrap my head around the changes in this PR. I'm also pretty sure I've seen mentioned that adding an
Really appreciate hearing that, thanks a bunch! |
I had not seen this before, but I'm glad that you had! Feeling a bit ignorant for suggesting such a major change when this is clearly stated in the Node.js docs: https://nodejs.org/api/packages.html#packages_package_entry_points
This change is apparently to allow library authors to encapsulate their packages, allowing fine-grain control over public interfaces for packages. With that said, I noticed the previous ESM imports in node were
TL;DR I think the |
Thanks @manzt, great research 👍🏻
Sounds good to me, as that also ensures we keep backwards compatibility with what we've been telling ESM users to do for well over a year.
I don't consider encapsulation via the Looking at what our resulting package tarball consists of:
..I don't see any of those files as "private" implementation details we'd want to avoid exposing to the outside. That's basically what we've been using the Lines 21 to 26 in 3e29d67
Bottom line: I think this is good to go. |
Thanks a lot for making this happen, I'm sure it'll make many devs out there happy 💯 I published
|
This has now been elevated from |
Adds the new
"exports"
field inpackage.json
to define conditional exports formustache.js
(ESM & CJS). This field is used both by Node and bundlers to resolve dependencies. Since there is no"module"
entrypoint for this package, some bundlers (rollup
+@rollup/plugin-node-resolve
) cannot resolve the module export. This is a step towards making both modules discoverable.Example