From dea46674e2170594ccb9a1cf3aa5732a6d1d55d2 Mon Sep 17 00:00:00 2001 From: Oliver Shi Date: Fri, 8 Sep 2023 12:50:50 -0400 Subject: [PATCH] add size limit --- .github/workflows/run-tests.yml | 1 + package-lock.json | 88 ++++++++++++++++++++++++++++++ packages/studio-ui/.gitignore | 2 +- packages/studio-ui/.size-limit.cjs | 7 +++ packages/studio-ui/package.json | 7 ++- 5 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 packages/studio-ui/.size-limit.cjs diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e5bb5e9b9..ca0d1ea7a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -34,3 +34,4 @@ jobs: - run: npm run build - run: npm run build-test-site -w=apps/test-site - run: npm run typecheck-jest + - run: npm run size-limit -w=packages/studio-ui diff --git a/package-lock.json b/package-lock.json index 25ebc440f..b481dc4f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5174,6 +5174,54 @@ "@sinonjs/commons": "^2.0.0" } }, + "node_modules/@size-limit/file": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@size-limit/file/-/file-9.0.0.tgz", + "integrity": "sha512-oM2UaH2FRq4q22k+R+P6xCpzET10T94LFdSjb9svVu/vOD7NaB9LGcG6se8TW1BExXiyXO4GEhLsBt3uMKM3qA==", + "dev": true, + "dependencies": { + "semver": "7.5.4" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "peerDependencies": { + "size-limit": "9.0.0" + } + }, + "node_modules/@size-limit/file/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@size-limit/file/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@size-limit/file/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, "node_modules/@surma/rollup-plugin-off-main-thread": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.3.tgz", @@ -8427,6 +8475,15 @@ "node": ">= 0.8" } }, + "node_modules/bytes-iec": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/bytes-iec/-/bytes-iec-3.1.1.tgz", + "integrity": "sha512-fey6+4jDK7TFtFg/klGSvNKJctyU7n2aQdnM+CO0ruLPbqqMOM8Tio0Pc+deqUeVKX1tL5DQep1zQ7+37aTAsA==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -15859,6 +15916,15 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/nanospinner": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/nanospinner/-/nanospinner-1.1.0.tgz", + "integrity": "sha512-yFvNYMig4AthKYfHFl1sLj7B2nkHL4lzdig4osvl9/LdGbXwrdFRoqBS98gsEsOakr0yH+r5NZ/1Y9gdVB8trA==", + "dev": true, + "dependencies": { + "picocolors": "^1.0.0" + } + }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -20976,6 +21042,26 @@ "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==" }, + "node_modules/size-limit": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/size-limit/-/size-limit-9.0.0.tgz", + "integrity": "sha512-DrA7o2DeRN3s+vwCA9nn7Ck9Y4pn9t0GNUwQRpKqBtBmNkl6LA2s/NlNCdtKHrEkRTeYA1ZQ65mnYveo9rUqgA==", + "dev": true, + "dependencies": { + "bytes-iec": "^3.1.1", + "chokidar": "^3.5.3", + "globby": "^11.1.0", + "lilconfig": "^2.1.0", + "nanospinner": "^1.1.0", + "picocolors": "^1.0.0" + }, + "bin": { + "size-limit": "bin.js" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + } + }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -26420,6 +26506,7 @@ "@babel/plugin-syntax-flow": "^7.18.6", "@babel/plugin-transform-react-jsx": "^7.19.0", "@rollup/plugin-typescript": "^10.0.1", + "@size-limit/file": "^9.0.0", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^14.4.3", @@ -26436,6 +26523,7 @@ "jest-environment-jsdom": "^29.3.1", "resize-observer-polyfill": "^1.5.1", "rollup-plugin-visualizer": "^5.9.2", + "size-limit": "^9.0.0", "vite-plugin-css-injected-by-js": "^3.3.0", "vite-plugin-dts": "^3.5.3" }, diff --git a/packages/studio-ui/.gitignore b/packages/studio-ui/.gitignore index 10dcd67fb..c04306b46 100644 --- a/packages/studio-ui/.gitignore +++ b/packages/studio-ui/.gitignore @@ -1 +1 @@ -stats.html \ No newline at end of file +stats.html diff --git a/packages/studio-ui/.size-limit.cjs b/packages/studio-ui/.size-limit.cjs new file mode 100644 index 000000000..2e0d4b7ba --- /dev/null +++ b/packages/studio-ui/.size-limit.cjs @@ -0,0 +1,7 @@ +module.exports = [ + { + path: "lib/src/index.js", + limit: "700 kB", + gzip: false, + }, +]; diff --git a/packages/studio-ui/package.json b/packages/studio-ui/package.json index 9d1ff776e..1c4a2ee32 100644 --- a/packages/studio-ui/package.json +++ b/packages/studio-ui/package.json @@ -17,9 +17,10 @@ "scripts": { "dev": "npm run copy-svg && tsc --watch --preserveWatchOutput -p tsconfig.json", "copy-svg": "npx copyfiles \"src/**/*.svg\" lib", - "build": "rimraf lib && npm run copy-svg && tsc -p tsconfig.json", + "build": "vite build", "test": "jest", - "typecheck-jest": "npx tsc -p tests/tsconfig.json" + "typecheck-jest": "npx tsc -p tests/tsconfig.json", + "size-limit": "size-limit" }, "dependencies": { "@dhmk/zustand-lens": "^2.0.5", @@ -51,6 +52,7 @@ "@babel/plugin-syntax-flow": "^7.18.6", "@babel/plugin-transform-react-jsx": "^7.19.0", "@rollup/plugin-typescript": "^10.0.1", + "@size-limit/file": "^9.0.0", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^14.4.3", @@ -67,6 +69,7 @@ "jest-environment-jsdom": "^29.3.1", "resize-observer-polyfill": "^1.5.1", "rollup-plugin-visualizer": "^5.9.2", + "size-limit": "^9.0.0", "vite-plugin-css-injected-by-js": "^3.3.0", "vite-plugin-dts": "^3.5.3" },