import-cost icon indicating copy to clipboard operation
import-cost copied to clipboard

Display cost of dependencies in package.json

Open web-devel opened this issue 6 years ago • 3 comments

web-devel avatar Aug 02 '18 10:08 web-devel

As Import Cost takes tree-shaking into consideration we will have to display the combined size of all imports from all files of a single package. For example:

// file 1
import { one } from 'some-lib'; // 1KB
// file 2
import { two } from 'some-lib'; // 1KB
// package.json
"dependencies": {
  "some-lib": "*" // 2KB (instead of the full size of 20KB of the library)
}

Scanning all the files and running numerous webpack instances at once will hinder your machine's performance (even more than the plugin does today). Maybe if we do it as an on-demand command and not automatically.

yairhaimo avatar Aug 14 '18 07:08 yairhaimo

Yes I realize it. My initial thought that for package.json it would be great to see rough weight of the dependency. That's to say to show cost of all main imports - effectively the same cost as for

import * as smth from 'somemodule';

web-devel avatar Sep 03 '18 09:09 web-devel

I think sites like https://bundlephobia.com/ are a great resource for that kind of information. Maybe we can integrate with it?

yairhaimo avatar Sep 06 '18 08:09 yairhaimo