import-cost
import-cost copied to clipboard
Display cost of dependencies in package.json
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.
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';
I think sites like https://bundlephobia.com/ are a great resource for that kind of information. Maybe we can integrate with it?