Skip to content

[code-infra] Add bundle size monitor #1791

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

Merged
merged 34 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f2d25ac
[code-infra] Add bundle size monitor
Janpot Apr 28, 2025
73628aa
Update bundle-size-checker.config.mjs
Janpot Apr 28, 2025
ccc50b3
Update config.yml
Janpot Apr 28, 2025
f806831
fixes
Janpot Apr 28, 2025
4153831
Update pnpm-lock.yaml
Janpot Apr 28, 2025
dd7fcac
Update pnpm-lock.yaml
Janpot May 5, 2025
e83825b
Merge remote-tracking branch 'upstream/master' into bundle-sizes
Janpot May 6, 2025
3a1344c
update
Janpot May 7, 2025
7328fa6
Merge remote-tracking branch 'upstream/master' into bundle-sizes
Janpot May 7, 2025
117b8a6
Update pnpm-lock.yaml
Janpot May 7, 2025
3d2ae51
Update pnpm-lock.yaml
Janpot May 7, 2025
42b3de3
Update pnpm-lock.yaml
Janpot May 7, 2025
5888404
Update pnpm-lock.yaml
Janpot May 7, 2025
c994fca
this works now
Janpot May 8, 2025
4afed6d
remove unneeded
Janpot May 8, 2025
6f0cd7d
remove name
Janpot May 8, 2025
9a8923e
Update pnpm-lock.yaml
Janpot May 8, 2025
342507b
externals
Janpot May 8, 2025
14acab1
fix attw
Janpot May 8, 2025
b6ca230
Merge remote-tracking branch 'upstream/master' into bundle-sizes
Janpot May 15, 2025
7ccc2ae
update packages
Janpot May 15, 2025
3c61659
Merge branch 'master' into bundle-sizes
Janpot May 15, 2025
ba1e3b3
vfege
Janpot May 15, 2025
1afe275
Merge remote-tracking branch 'upstream/master' into bundle-sizes
Janpot May 20, 2025
73e45e4
Move dangerfile content
Janpot May 20, 2025
e96459d
move bundle-size folder to test
Janpot May 21, 2025
a91b645
Add radix/base checkbox comparison snippets
Janpot May 21, 2025
e2404c3
update monitor
Janpot May 22, 2025
e3c4fa3
use separate file
Janpot May 22, 2025
373d942
Merge remote-tracking branch 'upstream/master' into bundle-sizes
Janpot May 22, 2025
4eb9ebe
Merge remote-tracking branch 'upstream/master' into bundle-sizes
Janpot May 28, 2025
9160734
Add package.json export back
Janpot May 28, 2025
60edf24
fix ci
Janpot May 28, 2025
f1f2b1f
Merge remote-tracking branch 'upstream/master' into bundle-sizes
Janpot May 29, 2025
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
31 changes: 23 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ default-job: &default-job
COREPACK_ENABLE_DOWNLOAD_PROMPT: '0'
working_directory: /tmp/base-ui
docker:
- image: cimg/node:18.20
- image: cimg/node:20.17

default-context: &default-context
context:
Expand Down Expand Up @@ -183,7 +183,7 @@ jobs:
pnpm docs:link-check
git add -A && git diff --exit-code --staged
- run:
name: '`pnpm inline-scripts changes committed?'
name: '`pnpm inline-scripts` changes committed?'
command: |
pnpm inline-scripts
git add -A && git diff --exit-code --staged
Expand Down Expand Up @@ -297,18 +297,20 @@ jobs:
- run:
name: pnpm test:e2e
command: pnpm test:e2e
test_bundle_size_monitor:
<<: *default-job
steps:
- checkout
- install_js
# TODO test bundle size https://github.com/mui/base-ui/issues/201

test_package:
<<: *default-job
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>

- run:
name: prepare danger on PRs
command: pnpm danger ci
environment:
DANGER_COMMAND: prepareBundleSizeReport

- run:
name: Build packages
command: pnpm release:build
Expand All @@ -319,6 +321,19 @@ jobs:
name: Verify built packages
command: pnpm -r test:package

- run:
name: create and upload a size snapshot
command: |
export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID_ARTIFACTS
export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY_ARTIFACTS
export AWS_REGION=$AWS_REGION_ARTIFACTS
pnpm size:snapshot

- run:
name: Run danger on PRs
command: pnpm danger ci --fail-on-errors
environment:
DANGER_COMMAND: reportBundleSize
workflows:
pipeline:
when:
Expand Down
6 changes: 6 additions & 0 deletions dangerfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const tsx = require('tsx/cjs/api');

// danger uses babelify under the hood. The implementation is buggy and fails on our
// custom plugins in our codebase. We'll just disable it and do our own compilation.
// Danger must always be run with envirnonent variable `DANGER_DISABLE_TRANSPILATION="true"`.
tsx.require('./scripts/dangerFileContent', __filename);
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"valelint": "pnpm vale sync && git ls-files | grep -h \".md$\" | xargs pnpm vale --filter='.Level==\"error\"'",
"prettier": "pretty-quick --ignore-path .eslintignore",
"prettier:all": "prettier --write . --ignore-path .eslintignore",
"size:snapshot": "node --max-old-space-size=4096 ./scripts/sizeSnapshot/create",
"size:why": "pnpm size:snapshot --analyze",
"size:snapshot": "pnpm -F ./test/bundle-size check",
"size:why": "pnpm size:snapshot --analyze --accurateBundles",
"start": "pnpm install && pnpm docs:dev",
"test": "pnpm test:chromium",
"test:e2e": "cross-env NODE_ENV=production pnpm test:e2e:build && concurrently --success first --kill-others \"pnpm test:e2e:run\" \"pnpm test:e2e:server\"",
Expand Down Expand Up @@ -73,6 +73,7 @@
"@babel/register": "^7.27.1",
"@mui/internal-babel-plugin-display-name": "^1.0.0",
"@mui/internal-babel-plugin-resolve-imports": "^2.0.1",
"@mui/internal-bundle-size-checker": "^1.0.3",
"@mui/internal-docs-utils": "^2.0.1",
"@mui/internal-markdown": "^2.0.4",
"@mui/internal-scripts": "^2.0.7",
Expand Down Expand Up @@ -105,6 +106,7 @@
"concurrently": "^9.1.2",
"cross-env": "^7.0.3",
"css-loader": "^7.1.2",
"danger": "^13.0.4",
"docs": "workspace:^",
"eslint": "^8.57.1",
"eslint-config-airbnb": "^19.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"build:types": "tsx ../../scripts/buildTypes.mts --copy build/cjs",
"build:copy-files": "node ../../scripts/copyFiles.mjs ./.npmignore:./.npmignore",
"build:manifest": "tsx ./scripts/createPackageManifest.mts",
"test:package": "publint ./build && attw --pack ./build",
"test:package": "publint ./build && attw --pack ./build --exclude-entrypoints package.json",
"release": "pnpm build && pnpm publish",
"test": "cross-env NODE_ENV=test VITEST_ENV=jsdom vitest",
"typescript": "tsc -b tsconfig.json"
Expand Down
5 changes: 4 additions & 1 deletion packages/react/scripts/createPackageManifest.mts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ export async function createPackageManifest() {
'*': ['./cjs/*/index.d.ts'],
},
},
exports: retargetExports(exports),
exports: {
'./package.json': './package.json',
...retargetExports(exports),
},
publishConfig,
};

Expand Down
Loading