From c205f181967fceaf0c72d33ce1efc5325b8a9008 Mon Sep 17 00:00:00 2001 From: Jozef Harag Date: Thu, 7 Nov 2024 15:07:59 +0100 Subject: [PATCH] chore: check size of artifacts (#889) --- .github/workflows/ci-main.yml | 2 + .github/workflows/ci.yml | 2 + .size-limit.cjs | 42 +++++++++ eslint.config.mjs | 1 + package-lock.json | 163 ++++++++++++++++++++++++++++++++-- package.json | 5 +- 6 files changed, 209 insertions(+), 6 deletions(-) create mode 100644 .size-limit.cjs diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index a54b9ac2..a7fa6831 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -14,6 +14,8 @@ jobs: uses: actions/checkout@v4.2.2 - name: Setup uses: ./.github/actions/setup + - name: Size check + run: npm run size-limit - run: npm run version:check - name: Lint code run: npm run lint diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7d77974..beaa0aed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,8 @@ jobs: - name: Setup uses: ./.github/actions/setup - run: npm run version:check + - name: Size check + run: npm run size-limit - name: Lint code run: npm run lint - name: Lint docs diff --git a/.size-limit.cjs b/.size-limit.cjs new file mode 100644 index 00000000..402e9322 --- /dev/null +++ b/.size-limit.cjs @@ -0,0 +1,42 @@ +/** + * + * Copyright 2024 Splunk Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +module.exports = [ + { + name: 'artifacts/otel-api-globals.js', + limit: '3 kB', + path: './packages/web/dist/artifacts/otel-api-globals.js', + }, + + { + name: 'artifacts/splunk-otel-web.js', + limit: '40 kB', + path: './packages/web/dist/artifacts/splunk-otel-web.js', + }, + + { + name: 'artifacts/splunk-otel-web.js', + limit: '72 kB', + path: './packages/web/dist/artifacts/splunk-otel-web-legacy.js', + }, + + { + name: 'artifacts/splunk-otel-web-session-recorder.js', + limit: '22 kB', + path: './packages/session-recorder/dist/artifacts/splunk-otel-web-session-recorder.js', + }, +] diff --git a/eslint.config.mjs b/eslint.config.mjs index 391d296f..3bcf832b 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -210,6 +210,7 @@ export default [ 'packages/web/performance-tests/**/*.{js,mjs,cjs}', 'packages/web/integration-tests/**/*.{js,mjs,cjs}', '**/*.conf.js', + '.size-limit.cjs', '.prettierrc.cjs', ], languageOptions: { diff --git a/package-lock.json b/package-lock.json index 14ce78ae..e7ce226c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "@eslint/js": "^9.13.0", "@octokit/graphql": "^7.0.1", "@octokit/request": "^8.1.1", + "@size-limit/file": "^11.1.6", "@stylistic/eslint-plugin-js": "^2.10.1", "@stylistic/eslint-plugin-ts": "^2.10.1", "@typescript-eslint/eslint-plugin": "^8.13.0", @@ -28,6 +29,7 @@ "eslint-plugin-prettier": "^5.2.1", "globals": "^15.11.0", "prettier": "^3.3.3", + "size-limit": "^11.1.6", "typescript": "^5.1.6", "typescript-eslint": "^8.12.2" }, @@ -4710,6 +4712,19 @@ "integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==", "dev": true }, + "node_modules/@size-limit/file": { + "version": "11.1.6", + "resolved": "https://registry.npmjs.org/@size-limit/file/-/file-11.1.6.tgz", + "integrity": "sha512-ojzzJMrTfcSECRnaTjGy0wNIolTCRdyqZTSWG9sG5XEoXG6PNgHXDDS6gf6YNxnqb+rWfCfVe93u6aKi3wEocQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "peerDependencies": { + "size-limit": "11.1.6" + } + }, "node_modules/@smithy/abort-controller": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@smithy/abort-controller/-/abort-controller-3.1.0.tgz", @@ -7081,6 +7096,16 @@ "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, + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/cacheable-lookup": { "version": "5.0.4", "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", @@ -11630,6 +11655,16 @@ "node": "*" } }, + "node_modules/jiti": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.4.0.tgz", + "integrity": "sha512-H5UpaUI+aHOqZXlYOaFP/8AzKsg+guWu+Pr3Y8i7+Y3zr1aXAvCvTAQ1RxSc6oVD8R8c7brgNtTVP91E7upH/g==", + "dev": true, + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, "node_modules/jpeg-js": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.4.4.tgz", @@ -12343,6 +12378,19 @@ } } }, + "node_modules/lilconfig": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.2.tgz", + "integrity": "sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antonk52" + } + }, "node_modules/lines-and-columns": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", @@ -13167,6 +13215,16 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node_modules/nanospinner": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/nanospinner/-/nanospinner-1.2.0.tgz", + "integrity": "sha512-dGxYcEj8YhuxjVO3PYmnj1nBhtwUkvuwYbLl/MduBPmQUPy3xBtG/ScJgqZgntQkX44UQaCSlFeW4rS5fUR/Sw==", + "dev": true, + "license": "MIT", + "dependencies": { + "picocolors": "^1.1.1" + } + }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -14679,10 +14737,11 @@ "dev": true }, "node_modules/picocolors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", - "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==", - "dev": true + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" }, "node_modules/picomatch": { "version": "2.3.1", @@ -15998,6 +16057,58 @@ "node": ">=0.3.1" } }, + "node_modules/size-limit": { + "version": "11.1.6", + "resolved": "https://registry.npmjs.org/size-limit/-/size-limit-11.1.6.tgz", + "integrity": "sha512-S5ux2IB8rU26xwVgMskmknGMFkieaIAqDLuwgKiypk6oa4lFsie8yFPrzRFV+yrLDY2GddjXuCaVk5PveVOHiQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "bytes-iec": "^3.1.1", + "chokidar": "^4.0.1", + "jiti": "^2.0.0", + "lilconfig": "^3.1.2", + "nanospinner": "^1.1.0", + "picocolors": "^1.1.0", + "tinyglobby": "^0.2.7" + }, + "bin": { + "size-limit": "bin.js" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + } + }, + "node_modules/size-limit/node_modules/chokidar": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.1.tgz", + "integrity": "sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/size-limit/node_modules/readdirp": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.0.2.tgz", + "integrity": "sha512-yDMz9g+VaZkqBYS/ozoBJwaBhTbZo3UNYQHNRw1D3UFQB8oHB4uS/tAODO+ZLjGWmUbKnIlOWO+aaIiAxrUWHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/smart-buffer": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", @@ -16852,6 +16963,48 @@ "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, + "node_modules/tinyglobby": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.10.tgz", + "integrity": "sha512-Zc+8eJlFMvgatPZTl6A9L/yht8QqdmUNtURHaKZLmKBE12hNPSrqNkUp2cs3M/UKmNVVAMFQYSjYIVHDjW5zew==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.4.2", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.4.2", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.2.tgz", + "integrity": "sha512-KnhMXsKSPZlAhp7+IjUkRZKPb4fUyccpDrdFXbi4QL1qkmFh9kVY09Yox+n4MaOb3lHZ1Tv829C3oaaXoMYPDQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/tldts-core": { "version": "6.1.28", "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.28.tgz", @@ -18173,7 +18326,7 @@ }, "packages/web": { "name": "@splunk/otel-web", - "version": "0.19.1", + "version": "0.19.2", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.24.7", diff --git a/package.json b/package.json index ef062755..ce29c75d 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "postversion": "node ./scripts/version-update.mjs", "version:bump": "npm version --workspaces --include-workspace-root", "version:check": "node ./scripts/version-check.mjs", - "tag:check": "node ./scripts/tag-check.js" + "tag:check": "node ./scripts/tag-check.js", + "size-limit": "size-limit" }, "devDependencies": { "@aws-sdk/client-cloudfront": "^3.171.0", @@ -48,6 +49,7 @@ "@eslint/js": "^9.13.0", "@octokit/graphql": "^7.0.1", "@octokit/request": "^8.1.1", + "@size-limit/file": "^11.1.6", "@stylistic/eslint-plugin-js": "^2.10.1", "@stylistic/eslint-plugin-ts": "^2.10.1", "@typescript-eslint/eslint-plugin": "^8.13.0", @@ -59,6 +61,7 @@ "eslint-plugin-prettier": "^5.2.1", "globals": "^15.11.0", "prettier": "^3.3.3", + "size-limit": "^11.1.6", "typescript": "^5.1.6", "typescript-eslint": "^8.12.2" }