diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 75a05a0e..67e51a40 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,6 +44,7 @@ jobs: run: pnpm test - name: 📏 Report bundle size + if: github.event_name == 'pull_request' uses: andresz1/size-limit-action@v1 continue-on-error: true with: diff --git a/.size-limit.cjs b/.size-limit.cjs new file mode 100644 index 00000000..68b97f08 --- /dev/null +++ b/.size-limit.cjs @@ -0,0 +1,25 @@ +const fs = require('fs'); +const path = require('path'); + +const packagesDir = path.join(__dirname, 'packages'); +const packageDirs = fs.readdirSync(packagesDir); + +const packages = packageDirs + .map((dir) => { + const packageJsonPath = path.join(packagesDir, dir, 'package.json'); + + if (fs.existsSync(packageJsonPath)) { + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); + + return { + name: packageJson.name, + path: path.join(__dirname, packageJson.repository.directory, packageJson.module), + import: '*', + }; + } + + return null; + }) + .filter(Boolean); + +module.exports = packages; diff --git a/package.json b/package.json index cf715609..ea5f0f9c 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,8 @@ "release": "pnpm release:version && pnpm release:publish", "release:publish": "pnpm clean && pnpm build && changeset publish", "release:version": "changeset version", + "size": "size-limit", + "size:why": "size-limit --why --clean-dir --save-bundle ./tmp", "stats:eslint": "cross-env TIMING=1 turbo run stats:eslint", "stats:ts": "turbo run stats:ts", "test": "turbo run test", @@ -41,6 +43,9 @@ "@lottiefiles/prettier-config": "3.0.0", "@lottiefiles/remark-preset": "1.0.0", "@lottiefiles/tsconfig": "2.0.0", + "@size-limit/esbuild": "^11.0.0", + "@size-limit/esbuild-why": "^11.0.0", + "@size-limit/preset-small-lib": "^10.0.2", "cross-env": "7.0.3", "eslint": "7.32.0", "husky": "8.0.3", @@ -48,6 +53,7 @@ "npm-check-updates": "16.10.9", "prettier": "2.8.8", "remark-cli": "11.0.0", + "size-limit": "^10.0.2", "syncpack": "9.8.6", "turbo": "1.10.16", "typescript": "5.0.4" diff --git a/packages/web/.size-limit.cjs b/packages/web/.size-limit.cjs deleted file mode 100644 index 2c1ec861..00000000 --- a/packages/web/.size-limit.cjs +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = [ - { - path: './dist/index.js', - import: '{ DotLottie }', - }, -]; diff --git a/packages/web/package.json b/packages/web/package.json index a386b45c..6df77537 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -39,7 +39,6 @@ "build:wasm:docker": "./docker_build_wasm.sh", "dev": "tsup --watch", "lint": "eslint --fix .", - "size": "size-limit", "size:why": "size-limit --why --clean-dir --save-bundle ./tmp", "stats:eslint": "cross-env TIMING=1 eslint .", "stats:ts": "tsc -p tsconfig.build.json --extendedDiagnostics", @@ -49,10 +48,7 @@ "@dotlottie/dotlottie-js": "^0.6.0" }, "devDependencies": { - "@size-limit/esbuild-why": "^10.0.2", - "@size-limit/preset-small-lib": "^10.0.2", "cross-env": "7.0.3", - "size-limit": "^10.0.2", "tsup": "7.2.0", "typescript": "5.0.4" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6ce02fa5..4cfbd473 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,6 +29,15 @@ importers: '@lottiefiles/tsconfig': specifier: 2.0.0 version: 2.0.0(typescript@5.0.4) + '@size-limit/esbuild': + specifier: ^11.0.0 + version: 11.0.0(size-limit@10.0.2) + '@size-limit/esbuild-why': + specifier: ^11.0.0 + version: 11.0.0(size-limit@10.0.2) + '@size-limit/preset-small-lib': + specifier: ^10.0.2 + version: 10.0.2(size-limit@10.0.2) cross-env: specifier: 7.0.3 version: 7.0.3 @@ -50,6 +59,9 @@ importers: remark-cli: specifier: 11.0.0 version: 11.0.0 + size-limit: + specifier: ^10.0.2 + version: 10.0.2 syncpack: specifier: 9.8.6 version: 9.8.6 @@ -79,18 +91,9 @@ importers: specifier: ^0.6.0 version: 0.6.0 devDependencies: - '@size-limit/esbuild-why': - specifier: ^10.0.2 - version: 10.0.2(size-limit@10.0.2) - '@size-limit/preset-small-lib': - specifier: ^10.0.2 - version: 10.0.2(size-limit@10.0.2) cross-env: specifier: 7.0.3 version: 7.0.3 - size-limit: - specifier: ^10.0.2 - version: 10.0.2 tsup: specifier: 7.2.0 version: 7.2.0(ts-node@10.9.1)(typescript@5.0.4) @@ -1953,11 +1956,11 @@ packages: engines: {node: '>=14.16'} dev: true - /@size-limit/esbuild-why@10.0.2(size-limit@10.0.2): - resolution: {integrity: sha512-X1NNP2c6BEpsVGqyG2ptwpm95AfP46Dgr4tMRx63pONv3LlG/3YF2d8aG1vQoQvMk1y2c7Uh0C9U/kOqGFrs8g==} + /@size-limit/esbuild-why@11.0.0(size-limit@10.0.2): + resolution: {integrity: sha512-YTEmxCBE5PF6LH9lvNYXJM/h7XqVjpCVFVf2NrsJ75d3HdU8q77WriI7/T1++reBf8GfUhY5RIyASdR1ZJ8S4w==} engines: {node: ^18.0.0 || >=20.0.0} peerDependencies: - size-limit: 10.0.2 + size-limit: 11.0.0 dependencies: esbuild-visualizer: 0.4.1 open: 9.1.0 @@ -1975,6 +1978,17 @@ packages: size-limit: 10.0.2 dev: true + /@size-limit/esbuild@11.0.0(size-limit@10.0.2): + resolution: {integrity: sha512-OOmba2ZuMpaUhmBXgCfgrO7L6zkUDwvFFfW8T+dK08968LQ79Q+kNgEXQAd+dhj9TlTkHyyEDczWmx16e9cXoQ==} + engines: {node: ^18.0.0 || >=20.0.0} + peerDependencies: + size-limit: 11.0.0 + dependencies: + esbuild: 0.19.5 + nanoid: 5.0.3 + size-limit: 10.0.2 + dev: true + /@size-limit/file@10.0.2(size-limit@10.0.2): resolution: {integrity: sha512-27jzgQtER/2WP4+ciLe8aExkceSfqQFSDEbFVhXnbpFvQBqGZ7uEQG9bDX7a5VGxTdMtGwzZndMsCOlinmLzSg==} engines: {node: ^18.0.0 || >=20.0.0} @@ -7992,6 +8006,12 @@ packages: hasBin: true dev: true + /nanoid@5.0.3: + resolution: {integrity: sha512-I7X2b22cxA4LIHXPSqbBCEQSL+1wv8TuoefejsX4HFWyC6jc5JG7CEaxOltiKjc1M+YCS2YkrZZcj4+dytw9GA==} + engines: {node: ^18 || >=20} + hasBin: true + dev: true + /nanospinner@1.1.0: resolution: {integrity: sha512-yFvNYMig4AthKYfHFl1sLj7B2nkHL4lzdig4osvl9/LdGbXwrdFRoqBS98gsEsOakr0yH+r5NZ/1Y9gdVB8trA==} dependencies: