Skip to content

Add browser build configuration for API package - #7247

Closed
MatissJanis wants to merge 13 commits into
masterfrom
claude/browser-compatible-api-QbhHh
Closed

MatissJanis wants to merge 13 commits into
masterfrom
claude/browser-compatible-api-QbhHh

Conversation

@MatissJanis

@MatissJanis MatissJanis commented Mar 20, 2026 •

Copy link
Copy Markdown
Member

Description

API package: browser support 🎉

Related issue(s)

n/a

Testing

The build scripts can be verified by running:

  • yarn build:node - builds the Node.js version
  • yarn build:browser - builds the browser version
  • yarn build - builds both versions

Existing tests should continue to pass with no regressions. We now also have browser-specific tests.

Checklist

  • Release notes added
  • No obvious regressions in affected areas
  • Self-review has been performed - I understand what each change in the code does and why it is needed

https://claude.ai/code/session_01MnxRXLNjqXrVb5CdsC85Fb


Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 26 11.99 MB 0%
loot-core 1 4.83 MB 0%
api 4 4.06 MB 0%
cli 1 7.88 MB 0%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
26 11.99 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
static/js/index.js 3.23 MB 0%
static/js/BackgroundImage.js 119.98 kB 0%
static/js/FormulaEditor.js 846.44 kB 0%
static/js/ReportRouter.js 1021.25 kB 0%
static/js/TransactionList.js 81.29 kB 0%
static/js/ca.js 185.57 kB 0%
static/js/da.js 104.66 kB 0%
static/js/de.js 177.58 kB 0%
static/js/en-GB.js 7.16 kB 0%
static/js/en.js 170.68 kB 0%
static/js/es.js 172.13 kB 0%
static/js/fr.js 177.57 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.46 kB 0%
static/js/it.js 168.97 kB 0%
static/js/narrow.js 354.12 kB 0%
static/js/nb-NO.js 154.72 kB 0%
static/js/nl.js 111.58 kB 0%
static/js/pl.js 88.34 kB 0%
static/js/pt-BR.js 180.5 kB 0%
static/js/resize-observer.js 18.03 kB 0%
static/js/th.js 179.94 kB 0%
static/js/theme.js 30.68 kB 0%
static/js/uk.js 213.14 kB 0%
static/js/useTransactionBatchActions.js 4.29 MB 0%
static/js/wide.js 418 B 0%
static/js/workbox-window.prod.es5.js 7.28 kB 0%

loot-core

Total

Files count Total bundle size % Changed
1 4.83 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.Dmj0rSrb.js 4.83 MB 0%

api

Total

Files count Total bundle size % Changed
4 4.06 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
index.js 3.84 MB 0%
from-Bl-Hslp4.js 167.73 kB 0%
multipart-parser-BnDysoMr.js 8.1 kB 0%
src-iMkUmuwR.js 43.64 kB 0%

cli

Total

Files count Total bundle size % Changed
1 7.88 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
cli.js 7.88 MB 0%

claude added 2 commits March 16, 2026 22:19
The API package was previously Node.js-only due to its dependency on
better-sqlite3 and Node.js fs/path modules. This adds a browser build
that uses loot-core's existing browser platform implementations
(sql.js/WASM, IndexedDB, absurd-sql) instead.

Changes:
- Add index.web.ts: browser entry point (no Node.js version check or
  node-fetch polyfill)
- Add vite.browser.config.ts: browser-targeted Vite build that resolves
  to browser platform files (index.ts) instead of Node.js ones
  (index.api.ts -> index.electron.ts)
- Update package.json: conditional exports (browser vs default/node),
  module field, build:browser script
- Update tsconfig.json: exclude new config file from type checking

The browser build outputs dist/browser.js (ESM) alongside the existing
dist/index.js (CJS/Node). Bundlers that support the "browser" condition
in package.json exports will automatically use the browser build.

https://claude.ai/code/session_01MnxRXLNjqXrVb5CdsC85Fb
- Remove `internal` export from index.web.ts (keep as local variable)
- Use `yarn build:node && yarn build:browser` in build script
- Remove unnecessary `node:` external from vite.browser.config.ts
  (Vite handles browser externalization automatically)

