check-size

Runs a static code analysis on dist folder to check that the current size of all bundles defined on the configuration file are correct.

Copy
devkit-scripts check-size

For those bundles which size exceeds the one on the configuration file, you will be notified if an update of the latter is allowed or not. The maximum increment permitted is a 5% of the previous size.

To update the size on the configuration file use:

Copy
devkit-scripts check-size --fix

Options

Copy
--config <file>     use this to change the config file (default: ".check-size.js")
 '-f, --fix'        use this to update the bundle size on the configuration file when permitted

API usage

Copy
const { checkSize } = require('@pos-web/devkit-scripts');

checkSize({
  config: String?,
  fix: Boolean?,
})

check-size configuration

By default, the script uses a file called .check-size.js which must be located in the project root.

.check-size.js

Copy
module.exports = [
  {
    name: 'devkit-plugin-auto-forms',
    path: 'plugins/devkit-plugin-auto-forms/dist/@pos-web/devkit-plugin-auto-forms.umd.js',
    limit: '5 KB',
  },
];

If you would like to use a different one, you can create a configuration file that follows this object pattern:

myConfigFile.js

Copy
module.exports = [
  {
    name: 'bundle',
    path: 'path-to-dist/bundle.js',
    limit: '1000 B',
  },
];

Important:

  1. You are able to use different size notations for the limit property (e.g., B for Bytes, KB for KiloBytes, MB for MegaBytes)

  2. Remember that you need to have this new file into the project root.