Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
size-limit
Advanced tools
Size Limit is a performance monitoring tool for JavaScript projects. It helps you keep your project within a specific size limit by analyzing the size of your JavaScript bundles and providing warnings when the size exceeds the specified limit.
Bundle Size Analysis
This feature allows you to specify the path to your JavaScript bundle and set a size limit. Size Limit will analyze the bundle and ensure it does not exceed the specified limit.
module.exports = [
{
path: 'dist/bundle.js',
limit: '500 KB'
}
];
Custom Configurations
You can customize the analysis by enabling gzip compression or disabling the running of the bundle. This provides more flexibility in how you measure the size of your bundles.
module.exports = [
{
path: 'dist/bundle.js',
limit: '500 KB',
gzip: true,
running: false
}
];
Multiple Bundles
Size Limit supports analyzing multiple bundles in a single configuration. This is useful for projects with multiple entry points or output files.
module.exports = [
{
path: 'dist/bundle1.js',
limit: '300 KB'
},
{
path: 'dist/bundle2.js',
limit: '200 KB'
}
];
Webpack Bundle Analyzer is a tool that visualizes the size of webpack output files with an interactive zoomable treemap. It provides a detailed breakdown of the bundle contents, making it easier to identify large modules and optimize the bundle size. Unlike Size Limit, it focuses more on visualization and detailed analysis rather than enforcing size limits.
Bundlesize is a tool that lets you set size limits for your JavaScript bundles and reports the size of the bundles in your CI/CD pipeline. It is similar to Size Limit in that it enforces size limits, but it integrates more tightly with CI/CD workflows and provides a simpler configuration.
Source Map Explorer analyzes JavaScript bundles using source maps to determine which files contribute to the bundle size. It provides a detailed breakdown of the bundle contents, similar to Webpack Bundle Analyzer, but it relies on source maps for its analysis. This makes it useful for understanding the impact of individual source files on the final bundle size.
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.
First, install size-limit
:
$ npm install --save-dev size-limit
Here's how you can get the size for your current project:
$ ./node_modules/bin/size-limit
Package size: 8.46 KB
With all dependencies, minified and gzipped
If your project size starts to look bloated, run Webpack Bundle Analyzer for analysis:
./node_modules/bin/size-limit --why
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
when adding the script to package.json
:
"scripts": {
"test": "jest && eslint .",
+ "size": "size-limit 9KB"
}
Add the size
script to your test suite:
"scripts": {
- "test": "jest && eslint .",
+ "test": "jest && eslint . && npm run size",
"size": "size-limit 9KB"
}
If you don't have a continuous integration service running, don’t forget to add one — start with Travis CI.
const getSize = require('size-limit')
const index = path.join(__dirname, 'index.js')
const extra = path.join(__dirname, 'extra.js')
getSize([index, extra]).then(size => {
if (size > 1 * 1024 * 1024) {
console.error('Project is now larger than 1MB!')
}
})
bundlesize
Size Limit is a full-featured library that helps you to get into the detail of what and why causes the bloat; it also works offline.
In short,
--why
mode to run Webpack Bundle Analyzer — this way,
you can see what went wrong in a nice graphical representation.FAQs
CLI tool for Size Limit
The npm package size-limit receives a total of 165,098 weekly downloads. As such, size-limit popularity was classified as popular.
We found that size-limit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.