Don't bundle and minify your published npm packages

Don't bundle and minify your published npm packages

Released Wednesday, 19th May 2021
Good episode? Give it some love!
Don't bundle and minify your published npm packages

Don't bundle and minify your published npm packages

Don't bundle and minify your published npm packages

Don't bundle and minify your published npm packages

Wednesday, 19th May 2021
Good episode? Give it some love!
Rate Episode

https://twitter.com/kentcdodds/status/1394420201542668289?s=20So the other day I tweeted about how I really want people to stop minifyingand bundling what they send to NPM. And just to clarify I it's fine if youwant to minify and bundle as one of the things you distribute as part ofyour package, but it shouldn't be the only thing and there are a couple ofreasons and what I do for my packages is I actually do have a UMD modulethat is bundled and I have a minified version of that as well.So we have two of those and then I've got an ESM.R version which is likefake ESM right now eventually I'll get around to making a native VSMsupported version. And then a common JS and those are the the four formatsthat I shipped to NPM. So the reason that I really really don't want peopleto exclusively ship minified code is even with source maps can it can bereally difficult to debug and especially when we're talking about librariesthat I'm interacting with well even even transitive dependencies.I like to be able to.Stick a console log in there or to step through with adebugger and it's just really difficult to do that if you've minified yourcode and in particular what motivated me to tweet this in the first placewas I was working with a library that minified everything and it ended upminifying its implementation of an abort signal and so the constructor namewas incorrect and node fetch actually checks the constructor name to knowif what you've passed is an abort signal which we could argue about whetherthat's necessary or not, but the fact is that it does and becauseThey wereminifying it totally is unusable which is a less super annoying.So that's notification then on the bundling side of things this can get tobe a real problem like if for example your bundling a particular libraryand I'm already using that library in my project MPM can't dedupe that anddo means it says, oh you're using this library in this other dependencyuses that library too.So we'll just have them both use the same files and therefore we don't haveto send.That code to the browser twice so we don't have to require thatcode and evaluate it in person all that stuff. And so there are argumentsthat people make about bundling as like performance improvement so like youcould do that with some tools and and that could be useful but it couldalso be a big problem because then I can't like change the versions of thethings that I'm using and I don't have any control over that.So there are a lot of issues there in general. So, please don't bundledon't minify it's better this way. Let meDo that.

Show More
Rate

Join Podchaser to...

  • Rate podcasts and episodes
  • Follow podcasts and creators
  • Create podcast and episode lists
  • & much more

Episode Tags

Do you host or manage this podcast?
Claim and edit this page to your liking.
,

Unlock more with Podchaser Pro

  • Audience Insights
  • Contact Information
  • Demographics
  • Charts
  • Sponsor History
  • and More!
Pro Features