https://claude.ai/code/session_01MnxRXLNjqXrVb5CdsC85Fb
@netlify

netlify Bot commented Mar 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 03ed7d8
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/69bf19f7e69895000819f286
😎 Deploy Preview https://deploy-preview-7247.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Mar 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget-storybook ready!

Name Link
🔨 Latest commit 3e2303e
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget-storybook/deploys/69bdbbd518c9d80008a93ddb
😎 Deploy Preview https://deploy-preview-7247--actualbudget-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Mar 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget-website ready!

Name Link
🔨 Latest commit 3e2303e
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget-website/deploys/69bdbbd502fb360008af69e3
😎 Deploy Preview https://deploy-preview-7247.www.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

claude added 2 commits March 20, 2026 21:27
The API package was previously Node.js-only due to its dependency on
better-sqlite3 and Node.js fs/path modules. This adds a browser build
that uses loot-core's existing browser platform implementations
(sql.js/WASM, IndexedDB, absurd-sql) instead.

Changes:
- Add index.web.ts: browser entry point (no Node.js version check or
  node-fetch polyfill)
- Add vite.browser.config.ts: browser-targeted Vite build that resolves
  to browser platform files (index.ts) instead of Node.js ones
  (index.api.ts -> index.electron.ts)
- Update package.json: conditional exports (browser vs default/node),
  module field, build:browser script
- Update tsconfig.json: exclude new config file from type checking

The browser build outputs dist/browser.js (ESM) alongside the existing
dist/index.js (CJS/Node). Bundlers that support the "browser" condition
in package.json exports will automatically use the browser build.

https://claude.ai/code/session_01MnxRXLNjqXrVb5CdsC85Fb
- Remove `internal` export from index.web.ts (keep as local variable)
- Use `yarn build:node && yarn build:browser` in build script
- Remove unnecessary `node:` external from vite.browser.config.ts
  (Vite handles browser externalization automatically)

https://claude.ai/code/session_01MnxRXLNjqXrVb5CdsC85Fb
@MatissJanis
MatissJanis force-pushed the claude/browser-compatible-api-QbhHh branch from 6d6e032 to 3e2303e Compare March 20, 2026 21:27
Comment thread packages/api/index.web.ts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should do index.browser.ts? Because that's the naming we use in loot-core

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense.

Also added some unit tests.

Still have not done a manual test though, so am not 100% confident in this PR. But I have to leave it here. Will circle back in ~1 week. Or you can take over it if you like

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also to note: if we start using api directly in desktop-client - the bundle size will go up by approx 4mb as we would be double-bundling loot-core. To solve this we need to also address #7252 and then slightly change the build process for the api package. All doable.. but I haven't gotten to this yet.

…albudget/actual into claude/browser-compatible-api-QbhHh
… API package. This change is part of the ongoing refactor to streamline the API for browser compatibility.
- Introduced `npm-run-all` for improved script management in package.json.
- Updated Vite configuration to include test settings for both browser and Node environments.
- Added integration tests for API CRUD operations, including budget and category management.
- Created setup files for browser and Node testing environments.
- Updated yarn.lock to include new dependencies.

This commit enhances the testing framework and ensures better compatibility across environments.
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi! It looks like this PR has not had any changes for a week now. Would you like someone to review this PR? If so - please remove the "[WIP]" prefix from the PR title. That will let the community know that this PR is open for a review.

@github-actions github-actions Bot added the Stale label Mar 29, 2026
@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 5 days with no activity.

@github-actions github-actions Bot closed this Apr 3, 2026
@MatissJanis

Copy link
Copy Markdown
Member Author

FYI: will circle back to this a bit later.

MatissJanis added a commit that referenced this pull request Apr 18, 2026
Captures the approach for adding a browser build to @actual-app/api, the
unit-test setup that runs the same integration spec under both Node and
browser environments, and an out-of-repo playground app that hand-verifies
the browser build against a real Actual sync server.

Continuation of the work started in #7247 (closed stale).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@MatissJanis
MatissJanis deleted the claude/browser-compatible-api-QbhHh branch May 29, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants