Compare commits

...

3 Commits

Author SHA1 Message Date
Claude
6d6e032429 [AI] Address review feedback for browser API build
- 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
2026-03-17 12:04:21 +00:00
Claude
399e59c088 [AI] Add browser-compatible build for @actual-app/api
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
2026-03-16 22:19:22 +00:00
Matiss Janis Aboltins
f73c5e9210 [AI] Fix adm-zip dependency resolution in loot-core (#7219) 2026-03-16 21:11:51 +00:00
8 changed files with 84 additions and 11 deletions

View File

@@ -88,6 +88,7 @@
"typescript": "^5.9.3"
},
"resolutions": {
"adm-zip": "patch:adm-zip@npm%3A0.5.16#~/.yarn/patches/adm-zip-npm-0.5.16-4556fea098.patch",
"rollup": "4.40.1",
"socks": ">=2.8.3"
},

25
packages/api/index.web.ts Normal file
View File

@@ -0,0 +1,25 @@
import { init as initLootCore } from '@actual-app/core/server/main';
import type { InitConfig, lib } from '@actual-app/core/server/main';
export * from './methods';
export * as utils from './utils';
let internal: typeof lib | null = null;
export async function init(config: InitConfig = {}) {
internal = await initLootCore(config);
return internal;
}
export async function shutdown() {
if (internal) {
try {
await internal.send('sync');
} catch {
// most likely that no budget is loaded, so the sync failed
}
await internal.send('close-budget');
internal = null;
}
}

View File

@@ -8,9 +8,24 @@
"dist"
],
"main": "dist/index.js",
"module": "dist/browser.js",
"types": "@types/index.d.ts",
"exports": {
".": {
"browser": {
"types": "./@types/index.d.ts",
"default": "./dist/browser.js"
},
"default": {
"types": "./@types/index.d.ts",
"default": "./dist/index.js"
}
}
},
"scripts": {
"build": "vite build",
"build": "yarn build:node && yarn build:browser",
"build:node": "vite build",
"build:browser": "vite build --config vite.browser.config.ts",
"test": "vitest --run",
"typecheck": "tsgo -b && tsc-strict"
},

View File

@@ -18,5 +18,12 @@
},
"references": [{ "path": "../crdt" }, { "path": "../loot-core" }],
"include": ["."],
"exclude": ["**/node_modules/*", "dist", "@types", "*.test.ts", "*.config.ts"]
"exclude": [
"**/node_modules/*",
"dist",
"@types",
"*.test.ts",
"*.config.ts",
"*.browser.config.ts"
]
}

View File

@@ -0,0 +1,26 @@
import path from 'path';
import { defineConfig } from 'vite';
import peggyLoader from 'vite-plugin-peggy-loader';
const distDir = path.resolve(__dirname, 'dist');
export default defineConfig({
build: {
target: 'esnext',
outDir: distDir,
emptyOutDir: false,
sourcemap: true,
lib: {
entry: path.resolve(__dirname, 'index.web.ts'),
formats: ['es'],
fileName: () => 'browser.js',
},
},
plugins: [peggyLoader()],
resolve: {
// Default extensions — picks up browser implementations (index.ts)
// instead of .api.ts (which resolves to Node.js/Electron code)
extensions: ['.js', '.ts', '.tsx', '.json'],
},
});

View File

@@ -83,7 +83,7 @@
"@rschedule/json-tools": "^1.5.0",
"@rschedule/standard-date-adapter": "^1.5.0",
"absurd-sql": "0.0.54",
"adm-zip": "patch:adm-zip@npm%3A0.5.16#~/.yarn/patches/adm-zip-npm-0.5.16-4556fea098.patch",
"adm-zip": "^0.5.16",
"better-sqlite3": "^12.6.2",
"csv-parse": "^6.1.0",
"csv-stringify": "^6.6.0",

View File

@@ -0,0 +1,6 @@
---
category: Bugfixes
authors: [MatissJanis]
---
Fix adm-zip dependency resolution in `@actual-app/core`

View File

@@ -95,7 +95,7 @@ __metadata:
"@types/pegjs": "npm:^0.10.6"
"@typescript/native-preview": "npm:^7.0.0-dev.20260309.1"
absurd-sql: "npm:0.0.54"
adm-zip: "patch:adm-zip@npm%3A0.5.16#~/.yarn/patches/adm-zip-npm-0.5.16-4556fea098.patch"
adm-zip: "npm:^0.5.16"
assert: "npm:^2.1.0"
better-sqlite3: "npm:^12.6.2"
browserify-zlib: "npm:^0.2.0"
@@ -11343,13 +11343,6 @@ __metadata:
languageName: node
linkType: hard
"adm-zip@npm:0.5.10":
version: 0.5.10
resolution: "adm-zip@npm:0.5.10"
checksum: 10/c5ab79b77114d8277f0cbfd6cca830198d6c7ee4971f6960f48e08cd2375953b11dc71729b7f396abd51d2d6cce8c862fad185ea90cb2c84ab5161c37ed1b099
languageName: node
linkType: hard
"adm-zip@npm:0.5.16":
version: 0.5.16
resolution: "adm-zip@npm:0.5.16"