Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
compsizer
is a tool designed to analyse the size of component bundles in your project. It helps you ensure that your component sizes are within acceptable limits by comparing them against baselines and showing size increases across builds. You can also configure gzip and Brotli compression checks.
You can install compsizer
locally in your project.
npm install compsizer --save-dev
Once installed, you can use the command compsizer
in your project.
You can run the tool from the command line either with the default configuration file or by specifying a custom configuration file.
If you use the default configuration file name compsizer.config.json
, simply run:
npx compsizer
If your configuration file is located elsewhere or has a different name, use:
npx compsizer --config path/to/your-config-file.json
package.json
You can add a script in your package.json
for convenience:
{
"scripts": {
"analyse-component-bundles": "compsizer --config path/to/your-config-file.json"
}
}
Then run it via:
npm run analyse-component-bundles
Each component package should have its own configuration file to specify the inclusion/exclusion patterns for files, size limits, and compression options.
modal/compsizer.config.json
){
"exclude": [
"**/*.d.ts"
],
"compression": {
"gzip": true,
"brotli": true
},
"baselineFile": "component-bundle-sizes.json",
"components": {
"modal": {
"maxSize": "50 KB",
"warnOnIncrease": "10%",
"include": [
"./dist/**/*.js"
]
}
},
"defaults": {
"warnOnIncrease": "5%"
}
}
gzip
: (boolean) Set to true
to calculate gzip sizes.brotli
: (boolean) Set to true
to calculate Brotli sizes.maxSize
: (string) The maximum allowable size for the component (e.g., 50KB
, 500KB
).warnOnIncrease
: (string) Warn if the size increases by more than the specified percentage.include
: (array) Glob patterns specific to the component to include.exclude
: (array) Glob patterns specific to the component to exclude. (Overrides the base exclude
)warnOnIncrease
: (string) Default warning threshold for size increases.The configuration file (e.g., compsizer.config.json
) should be added to each component package in your monorepo instead of the monorepo root. This allows for more granular control over component-specific size limits and compression options.
The tool generates a report of the component sizes, whether they exceed limits, and how they compare to baseline sizes. It also updates the baseline file after each run.
The report provides detailed size breakdowns for each component, including:
index.js
file.index.js
and react.js
files, representing the core component and its React dependencies.index.js
along with other JavaScript files, such as polyfills or additional module exports, providing a comprehensive overview of the total size of the component and its dependencies.Example output:
Component Bundle Sizes Report
Component: modal/index.js
Total Size: 19.45 KB
Gzip Size: 5.12 KB
Brotli Size: 4.01 KB
Within max size limit of 50KB
Size increase of 4.8% since last recorded size is within threshold of 5%
Component: modal/index.js + react.js + other JS
Total Size: 48.78 KB
Gzip Size: 12.34 KB
Brotli Size: 10.24 KB
Within max size limit of 50KB
Size increase of 2.5% since last recorded size is within threshold of 10%
If any component exceeds its size threshold or size increase percentage, the tool will print a warning and exit with a non-zero status code.
This project is licensed under the MIT License.
FAQs
A tool for analysing the size of component packages in your monorepo.
We found that compsizer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.