Skip to content

Commit 16bd83b

Browse files
committed
internal: Add bundle size tracker on PRs
1 parent 3334071 commit 16bd83b

File tree

13 files changed

+391
-0
lines changed

13 files changed

+391
-0
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
- run:
3131
name: Add examples/* to yarn workspace
3232
command: |
33+
npm pkg delete workspaces[5]
3334
npm pkg delete workspaces[4]
3435
npm pkg delete workspaces[3]
3536
npm pkg delete workspaces[2]

.github/workflows/bundle_size.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Bundle Size
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 1
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: '22'
17+
cache: 'yarn'
18+
- name: Install packages
19+
env:
20+
YARN_ENABLE_IMMUTABLE_INSTALLS: true
21+
run: |
22+
# npm pkg delete workspaces[5]
23+
# npm pkg delete workspaces[4]
24+
# npm pkg delete workspaces[3]
25+
# npm pkg delete workspaces[1]
26+
corepack enable
27+
yarn install
28+
- name: Build packages
29+
run: |
30+
yarn workspaces foreach -Wptiv --no-private run build:lib
31+
- name: compressed-size-action
32+
uses: preactjs/compressed-size-action@v2
33+
continue-on-error: true
34+
with:
35+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
36+
build-script: "build:sizecompare"
37+
pattern: "examples/test-bundlesize/dist/**/*.{js,json}"
38+
exclude: "{examples/test-bundlesize/dist/manifest.json,**/*.LICENSE.txt,**/*.map,**/node_modules/**}"
39+
minimum-change-threshold: 8
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [['@anansi', { polyfillMethod: false }], '@linaria'],
3+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist-server
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# coinbase-lite
2+
3+
## 0.0.9
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [[`d225595`](https://github.com/reactive/data-client/commit/d2255959489b71cfdfcaf4be72fd272231d392f1), [`f4cf8a4`](https://github.com/reactive/data-client/commit/f4cf8a4df3dfe852d98058abd06178f751ae8716), [`2ad1811`](https://github.com/reactive/data-client/commit/2ad1811149cdc419f6462ace08efdb7766195b36), [`d225595`](https://github.com/reactive/data-client/commit/d2255959489b71cfdfcaf4be72fd272231d392f1), [`2ad1811`](https://github.com/reactive/data-client/commit/2ad1811149cdc419f6462ace08efdb7766195b36), [`2ad1811`](https://github.com/reactive/data-client/commit/2ad1811149cdc419f6462ace08efdb7766195b36), [`6325384`](https://github.com/reactive/data-client/commit/632538421bf21440a12bb32cb3c8cccd3a5c4cbb), [`2ad1811`](https://github.com/reactive/data-client/commit/2ad1811149cdc419f6462ace08efdb7766195b36), [`8aabe18`](https://github.com/reactive/data-client/commit/8aabe189330bdef2f36dd2c76c9e0ff80659468b), [`f4cf8a4`](https://github.com/reactive/data-client/commit/f4cf8a4df3dfe852d98058abd06178f751ae8716), [`9df0f7c`](https://github.com/reactive/data-client/commit/9df0f7c670c919d956312d2535c298d2553f5840)]:
8+
- @data-client/react@0.14.0
9+
- @data-client/rest@0.14.0
10+
- @data-client/img@0.14.0
11+
12+
## 0.0.8
13+
14+
### Patch Changes
15+
16+
- Updated dependencies [[`720ff0c`](https://github.com/reactive/data-client/commit/720ff0c3d833ff4d1eb5020694131e87282b585d), [`720ff0c`](https://github.com/reactive/data-client/commit/720ff0c3d833ff4d1eb5020694131e87282b585d), [`c38714d`](https://github.com/reactive/data-client/commit/c38714ddb42819f2d05e0dda9a19579025600928)]:
17+
- @data-client/react@0.13.4
18+
- @data-client/rest@0.13.4
19+
- @data-client/img@0.13.4
20+
21+
## 0.0.7
22+
23+
### Patch Changes
24+
25+
- Updated dependencies [[`cf770de`](https://github.com/reactive/data-client/commit/cf770de244ad890b286c59ac305ceb6c3b1288ea), [`cf770de`](https://github.com/reactive/data-client/commit/cf770de244ad890b286c59ac305ceb6c3b1288ea)]:
26+
- @data-client/img@0.13.0
27+
- @data-client/react@0.13.0
28+
29+
## 0.0.6
30+
31+
### Patch Changes
32+
33+
- Updated dependencies [[`428ddd1`](https://github.com/reactive/data-client/commit/428ddd1a185cd5fcc4bb53b2bc64605cca48ba82), [`d1b9e96`](https://github.com/reactive/data-client/commit/d1b9e96dffe69527f9ce0ebff4727f0b1226c9d5), [`428ddd1`](https://github.com/reactive/data-client/commit/428ddd1a185cd5fcc4bb53b2bc64605cca48ba82), [`428ddd1`](https://github.com/reactive/data-client/commit/428ddd1a185cd5fcc4bb53b2bc64605cca48ba82)]:
34+
- @data-client/react@0.12.13
35+
- @data-client/redux@0.13.0
36+
37+
## 0.0.5
38+
39+
### Patch Changes
40+
41+
- Updated dependencies [[`00d4205`](https://github.com/reactive/data-client/commit/00d4205f03562cfe4acd18215718e23ae5466b8d), [`8a8634c`](https://github.com/reactive/data-client/commit/8a8634c7a263cf99e9ce426b2c9b92fd2a12a259)]:
42+
- @data-client/react@0.12.3
43+
- @data-client/redux@0.12.3
44+
- @data-client/rest@0.12.3
45+
- @data-client/img@0.12.3
46+
47+
## 0.0.4
48+
49+
### Patch Changes
50+
51+
- Updated dependencies [[`5b64cbf`](https://github.com/reactive/data-client/commit/5b64cbf3126c404b70853960a4bdedc268e3328c), [`5b64cbf`](https://github.com/reactive/data-client/commit/5b64cbf3126c404b70853960a4bdedc268e3328c), [`6e9d36b`](https://github.com/reactive/data-client/commit/6e9d36b6cb287763c0fcc3f07d9f2ef0df619d12)]:
52+
- @data-client/react@0.12.1
53+
- @data-client/img@0.12.1
54+
- @data-client/redux@0.12.1
55+
56+
## 0.0.3
57+
58+
### Patch Changes
59+
60+
- Updated dependencies [[`2e169b7`](https://github.com/reactive/data-client/commit/2e169b705e4f8e2eea8005291a0e76e9d11764a4), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`7580500`](https://github.com/reactive/data-client/commit/7580500cecb2c4baa093f4db7b951af4840a0967), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`ca79a62`](https://github.com/reactive/data-client/commit/ca79a6266cc6834ee8d8e228b4715513d13185e0), [`59a407a`](https://github.com/reactive/data-client/commit/59a407a5bcaa8e5c6a948a85f5c52f106b24c5af), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`f6f195d`](https://github.com/reactive/data-client/commit/f6f195d573c7c51dc63361a48b2ef804181a348b), [`ba636a7`](https://github.com/reactive/data-client/commit/ba636a74e77bf5cb8c2b327e161db09f4c4a7192), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`bb24601`](https://github.com/reactive/data-client/commit/bb24601e5ca5b0d92b8db75f115fcfb99fb97563), [`8377e0a`](https://github.com/reactive/data-client/commit/8377e0a157419f0f4c237c392a895fec1772854d), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`6e55026`](https://github.com/reactive/data-client/commit/6e550260672507592d75c4781dc2563a50e664fa), [`c129a25`](https://github.com/reactive/data-client/commit/c129a2558ecb21b5d9985c13747c555b88c51b3a), [`8d42ef6`](https://github.com/reactive/data-client/commit/8d42ef6fae10859bcac1812cdbe637c739afaa6d), [`446f0b9`](https://github.com/reactive/data-client/commit/446f0b905f57c290e120c6f11a6b4708554283d1), [`b738e18`](https://github.com/reactive/data-client/commit/b738e18f7dc2976907198192ed4ec62775e52161)]:
61+
- @data-client/react@0.11.0
62+
- @data-client/rest@0.11.0
63+
- @data-client/redux@0.11.0
64+
- @data-client/img@0.11.0
65+
66+
## 0.0.2
67+
68+
### Patch Changes
69+
70+
- Updated dependencies [[`44f9ec2`](https://github.com/reactive/data-client/commit/44f9ec2801fe389a5afb215553a3441143078803), [`922be79`](https://github.com/reactive/data-client/commit/922be79169a3eeea8e336eee519c165431ead474), [`44f9ec2`](https://github.com/reactive/data-client/commit/44f9ec2801fe389a5afb215553a3441143078803), [`053e823`](https://github.com/reactive/data-client/commit/053e82377bd29f200cd7dfbc700da7a3ad7fa8d7), [`922be79`](https://github.com/reactive/data-client/commit/922be79169a3eeea8e336eee519c165431ead474), [`69834b5`](https://github.com/reactive/data-client/commit/69834b50c6d2b33f46d7c63cabdc0744abf160ae)]:
71+
- @data-client/rest@0.10.0
72+
- @data-client/redux@0.10.0
73+
- @data-client/img@0.10.0
74+
- @data-client/react@0.10.0

examples/test-bundlesize/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2023 Nathaniel Tucker <me@ntucker.me>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

examples/test-bundlesize/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
### Coin App
2+
3+
4+
This project was generated by [Anansi](https://github.com/ntucker/anansi#readme).
5+
6+
### Usage
7+
8+
With [Visual Studio Code](https://code.visualstudio.com), simply press `F5` to start the development server and browser.
9+
10+
#### Run dev:
11+
12+
```bash
13+
yarn start
14+
```
15+
16+
#### Build prod:
17+
18+
`Ctrl+shift+B` in [Visual Studio Code](https://code.visualstudio.com)
19+
20+
```bash
21+
yarn build
22+
yarn build:server
23+
```
24+
25+
#### Run prod: (after build)
26+
27+
```bash
28+
yarn start:server
29+
```
30+
31+
#### Analyze production bundle sizes:
32+
33+
```bash
34+
yarn build:analyze
35+
```
36+
37+
#### Run with [React Profiler](https://reactjs.org/blog/2018/09/10/introducing-the-react-profiler.html):
38+
39+
```bash
40+
yarn build:profile
41+
```
42+
43+
#### Check Packages for duplicates or circular dependencies:
44+
45+
```bash
46+
yarn pkgcheck
47+
```
48+
49+
#### Share demo on Stackblitz
50+
51+
https://stackblitz.com/github/reactive/data-client/tree/master/examples/coin-app
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "test-bundlesize",
3+
"version": "0.1.0",
4+
"packageManager": "yarn@4.6.0",
5+
"description": "Testing Bundled Size",
6+
"scripts": {
7+
"lint": "eslint src --ext .ts,.tsx",
8+
"format": "npm run lint --fix",
9+
"test:type": "tsc",
10+
"start": "anansi serve --dev ./src/index.tsx",
11+
"start:server": "anansi serve ./dist-server/App.js -a",
12+
"build": "webpack --mode=production",
13+
"build:server": "webpack --mode=production --target=node --env entrypath=index.server.tsx",
14+
"build:analyze": "BABEL_DISABLE_CACHE=1 BROWSERSLIST_ENV='modern' webpack --mode=production --env analyze",
15+
"build:sizecompare": "BABEL_DISABLE_CACHE=1 BROWSERSLIST_ENV='modern' webpack --mode=production --env nohash",
16+
"build:profile": "webpack --mode=production --env profile",
17+
"test:pkg": "webpack --env check=nobuild",
18+
"postinstall": "rm -rf node_modules/.cache"
19+
},
20+
"engines": {
21+
"node": ">=18.0"
22+
},
23+
"browserslist": "extends @anansi/browserslist-config",
24+
"keywords": [
25+
"anansi"
26+
],
27+
"devDependencies": {
28+
"@anansi/babel-preset": "6.2.1",
29+
"@anansi/browserslist-config": "^1.4.3",
30+
"@anansi/webpack-config": "^20.0.0",
31+
"@babel/core": "^7.22.15",
32+
"@types/react": "*",
33+
"@types/react-dom": "*",
34+
"react-refresh": "*",
35+
"typescript": "5.7.3",
36+
"webpack": "*",
37+
"webpack-cli": "*"
38+
},
39+
"dependencies": {
40+
"@babel/runtime-corejs3": "^7.26.7",
41+
"@data-client/img": "^0.14.0",
42+
"@data-client/react": "^0.14.0",
43+
"@data-client/rest": "^0.14.0",
44+
"core-js": "^3.40.0",
45+
"react": "^19.0.0",
46+
"react-dom": "^19.0.0"
47+
},
48+
"main": "src/index.ts",
49+
"types": "src/index.ts",
50+
"private": true,
51+
"license": "MIT"
52+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { AsyncBoundary, DataProvider, useSuspense } from '@data-client/react';
2+
import { RestEndpoint } from '@data-client/rest';
3+
import React from 'react';
4+
import { createRoot } from 'react-dom/client';
5+
6+
// docs: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductcandles
7+
export const getCandles = new RestEndpoint({
8+
urlPrefix: 'https://api.exchange.coinbase.com',
9+
path: '/products/:product_id/candles',
10+
searchParams: {} as {
11+
granularity?: 60 | 300 | 900 | 3600 | 21600 | 86400;
12+
start?: string | number;
13+
end?: string | number;
14+
},
15+
process(value: CandleTuple[]) {
16+
return value.map(candle => ({
17+
timestamp: candle[0],
18+
price_open: candle[3],
19+
}));
20+
},
21+
pollFrequency: 60 * 1000,
22+
});
23+
24+
type CandleTuple = [
25+
timestamp: number,
26+
price_low: number,
27+
price_high: number,
28+
price_open: number,
29+
price_close: number,
30+
];
31+
32+
export const Doit = () => {
33+
const a = useSuspense(getCandles, { product_id: 'BTC-USD' });
34+
return <>{a} hi</>;
35+
};
36+
export const second = React.memo(Doit);
37+
38+
export default function Entry() {
39+
return (
40+
<DataProvider>
41+
<AsyncBoundary>
42+
<Doit />
43+
</AsyncBoundary>
44+
</DataProvider>
45+
);
46+
}
47+
export const renderedElement = <Entry />;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"compilerOptions": {
3+
"outDir": "./dist",
4+
"baseUrl": "./src",
5+
"target": "esnext",
6+
"module": "esnext",
7+
"lib": [
8+
"dom",
9+
"esnext"
10+
],
11+
"jsx": "react-jsx",
12+
"declaration": true,
13+
"strict": true,
14+
"moduleResolution": "bundler",
15+
"allowSyntheticDefaultImports": true,
16+
"esModuleInterop": true,
17+
"experimentalDecorators": true,
18+
"emitDecoratorMetadata": true,
19+
"skipLibCheck": true,
20+
"types": [
21+
"@anansi/webpack-config/types"
22+
],
23+
"noEmit": true
24+
},
25+
"include": [
26+
"src"
27+
],
28+
"exclude": [
29+
"node_modules",
30+
"dist"
31+
]
32+
}

0 commit comments

Comments
 (0)