Skip to content

Commit

Permalink
Add bundlesize (#353)
Browse files Browse the repository at this point in the history
* test: add bundlesize

This will let us prevent regressions in bundlesize.

I chose to monitor the bundlesize of webpack and rollup build because
this is what ultimately matters to the user. If we break something in
our library that would e.g. break tree shaking in one of these bundlers
we would want to notice.

Co-authored-by: Robert Kieffer <robert@broofa.com>
  • Loading branch information
ctavan and broofa committed Jan 23, 2020
1 parent 380fe28 commit 4acaea4
Show file tree
Hide file tree
Showing 16 changed files with 737 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Expand Up @@ -23,3 +23,4 @@ jobs:
- run: npm run ci
env:
CI: true
BUNDLESIZE_GITHUB_TOKEN: ${{ secrets.BUNDLESIZE_GITHUB_TOKEN }}
13 changes: 13 additions & 0 deletions bundlesize.config.json
@@ -0,0 +1,13 @@
{
"files": [
{ "path": "./examples/browser-rollup/dist/v1-size.js", "maxSize": "0.8 kB" },
{ "path": "./examples/browser-rollup/dist/v3-size.js", "maxSize": "1.8 kB" },
{ "path": "./examples/browser-rollup/dist/v4-size.js", "maxSize": "0.5 kB" },
{ "path": "./examples/browser-rollup/dist/v5-size.js", "maxSize": "1.2 kB" },

{ "path": "./examples/browser-webpack/dist/v1-size.js", "maxSize": "1.3 kB" },
{ "path": "./examples/browser-webpack/dist/v3-size.js", "maxSize": "2.2 kB" },
{ "path": "./examples/browser-webpack/dist/v4-size.js", "maxSize": "0.9 kB" },
{ "path": "./examples/browser-webpack/dist/v5-size.js", "maxSize": "1.6 kB" }
]
}
3 changes: 3 additions & 0 deletions examples/browser-rollup/bundlesize-v1.js
@@ -0,0 +1,3 @@
import { v1 as uuidv1 } from 'uuid';

uuidv1();
3 changes: 3 additions & 0 deletions examples/browser-rollup/bundlesize-v3.js
@@ -0,0 +1,3 @@
import { v3 as uuidv3 } from 'uuid';

uuidv3();
3 changes: 3 additions & 0 deletions examples/browser-rollup/bundlesize-v4.js
@@ -0,0 +1,3 @@
import { v4 as uuidv4 } from 'uuid';

uuidv4();
3 changes: 3 additions & 0 deletions examples/browser-rollup/bundlesize-v5.js
@@ -0,0 +1,3 @@
import { v5 as uuidv5 } from 'uuid';

uuidv5();
173 changes: 173 additions & 0 deletions examples/browser-rollup/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/browser-rollup/package.json
Expand Up @@ -11,6 +11,7 @@
},
"devDependencies": {
"rollup": "^1.24.0",
"rollup-plugin-node-resolve": "^5.2.0"
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^5.2.0"
}
}
36 changes: 35 additions & 1 deletion examples/browser-rollup/rollup.config.js
@@ -1,6 +1,7 @@
const resolve = require('rollup-plugin-node-resolve');
const { terser } = require('rollup-plugin-terser');

const plugins = [resolve()];
const plugins = [resolve(), terser()];
module.exports = [
{
input: './example-all.js',
Expand All @@ -26,4 +27,37 @@ module.exports = [
},
plugins,
},

{
input: './bundlesize-v1.js',
output: {
file: 'dist/v1-size.js',
format: 'cjs',
},
plugins,
},
{
input: './bundlesize-v3.js',
output: {
file: 'dist/v3-size.js',
format: 'cjs',
},
plugins,
},
{
input: './bundlesize-v4.js',
output: {
file: 'dist/v4-size.js',
format: 'cjs',
},
plugins,
},
{
input: './bundlesize-v5.js',
output: {
file: 'dist/v5-size.js',
format: 'cjs',
},
plugins,
},
];
3 changes: 3 additions & 0 deletions examples/browser-webpack/bundlesize-v1.js
@@ -0,0 +1,3 @@
import { v1 as uuidv1 } from 'uuid';

uuidv1();
3 changes: 3 additions & 0 deletions examples/browser-webpack/bundlesize-v3.js
@@ -0,0 +1,3 @@
import { v3 as uuidv3 } from 'uuid';

uuidv3();
3 changes: 3 additions & 0 deletions examples/browser-webpack/bundlesize-v4.js
@@ -0,0 +1,3 @@
import { v4 as uuidv4 } from 'uuid';

uuidv4();
3 changes: 3 additions & 0 deletions examples/browser-webpack/bundlesize-v5.js
@@ -0,0 +1,3 @@
import { v5 as uuidv5 } from 'uuid';

uuidv5();
5 changes: 5 additions & 0 deletions examples/browser-webpack/webpack.config.js
Expand Up @@ -6,6 +6,11 @@ module.exports = {
all: './example-all.js',
v1: './example-v1.js',
v4: './example-v4.js',

'v1-size': './bundlesize-v1.js',
'v3-size': './bundlesize-v3.js',
'v4-size': './bundlesize-v4.js',
'v5-size': './bundlesize-v5.js',
},
output: {
filename: '[name].js',
Expand Down

0 comments on commit 4acaea4

Please sign in to comment.