Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JST-300: added bundle size validator #611

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"jest": "^29.6.2",
"prettier": "^3.0.0",
"rollup": "^3.26.3",
"rollup-plugin-filesize": "^10.0.0",
"rollup-plugin-ignore": "^1.0.10",
"rollup-plugin-polyfill-node": "^0.12.0",
"rollup-plugin-visualizer": "^5.9.0",
Expand Down
10 changes: 9 additions & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import typescript from "@rollup/plugin-typescript";
import nodePolyfills from "rollup-plugin-polyfill-node";
import pkg from "./package.json" assert { type: "json" };
import ignore from "rollup-plugin-ignore";
import filesize from "rollup-plugin-filesize";

/**
* Looking for plugins?
Expand Down Expand Up @@ -43,6 +44,7 @@ export default [
json(), // Required because one our dependencies (bottleneck) loads its own 'version.json'
typescript({ tsconfig: "./tsconfig.json" }),
terser({ keep_classnames: true }),
filesize({ reporter: [sizeValidator, "boxen"] }),
],
},
// NodeJS
Expand All @@ -52,6 +54,12 @@ export default [
{ file: pkg.main, format: "cjs", sourcemap: true },
{ file: pkg.module, format: "es", sourcemap: true },
],
plugins: [typescript({ tsconfig: "./tsconfig.json" })],
plugins: [typescript({ tsconfig: "./tsconfig.json" }), filesize({ reporter: [sizeValidator, "boxen"] })],
},
];

function sizeValidator(options, bundle, { bundleSize }) {
if (parseInt(bundleSize) === 0) {
throw new Error(`Something went wrong while building. Bundle size = ${bundleSize}`);
}
}
Loading