wix / import-cost

displays the import size of the package you are importing inside the code editor
https://marketplace.visualstudio.com/items?itemName=wix.vscode-import-cost
MIT License
1.36k stars 68 forks source link

Display cost of dependencies in package.json #77

Open web-devel opened 6 years ago

yairhaimo commented 6 years ago

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.

web-devel commented 6 years ago

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';
yairhaimo commented 6 years ago

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