Bundle Phobia: find the cost of adding an npm package to your bundle
bundlephobia.com
bundlephobia.com
If you want to get out of this dependency hell, bundle these small, essential functions into the runtime.
Although for this particular strawman I think `foo.constructor === Array` is probably enough.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
I wish. See the `Set` implementation [1], for instance. It's lacking very basic stuff like union and intersection, forcing the user to copy/paste code or add another dependency.
Does someone know why they do that? Looking from the outside it seems that the committee in charge of this doesn't know what they're doing.
[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
I think the “Why” is because it’s easier to get everyone to sign off on small changes than large changes that can never be removed.
The web platform has to live for a long time and be backwards compatible.
http://2ality.com/2015/01/es6-set-operations.html
> Long-term, I expect JavaScript to have built-in functionality for this, e.g. via functions that operate on iterables
IMO the problem with npm is that it makes no distinction between snippets, libraries, frameworks and scripted command line tools. An npm package can be any of these. I feel there perhaps should be separate namespaces and package managers for all four — e.g. an inlining minimal “node snippet manager”, a standardized framework installer for things like create-react-app, and so on.
If you hand me a .framework and a .app for macOS, it’s immediately clear which is which. This isn’t an unreasonable standard for distributing programs.
In JS land, you have multiple different implementations with different feature sets and behaviors. Code written for V8/chrome/node may behave differently in safari/jscore or IE/edge/chakra or firefox/spidermonkey.
C++ has a lot of different standards, compilers and implementations. There are differences in vc++ and gcc that can prevent compilation without flags or custom implementations. But I am sure that simple functions like printf or strcpy behave same across implementations.
Even in Java you have Oracle JVM and android's custom dalvik/ART. But the standard Java functions still work the same. Same with .net/mono.
A flat system would mean there’s only ever a single version installed. Or at least, I think that’s what OP means, since that’s the only definition I’ve ever heard.
Which is.. kind of surprising, I didn't realize that.
I sort of expected WebAssembly to have a performant JS API, since its origin is in asm.js, which was a peformant subset of javascript - but I see now that asm.js too had this same problem.
Which again surprises me, as I sort of expected it to be a bit like Macromedia Flash, which I recall had a Javascript API that seemed to perform well enough, although I suspect it wasn't used for high-performance scenarios, so maybe not.
It seems odd to me that the interfacing between these two technologies would be so separate that it would cause performance issues.. why would it not be something that is improved? Perhaps you'll have a flip where you write javascript and some other language, and the javascript runs as an interpreted language on the same VM with some compiled code, together...
Hmm.. an interpreted language interfacing with compiled bytecode efficiently... Python.. LISP can do it.. why not Javascript/WebAssembly?
Unless you are specifically concerned about the `npm install` performance in node, in which case the npm package size is relevant, you never include the whole NPM package in your bundle. Most universal packages include separate dist files and separate entry points for node usage, so most of the content is actually not included.
If you are truly interested in bloat, let your bundler give you a summary at the end. Webpack can give you detailed information about what files were included, how much each file costs, and why the costs were incurred.
So in practice you'll pretty much never be using the full package on account of 1) going for either require('lodash') or require('lodash/fp'), but not both, and 2) requiring specific functions through require('lodash/each') or whatnot.
The only way to get an accurate picture is to analyse the bundled package, or I suppose as part of the pipeline of whatever packaging solution you use.
You can also see size results now when browsing a package on yarnpkg.com (look for "Size in browser") or as a sheild on some repos (WIP).
Suggestions welcome.
Thanks for building!
MissingDependencyError
This package (or this version) uses `./lib-cov/http`, but does not specify them
either as a dependency or a peer dependency
For input chai-httpThat's usually where I run in to bundle-phobia mentality (whether its warranted or not is another discussion).
All in all though cool project, looks great, works fast, provides good info. thanks and congrats
just ... wow :D
https://marketplace.visualstudio.com/items?itemName=wix.vsco...
But seriously great service, I was thinking about a CLI tool like this to estimate dependency impact before using it.
[0] http://www.adriancourreges.com/blog/2017/12/15/mgs-v-graphic...
7ms is hardly anything but apply it to a list of only a 1000 elements and you have now slowed down the user experience by 7000ms (I know, this would all be buffered and hidden, etc. but this is just one tiny component and eventually all this stuff leads to real perceptible awful jankiness that could have been avoided if people allowed themselves to think a bit about performance).
While the first is for installing applications on your system (and also used for c libraries, because c has no official dependency manager), the second serves much more specialized purposes tailored for the language, such as
- os-agnostic (imagine the work in getting all them distros update just one package)
- compiles/postprocesses dependencies in deterministic ways
- etc.
I haven't been able to determine if this is an NPM issue or CircleCI issue, but short research periods seem to indicate the former, and I find the availability of packages in the manager to be 'unreliable'. That's not really something that I want to deal with in software that is managing my dependencies, but that's the state of the world. Apt repositories have a tendency to do the same thing, actually.
Very true, pointed criticism, but i'm afraid part of the answer is avoiding npm altogether.
A massive majority of that code you download is from 3rd parties.
Ads, tracking, analytics, Instagram & Facebook embeds, etc...
Now you can suggest that we should move to not having any of these but from a business perspective that’s... very hard.
Trimming is possible, of course, but the reality is that npm is not the problem- sites were bloated with JS before it came along.
The problem ends up being when you're embedding this stuff and the provider has their own dependencies they're loading. Hubspot's embedded web forms pulls in an entire React framework. Mess.
If you're serious about doing this stuff, you include the bare minimum JS possible (GA/GTM, usually), store GUIDs in your request logs and put that into your analytics data pipeline.
And keep telling the Google rep to take a hike when they put pressure on you to use AMP.
AMP may be bullshit but it means a 5-10x increase in traffic so... again, missing the business case.
It's a great way for google to build a captive market of content providers, but once everyone is serving AMP pages, the benefit to brands (SERP) is gone.
I hate AMP with a passion but your specific objection hasn’t been true for us.