Improve package publishing
See original GitHub issueSuggestions:
- The
exports
field shouldn’t stripped from the publishedpackage.json
and noindex.mjs
file is included. @n1ru4l I found that you raised this issue earlier, (though not sure why it was closed) https://github.com/kamilkisiela/bob/issues/16 - Don’t bundle. Publish as commonjs unbundled with both commonjs and ESM entrypoints. This can also allow consumers to deep import files rather than via their named exports. This should be encouraged in the documentation. The entrypoints can remain mostly for static analysis.
- As an alternative, perhaps consider perhaps only publishing ESM. https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10 (10 by maintainers)
Top Results From Across the Web
3 ways you can improve your npm publish | Mainmatter
This blog post will show you three of our most important tricks to improve how you publish your packages to npm.
Read more >Publishing packages | Dart
Advantages of using a verified publisher. You can publish packages using either a verified publisher (recommended) or an independent Google Account. Using a ......
Read more >Publishing packages - Rush.js
You need two steps to publish your packages when version policies are used. The first step is to increase the package versions. And...
Read more >Learn How to Develop and Publish an NPM Package - Auth0
Learn, through a practical tutorial, what tools we can leverage to develop and publish high-quality NPM packages.
Read more >How to Publish an Updated Version of an npm Package
I wanted get a better handle on what's typically involved in the npm release process. In this article, I'll cover the most common...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you want to reduce memory usage you can still bundle your server code and drop unused code via tree shaking. I don’t see why deep imports (which limit me as a library maintainer), should take care of this instead.
I think importing from CDN and causing request waterfalls is also something that should be avoided for production usage (by using a bundler), for development/demos the additional loaded code won’t be a dealbreaker.
The dual package hazard is only introduced if people decide to only ship ESM or commonjs which basically means “I don’t care about library consumers” to me.
If a package has zero dependencies (or all dependencies of that package are ESM only) I agree that only shipping ESM is totally legit. But as soon your library has dependencies you should ship both commonjs and ESM in order to avoid the dual package hazard.
I realised that I was on earlier versions of a couple of packages, which didn’t include the exports field (https://unpkg.com/browse/@n1ru4l/graphql-live-query-patch-jsondiffpatch@0.4.0/package.json). I wasn’t aware that it had already been addressed. Great!
On deep imports, the advantage is that users won’t be importing anything they don’t need, saves memory on the server and negates the need to tree shake if bundling on the client. It also better supports browser URL imports over CDN since users won’t be downloading the entire API (Edit: note that this requires publishing files as ESM, though some CDN’s can convert to ESM such as https://esm.sh/).
Supporting both is kinda hard, currently these packages all suffer from the dual package hazard, see here for an explanation.