size-limit: Error: “Size Limit can't resolve fs”
When attempting to run size-limit, I get this error:
ERROR Size Limit can't resolve
fs
in /Users/jaydenseric/Sites/apollo-upload-server/node_modules/busboy/lib
When using "webpack": false
the error does not appear.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (11 by maintainers)
Commits related to this issue
- fix: ignore fs in Webpack This is a workaround to allow size-limit to work on this package. https://github.com/ai/size-limit/issues/65 — committed to sarahdayan/penjing by sarahdayan 4 years ago
- :wrench: add 'browser' key https://github.com/ai/size-limit/issues/65#issuecomment-389780335 — committed to Tincre/promo-button by thinkjrs 2 years ago
We can do:
But we must to do it in separated project. Maybe
package-limit
?@styfle I very like the project. It will be more accurate than Size Limit since it will calculate also non-jS files. Do you have CI tool to run it in Travis CI?
I have two news:
Here is a temporary workaround:
browser: { fs: false }
to yourpackage.json
. It will say for webpack to ignore this module.gzip: false
to Size Limit config since you are care about size on the disk.Will like work for you until I will finding better solution?
I decided that at least for now,
fs
will not be part as default. It is much safer to explicitly define it inignore
or inbrowsers
.If we will have this issue again in the future, I can change my mind.
@styfle very nice service indeed! In fact I love it, awesome to see somebody made this. Sadly as you already mentioned it checks the size after it is published while I would like to check the size in PRs.
Also proposal here: https://github.com/styfle/packagephobia/issues/88
Regarding the CLI tools:
Another use-case is for CLI packages, I’m currently searching for a way to keep the size in check. I found the module cost-of-modules which does the job put returns the size of all modules instead of only the total size. I’ve opened an issue about it: https://github.com/siddharthkp/cost-of-modules/issues/51
Interesting use case. So you want to use Size Limit to control how much file size your project will have in user’s
node_modules
?Yes.
Because I am a responsible package author, and want to ensure my packages are lean and efficient. This is particularly important for consumers that use Webpack or Babel to process their server-side code; they don’t want huge bundles or compile times.