A local-first personal finance app
[AI] Emit bundle stats from the crdt package (#7537)
Matiss Janis Aboltinsff7f81ac065c
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 0299d4a032..15e2d5d163 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -56,11 +56,18 @@ jobs:run: cd packages/crdt && yarn build- name: Create package tgzrun: cd packages/crdt && yarn pack && mv package.tgz actual-crdt.tgz+ - name: Prepare bundle stats artifact+ run: cp packages/crdt/dist/stats.json crdt-stats.json- name: Upload Builduses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1with:name: actual-crdtpath: packages/crdt/actual-crdt.tgz+ - name: Upload CRDT bundle stats+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ with:+ name: crdt-build-stats+ path: crdt-stats.jsonweb:runs-on: ubuntu-latestdiff --git a/.github/workflows/size-compare.yml b/.github/workflows/size-compare.ymlindex 7f5c09c5ba..30b76c4611 100644--- a/.github/workflows/size-compare.yml+++ b/.github/workflows/size-compare.yml@@ -64,6 +64,13 @@ jobs:token: ${{ secrets.GITHUB_TOKEN }}checkName: cliref: ${{github.base_ref}}+ - name: Wait for ${{github.base_ref}} CRDT build to succeed+ uses: fountainhead/action-wait-for-check@5a908a24814494009c4bb27c242ea38c93c593be # v1.2.0+ id: master-crdt-build+ with:+ token: ${{ secrets.GITHUB_TOKEN }}+ checkName: crdt+ ref: ${{github.base_ref}}- name: Wait for PR build to succeeduses: fountainhead/action-wait-for-check@5a908a24814494009c4bb27c242ea38c93c593be # v1.2.0@@ -86,9 +93,16 @@ jobs:token: ${{ secrets.GITHUB_TOKEN }}checkName: cliref: ${{github.event.pull_request.head.sha}}+ - name: Wait for CRDT PR build to succeed+ uses: fountainhead/action-wait-for-check@5a908a24814494009c4bb27c242ea38c93c593be # v1.2.0+ id: wait-for-crdt-build+ with:+ token: ${{ secrets.GITHUB_TOKEN }}+ checkName: crdt+ ref: ${{github.event.pull_request.head.sha}}- name: Report build failure- if: steps.wait-for-web-build.outputs.conclusion == 'failure' || steps.wait-for-api-build.outputs.conclusion == 'failure' || steps.wait-for-cli-build.outputs.conclusion == 'failure'+ if: steps.wait-for-web-build.outputs.conclusion == 'failure' || steps.wait-for-api-build.outputs.conclusion == 'failure' || steps.wait-for-cli-build.outputs.conclusion == 'failure' || steps.wait-for-crdt-build.outputs.conclusion == 'failure'run: |echo "Build failed on PR branch or ${{github.base_ref}}"exit 1@@ -146,6 +160,23 @@ jobs:name: cli-build-statspath: headallow_forks: true+ - name: Download CRDT build artifact from ${{github.base_ref}}+ uses: dawidd6/action-download-artifact@8305c0f1062bb0d184d09ef4493ecb9288447732 # v20+ with:+ branch: ${{github.base_ref}}+ workflow: build.yml+ workflow_conclusion: '' # ignore the conclusion of the workflow, since we already checked it+ name: crdt-build-stats+ path: base+ - name: Download CRDT stats from PR+ uses: dawidd6/action-download-artifact@8305c0f1062bb0d184d09ef4493ecb9288447732 # v20+ with:+ pr: ${{github.event.pull_request.number}}+ workflow: build.yml+ workflow_conclusion: '' # ignore the conclusion of the workflow, since we already checked it+ name: crdt-build-stats+ path: head+ allow_forks: true- name: Strip content hashes from stats filesrun: |if [ -f ./head/web-stats.json ]; then@@ -168,10 +199,12 @@ jobs:--base loot-core=./base/loot-core-stats.json \--base api=./base/api-stats.json \--base cli=./base/cli-stats.json \+ --base crdt=./base/crdt-stats.json \--head desktop-client=./head/web-stats.json \--head loot-core=./head/loot-core-stats.json \--head api=./head/api-stats.json \--head cli=./head/cli-stats.json \+ --head crdt=./head/crdt-stats.json \--identifier combined \--format pr-body > bundle-stats-comment.md- name: Post combined bundle stats commentdiff --git a/packages/crdt/package.json b/packages/crdt/package.jsonindex c06738afe9..47c9fcf22f 100644--- a/packages/crdt/package.json+++ b/packages/crdt/package.json@@ -20,9 +20,9 @@}},"scripts": {- "build:node": "tsgo -p tsconfig.build.json",+ "build:node": "vite build","proto:generate": "./bin/generate-proto",- "build": "rm -rf dist && yarn run build:node && cp src/proto/sync_pb.js dist/proto/sync_pb.js",+ "build": "yarn run build:node && tsgo -p tsconfig.build.json --emitDeclarationOnly","test": "vitest --run","typecheck": "tsgo -b"},@@ -34,7 +34,9 @@"@types/google-protobuf": "3.15.12","@typescript/native-preview": "^7.0.0-dev.20260404.1","protoc-gen-js": "3.21.4-4",+ "rollup-plugin-visualizer": "^7.0.1","ts-protoc-gen": "0.15.0",+ "vite": "^8.0.5","vitest": "^4.1.2"}}diff --git a/packages/crdt/vite.config.mts b/packages/crdt/vite.config.mtsnew file mode 100644index 0000000000..e71868c484--- /dev/null+++ b/packages/crdt/vite.config.mts@@ -0,0 +1,24 @@+import path from 'path';++import { visualizer } from 'rollup-plugin-visualizer';+import { defineConfig } from 'vite';++export default defineConfig({+ ssr: {+ noExternal: true,+ external: ['google-protobuf', 'murmurhash'],+ },+ build: {+ ssr: true,+ target: 'node22',+ outDir: path.resolve(__dirname, 'dist'),+ emptyOutDir: true,+ sourcemap: true,+ lib: {+ entry: path.resolve(__dirname, 'src/index.ts'),+ formats: ['cjs'],+ fileName: () => 'index.js',+ },+ },+ plugins: [visualizer({ template: 'raw-data', filename: 'dist/stats.json' })],+});diff --git a/upcoming-release-notes/7537.md b/upcoming-release-notes/7537.mdnew file mode 100644index 0000000000..1bb2a5482e--- /dev/null+++ b/upcoming-release-notes/7537.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [MatissJanis]+---++Migrate CRDT package build to Vite and generate bundle statistics for CI/CD.diff --git a/yarn.lock b/yarn.lockindex eeb1ff2905..b02b9099a8 100644--- a/yarn.lock+++ b/yarn.lock@@ -173,7 +173,9 @@ __metadata:google-protobuf: "npm:^3.21.4"murmurhash: "npm:^2.0.1"protoc-gen-js: "npm:3.21.4-4"+ rollup-plugin-visualizer: "npm:^7.0.1"ts-protoc-gen: "npm:0.15.0"+ vite: "npm:^8.0.5"vitest: "npm:^4.1.2"languageName: unknownlinkType: soft