Comments (11)
There is two way to do it:
- Run Size Limit on your
dist/
dir with compiled JS files. It is recommended way. - Use custom webpack config. Not recommended because result could be a little different from real npm package.
from size-limit.
Yeap. For app you should add files to path
manually depends on your needs 👍😊
from size-limit.
@ai, thanks for the quick response. Does that mean size-limit
simply sums up all files' sizes and displays the total size?
from size-limit.
Nope. Size Limit emulates “simple user”. It creates empty and simple webpack project in the memory, install your library and calculates project size difference.
Because it emulates simple user, it doesn't have TS support. Since your library users will not add special TS loaders for your library.
from size-limit.
But for Run Size Limit on your dist/ dir with compiled JS files. It is recommended way.
it would just sum up all files' sizes, I guess?
from size-limit.
Nope. It will load dist/index.js
in that empty project in the memory.
from size-limit.
Sum all files is not the best way to control size. In my experience the most popular problems with the size happen because of dependencies and webpack's polyfills for Node modules (like when you are using process
).
This is why we always try to calculate real cost of your library.
(If you really need just files sum you can do it by webpack: false, path: "dist/*"
, but I don't recommend it)
from size-limit.
I'm not sure I understand this. In my final dist
directory I have these files:
- main.js
- main.js.gz
- main.js.br
- vendor.js
- vendor.js.gz
- vendor.js.br
- main.css
- main.css.gz
- main.css.br
- chunks/0.js
- chunks/0.js.gz
- chunks/0.js.br
- icons/{multiple}.png
- sprites/{multiple}.svg
- sprites/{multiple}.svg.gz
- sprites/{multiple}.svg.br
- fonts/{multiple}.woff
- fonts/{multiple}.woff2
How do I have to configure size-limit
to have it analyze the size correctly?
I'm working on an application, not a library. Does that even work then?
from size-limit.
If you are using Size Limit for app, you should have config like:
webpack: false,
path: "dist/main.js"
limit: "100 KB"
from size-limit.
@ai, thanks for the answer. Running size-limit
prints this:
Package size: 5.11 KB
With all dependencies, minified and gzipped
This seems to be the gzipped file-size of main.js
itself.
That probably means it does not include vendor.js
and any other assets.
So, I guess, to get the desired size, I will have to configure path
to include all files.
from size-limit.
Thanks for the help!
from size-limit.
Related Issues (20)
- doesn't invoke a custom webpack config function HOT 2
- An NX plugin support HOT 5
- save and compare previous size result HOT 1
- Possibility to use size-limit with nextjs apps HOT 1
- Should I ignore some file types?
- size-limit fails with rxjs imports
- Add customisation for improving performance culture HOT 6
- Loosen strictness of peer dependency requirement of `tslib` HOT 1
- Global installation with plugin support HOT 5
- React should be peer dependency HOT 7
- The comment might be misleading when size limit fails HOT 5
- Unable to run on windows 10 HOT 4
- Receive ERR_UNSUPPORTED_ESM_URL_SCHEME error on version 10 HOT 5
- Switch from GZIP to Brotli by default HOT 4
- plugins are `import`ed with `require.resolve` which will resolve `commonjs` entry for dual package HOT 4
- Allow customize error message HOT 1
- Inaccurate bundle size when using dynamic imports HOT 10
- Support `.size-limit.mjs` config file HOT 2
- Migrate codebase to TypeScript HOT 4
- Esbuild plugin produces incorrect numbers when CSS used HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from size-limit.