Create quest.js #7
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Size Limit
Size Limit is a tool to prevent JavaScript libraries bloat.
With it, you know exactly for how many kilobytes your JS library
increases the user bundle.
You can add Size Limit to your continuous integration service
(such as Travis CI) and set the limit. If you accidentally
add a massive dependency, Size Limit will throw an error.
Size Limit could tell you not only library size. With
--whyargument it cantell you why your library has this size and show real cost of all your
internal dependencies.
Who Uses Size Limit
25% of the size.
25% of the size.
33% of the size.
90% of the size.
How It Works
You can find more examples in Size Limit: Make the Web lighter article.
To be really specific, Size Limit creates an empty webpack project in memory.
Then, it adds your library as a dependency to the project and calculates
the real cost of your libraries, including all dependencies, webpack’s polyfills
for process, etc.
Usage
First, install
size-limit:Add
size-limitsection topackage.jsonandsizescript:The
pathoption:to npm (usually the same value as the
mainfield in thepackage.json);webpack: false(see theApplications section).
Here’s how you can get the size for your current project:
If your project size starts to look bloated,
run Webpack Bundle Analyzer
for analysis:
Now, let’s set the limit. Determine the current size of your library,
add just a little bit (a kilobyte, maybe) and use that as a limit in
your
package.json:"size-limit": [ { + "limit": "9 KB", "path": "index.js" } ],Add the
sizescript to your test suite:"scripts": { "size": "size-limit", - "test": "jest && eslint ." + "test": "jest && eslint . && npm run size" }If you don’t have a continuous integration service running, don’t forget
to add one — start with Travis CI.
Config
Size Limits supports 3 ways to define config.
size-limitsection topackage.json:or separated
.size-limitconfig file:or more flexible
.size-limit.jsconfig file:Each section in config could have options:
It could be a path
"index.js", a pattern"dist/app-*.js"or an array
["index.js", "dist/app-*.js"].pathoption. It should be a stringwith a number and unit (
100 B,10 KB, etc).if you have multiple sections.
falsewill disable webpack.falsewill disable gzip compression.Applications
Webpack inside Size Limit is very useful for small open source library.
But if you want to use Size Limit for application, not open source library, you
could already have webpack to make bundle.
In this case you can disable internal webpack:
"size-limit": [ { "limit": "300 KB", + "webpack": false, "path": "public/app-*.js" } ],JavaScript API
Comparison with
bundlesizeMain difference between Size Limit and
bundlesize, that Size Limit useswebpack to build bundle. It has more accurate result and can show you
what and why causes the bloat.
--whymode to run Webpack Bundle Analyzer — this way,you can see what went wrong in a nice graphical representation.
of libraries bloat — unexpected huge dependency.
processor
pathusage, when webpack will add big unnecessary polyfill.to CI resources.