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.
A tool for analysing the size of component packages in your monorepo.
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.
Currently this package is designed for component libraries with the following dist folder structure for each component package:
/dist
| - index.js <- main component file
| - index.d.ts <- type declaration
| - react.js <- a react compatible export
| - react.d.ts <- type declaration
| - someOtherFile.js <- any number of other JS files, likely polyfills
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.
Alternatively, you can place the exact same config inside your component package.json
file as a compsizer
property.
Note: You can choose to place a single configuration file at the root of your repository and list all of your components in the components
property together. However, please be aware that depending on how many components you add, it could take a while to generate the size reports for all of them at once.
modal/compsizer.config.json
){
"exclude": [
"**/*.d.ts"
],
"compression": { // Optional compression options
"gzip": true,
"brotli": true
},
"baselineFile": "component-bundle-sizes.json", // Optional - if not provided, no baseline comparison takes place
"components": {
"modal": {
"maxSize": "50 KB",
"warnOnIncrease": "10%", // Optional
"distFolderLocation": "./dist"
},
// You could add more components here if placing this config at the root of your project.
}
}
Or in package.json:
{
"compsizer": {
"exclude": [
"**/*.d.ts"
],
"compression": { // Optional compression options
"gzip": true,
"brotli": true
},
"baselineFile": "component-bundle-sizes.json", // Optional - if not provided, no baseline comparison takes place
"components": {
"modal": {
"maxSize": "50 KB",
"warnOnIncrease": "10%", // Optional
"distFolderLocation": "./dist"
},
// You could add more components here if placing this config at the root of your project.
}
}
}
gzip
: (boolean) OPTIONAL: Set to true
to calculate gzip sizes (defaults to true).brotli
: (boolean) OPTIONAL: Set to true
to calculate Brotli sizes (defaults to true).maxSize
: (string) The maximum allowable size for the component (e.g., 50KB
, 500KB
).warnOnIncrease
: (string) OPTIONAL: Warn if the size increases by more than the specified percentage.distFolderLocation
: (string) Path pointing to the built component files.exclude
: (array) Glob patterns specific to the component to exclude. (Overrides the base exclude
)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.
The npm package compsizer receives a total of 1 weekly downloads. As such, compsizer popularity was classified as not popular.
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.