Skip to content

A local-first personal finance app

[AI] sync server changes; crdt & et al (#7702)

Matiss Janis Aboltinsa95c0ad9b0c7
diff --git a/.oxlintrc.json b/.oxlintrc.json
index e02699ec0c..c0e2a45e1d 100644
--- a/.oxlintrc.json
+++ b/.oxlintrc.json
@@ -15,7 +15,8 @@
"vi": "readonly",
"backend": "readonly",
"importScripts": "readonly",
- "FS": "readonly"
+ "FS": "readonly",
+ "__APP_VERSION__": "readonly"
},
"rules": {
// Import sorting
diff --git a/package.json b/package.json
index 78f181099e..cffbe1c0b0 100644
--- a/package.json
+++ b/package.json
@@ -52,7 +52,7 @@
"playwright": "yarn workspace @actual-app/web run playwright",
"vrt": "yarn workspace @actual-app/web run vrt",
"vrt:docker": "./bin/run-vrt",
- "rebuild-electron": "./node_modules/.bin/electron-rebuild -f -m ./packages/desktop-electron -o better-sqlite3,bcrypt",
+ "rebuild-electron": "./node_modules/.bin/electron-rebuild -m ./packages/desktop-electron -o better-sqlite3,bcrypt --build-from-source -f",
"rebuild-node": "yarn workspace @actual-app/core rebuild",
"lint": "oxfmt --check . && oxlint --type-aware --quiet",
"lint:fix": "oxfmt . && oxlint --fix --type-aware --quiet",
diff --git a/packages/crdt/package.json b/packages/crdt/package.json
index 9bb77abdd4..d9217d9673 100644
--- a/packages/crdt/package.json
+++ b/packages/crdt/package.json
@@ -10,14 +10,10 @@
"!dist/**/*.spec.d.ts",
"!dist/**/*.spec.d.ts.map"
],
- "main": "dist/index.js",
- "types": "dist/index.d.ts",
+ "main": "src/index.ts",
+ "types": "src/index.ts",
"exports": {
- ".": {
- "types": "./dist/index.d.ts",
- "development": "./src/index.ts",
- "default": "./dist/index.js"
- }
+ ".": "./src/index.ts"
},
"publishConfig": {
"exports": {
@@ -25,7 +21,9 @@
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
- }
+ },
+ "main": "dist/index.js",
+ "types": "dist/index.d.ts"
},
"scripts": {
"build:node": "vite build",
diff --git a/packages/crdt/tsconfig.json b/packages/crdt/tsconfig.json
index 9da5b3d6a4..e436410883 100644
--- a/packages/crdt/tsconfig.json
+++ b/packages/crdt/tsconfig.json
@@ -4,8 +4,8 @@
"rootDir": "./src",
"composite": true,
"target": "ES2021",
- "module": "NodeNext",
- "moduleResolution": "NodeNext",
+ "module": "ES2022",
+ "moduleResolution": "bundler",
"noEmit": false,
"emitDeclarationOnly": true,
"declaration": true,
diff --git a/packages/desktop-client/src/browser-preload.js b/packages/desktop-client/src/browser-preload.js
index 305e091057..c91e93a6ac 100644
--- a/packages/desktop-client/src/browser-preload.js
+++ b/packages/desktop-client/src/browser-preload.js
@@ -335,10 +335,17 @@ const isUpdateReadyForDownloadPromise = new Promise(resolve => {
resolve(true);
};
});
-const updateSW = registerSW({
- immediate: true,
- onNeedRefresh: markUpdateReadyForDownload,
-});
+// Skip SW registration in dev so stale cached assets don't override edits
+// between page loads. Plugin code that needs a SW can register one itself.
+// In dev there is no SW to install, so applyAppUpdate() can't rely on the
+// SW lifecycle to swap the page — fall back to a plain reload so callers
+// don't hang on the never-resolving promise inside applyAppUpdate.
+const updateSW = IS_DEV
+ ? () => window.location.reload()
+ : registerSW({
+ immediate: true,
+ onNeedRefresh: markUpdateReadyForDownload,
+ });
global.Actual = {
IS_DEV,
diff --git a/packages/desktop-client/vite.config.mts b/packages/desktop-client/vite.config.mts
index 6e19f41b99..5a5200088e 100644
--- a/packages/desktop-client/vite.config.mts
+++ b/packages/desktop-client/vite.config.mts
@@ -376,7 +376,9 @@ export default defineConfig(async ({ mode, command }) => {
// swSrc: `service-worker/plugin-sw.js`,
// },
devOptions: {
- enabled: true, // We need service worker in dev mode to work with plugins
+ // Disabled: caches stale assets across reloads in dev. Plugin
+ // code that explicitly needs a SW can register one itself.
+ enabled: false,
type: 'module',
},
workbox: {
diff --git a/packages/desktop-electron/index.ts b/packages/desktop-electron/index.ts
index 9a67d5c59a..782fd586a4 100644
--- a/packages/desktop-electron/index.ts
+++ b/packages/desktop-electron/index.ts
@@ -239,12 +239,11 @@ async function startSyncServer() {
),
};
- const serverPath = path.join(
- // require.resolve will recursively search up the workspace for the module
- path.dirname(require.resolve('@actual-app/sync-server/package.json')),
- 'build',
- 'app.js',
+ // require.resolve will recursively search up the workspace for the module
+ const syncServerRoot = path.dirname(
+ require.resolve('@actual-app/sync-server/package.json'),
);
+ const serverPath = path.join(syncServerRoot, 'build/app.js');
const webRoot = path.join(
// require.resolve will recursively search up the workspace for the module
diff --git a/packages/sync-server/bin/actual-server.js b/packages/sync-server/bin/actual-server.js
index 7797119c09..6d1a269c73 100755
--- a/packages/sync-server/bin/actual-server.js
+++ b/packages/sync-server/bin/actual-server.js
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import { existsSync, readFileSync } from 'node:fs';
-import { dirname, resolve } from 'node:path';
-import { fileURLToPath } from 'node:url';
+import { resolve } from 'node:path';
import { parseArgs } from 'node:util';
const args = process.argv;
@@ -54,11 +53,7 @@ if (values.help) {
}
if (values.version) {
- const __dirname = dirname(fileURLToPath(import.meta.url));
- const packageJsonPath = resolve(__dirname, '../../package.json');
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
-
- console.log('v' + packageJson.version);
+ console.log('v' + __APP_VERSION__);
process.exit();
}
diff --git a/packages/sync-server/bin/add-import-extensions.mjs b/packages/sync-server/bin/add-import-extensions.mjs
deleted file mode 100644
index 40721fa839..0000000000
--- a/packages/sync-server/bin/add-import-extensions.mjs
+++ /dev/null
@@ -1,146 +0,0 @@
-#!/usr/bin/env node
-import { existsSync, readFileSync } from 'node:fs';
-import { readdir, readFile, writeFile } from 'node:fs/promises';
-import { dirname, extname, join, relative, resolve } from 'node:path';
-import { fileURLToPath } from 'node:url';
-
-const __filename = fileURLToPath(import.meta.url);
-const __dirname = dirname(__filename);
-
-const buildDir = resolve(__dirname, '../build');
-const packageRoot = resolve(__dirname, '..');
-
-const packageJson = JSON.parse(
- readFileSync(join(packageRoot, 'package.json'), 'utf-8'),
-);
-// publishConfig.imports already has ./build/src/ paths with .js extensions
-const importsMap = packageJson.publishConfig?.imports || {};
-
-// Sort wildcard patterns longest-prefix-first so more specific patterns
-// (e.g. #app-gocardless/services/tests/*) match before broader ones (#app-gocardless/*)
-const wildcardEntries = Object.entries(importsMap)
- .filter(([p]) => p.includes('*'))
- .sort(([a], [b]) => b.length - a.length);
-
-async function getAllJsFiles(dir) {
- const files = [];
- const entries = await readdir(dir, { withFileTypes: true });
-
- for (const entry of entries) {
- const fullPath = join(dir, entry.name);
- if (entry.isDirectory()) {
- files.push(...(await getAllJsFiles(fullPath)));
- } else if (entry.isFile() && extname(entry.name) === '.js') {
- files.push(fullPath);
- }
- }
-
- return files;
-}
-
-function resolveImportPath(importPath, fromFile) {
- const baseDir = dirname(fromFile);
- const resolvedPath = resolve(baseDir, importPath);
-
- // Check if it's a file with .js extension
- if (existsSync(`${resolvedPath}.js`)) {
- return `${importPath}.js`;
- }
-
- // Check if it's a directory with index.js
- if (existsSync(resolvedPath) && existsSync(join(resolvedPath, 'index.js'))) {
- return `${importPath}/index.js`;
- }
-
- // Verify the file exists before adding extension
- if (!existsSync(`${resolvedPath}.js`)) {
- console.warn(
- `Warning: Could not resolve import '${importPath}' from ${relative(buildDir, fromFile)}`,
- );
- }
-
- // Default: assume it's a file and add .js
- return `${importPath}.js`;
-}
-
-function toRelativePath(target, fromFile) {
- const absoluteTarget = resolve(packageRoot, target);
- let rel = relative(dirname(fromFile), absoluteTarget);
- if (!rel.startsWith('.')) rel = './' + rel;
- return rel.split('\\').join('/');
-}
-
-function resolveSubpathImport(importPath, fromFile) {
- if (importsMap[importPath]) {
- return toRelativePath(importsMap[importPath], fromFile);
- }
-
- for (const [pattern, target] of wildcardEntries) {
- const prefix = pattern.replaceAll('*', '');
- if (importPath.startsWith(prefix)) {
- const wildcard = importPath.slice(prefix.length);
- return toRelativePath(target.replaceAll('*', wildcard), fromFile);
- }
- }
-
- console.warn(
- `Warning: Could not resolve subpath import '${importPath}' from ${relative(buildDir, fromFile)}`,
- );
- return null;
-}
-
-function addExtensionsToImports(content, filePath) {
- const importRegex =
- /(?:import\s+(?:(?:\{[^}]*\}|\*\s+as\s+\w+|\w+)(?:\s*,\s*(?:\{[^}]*\}|\*\s+as\s+\w+|\w+))*\s+from\s+)?|import\s*\(|require\s*\()['"]((\.\.?\/[^'"]+)|(#[^'"]+))['"]/g;
-
- return content.replace(importRegex, (match, importPath) => {
- if (!importPath || typeof importPath !== 'string') {
- return match;
- }
-
- if (importPath.startsWith('#')) {
- const resolved = resolveSubpathImport(importPath, filePath);
- if (resolved) {
- return match.replace(importPath, resolved);
- }
- return match;
- }
-
- // Skip if already has an extension
- if (/\.(js|mjs|ts|mts|json)$/.test(importPath)) {
- return match;
- }
-
- // Skip if ends with / (directory import that already has trailing slash)
- if (importPath.endsWith('/')) {
- return match;
- }
-
- const newImportPath = resolveImportPath(importPath, filePath);
- return match.replace(importPath, newImportPath);
- });
-}
-
-async function processFile(filePath) {
- const content = await readFile(filePath, 'utf-8');
- const newContent = addExtensionsToImports(content, filePath);
-
- if (content !== newContent) {
- await writeFile(filePath, newContent, 'utf-8');
- const relativePath = relative(buildDir, filePath);
- console.log(`Updated imports in ${relativePath}`);
- }
-}
-
-async function main() {
- try {
- const files = await getAllJsFiles(buildDir);
- await Promise.all(files.map(processFile));
- console.log(`Processed ${files.length} files`);
- } catch (error) {
- console.error('Error processing files:', error);
- process.exit(1);
- }
-}
-
-void main();
diff --git a/packages/sync-server/loader.mjs b/packages/sync-server/loader.mjs
deleted file mode 100644
index b0e6c19f22..0000000000
--- a/packages/sync-server/loader.mjs
+++ /dev/null
@@ -1,26 +0,0 @@
-import { existsSync } from 'node:fs';
-import { dirname, extname, resolve as nodeResolve } from 'node:path';
-import { pathToFileURL } from 'node:url';
-
-const extensions = ['.ts', '.js', '.mts', '.mjs'];
-
-export async function resolve(specifier, context, nextResolve) {
- // Only handle relative imports without extensions
- if (specifier.startsWith('.') && !extname(specifier)) {
- const parentURL = context.parentURL;
- if (parentURL) {
- const parentPath = new URL(parentURL).pathname;
- const parentDir = dirname(parentPath);
-
- // Try extensions in order
- for (const ext of extensions) {
- const resolvedPath = nodeResolve(parentDir, `${specifier}${ext}`);
- if (existsSync(resolvedPath)) {
- return nextResolve(pathToFileURL(resolvedPath).href, context);
- }
- }
- }
- }
-
- return nextResolve(specifier, context);
-}
diff --git a/packages/sync-server/package.json b/packages/sync-server/package.json
index 9f534899f2..1ef2d11a16 100644
--- a/packages/sync-server/package.json
+++ b/packages/sync-server/package.json
@@ -74,20 +74,18 @@
}
},
"scripts": {
- "start": "yarn build && node build/app",
- "start-monitor": "nodemon --exec 'yarn build && node build/app' --ignore './build/**/*' --ext 'ts,js' build/app",
- "build": "tsgo -b && yarn add-import-extensions && yarn copy-static-assets",
+ "start": "yarn build && node build/app.js",
+ "start-monitor": "nodemon --exec 'yarn build && node build/app.js' --ignore './build/**/*' --ext 'ts,js' build/app.js",
+ "build": "vite build",
"typecheck": "tsgo -b && tsc-strict",
- "add-import-extensions": "node bin/add-import-extensions.mjs",
- "copy-static-assets": "rm -rf build/src/sql && cp -r src/sql build/src/sql",
- "test": "NODE_ENV=test NODE_OPTIONS='--experimental-vm-modules --import ./register-loader.mjs --trace-warnings' vitest --run",
- "db:migrate": "yarn build && cross-env NODE_ENV=development node build/src/scripts/run-migrations.js up",
- "db:downgrade": "yarn build && cross-env NODE_ENV=development node build/src/scripts/run-migrations.js down",
- "db:test-migrate": "yarn build && cross-env NODE_ENV=test node build/src/scripts/run-migrations.js up",
- "db:test-downgrade": "yarn build && cross-env NODE_ENV=test node build/src/scripts/run-migrations.js down",
- "reset-password": "yarn build && node build/src/scripts/reset-password.js",
- "disable-openid": "yarn build && node build/src/scripts/disable-openid.js",
- "health-check": "yarn build && node build/src/scripts/health-check.js"
+ "test": "NODE_ENV=test NODE_OPTIONS='--experimental-vm-modules --trace-warnings' vitest --run",
+ "db:migrate": "yarn build && cross-env NODE_ENV=development node build/scripts/run-migrations.js up",
+ "db:downgrade": "yarn build && cross-env NODE_ENV=development node build/scripts/run-migrations.js down",
+ "db:test-migrate": "yarn build && cross-env NODE_ENV=test node build/scripts/run-migrations.js up",
+ "db:test-downgrade": "yarn build && cross-env NODE_ENV=test node build/scripts/run-migrations.js down",
+ "reset-password": "yarn build && node build/scripts/reset-password.js",
+ "disable-openid": "yarn build && node build/scripts/disable-openid.js",
+ "health-check": "yarn build && node build/scripts/health-check.js"
},
"dependencies": {
"@actual-app/crdt": "workspace:*",
@@ -124,6 +122,7 @@
"nodemon": "^3.1.14",
"supertest": "^7.2.2",
"typescript-strict-plugin": "^2.4.4",
+ "vite": "^8.0.5",
"vitest": "^4.1.2"
},
"engines": {
diff --git a/packages/sync-server/register-loader.mjs b/packages/sync-server/register-loader.mjs
deleted file mode 100644
index 1e7fd4cc5e..0000000000
--- a/packages/sync-server/register-loader.mjs
+++ /dev/null
@@ -1,9 +0,0 @@
-import { register } from 'node:module';
-import { dirname, resolve } from 'node:path';
-import { fileURLToPath, pathToFileURL } from 'node:url';
-
-const __filename = fileURLToPath(import.meta.url);
-const __dirname = dirname(__filename);
-const loaderPath = resolve(__dirname, 'loader.mjs');
-
-register(pathToFileURL(loaderPath).href, pathToFileURL(__dirname));
diff --git a/packages/sync-server/src/app-gocardless/bank-factory.js b/packages/sync-server/src/app-gocardless/bank-factory.js
index 624bcc4d09..34cdd51082 100644
--- a/packages/sync-server/src/app-gocardless/bank-factory.js
+++ b/packages/sync-server/src/app-gocardless/bank-factory.js
@@ -1,22 +1,14 @@
-import fs from 'node:fs';
-import path from 'node:path';
-import { fileURLToPath, pathToFileURL } from 'node:url';
-
import IntegrationBank from './banks/integration-bank';
-const dirname = path.resolve(fileURLToPath(import.meta.url), '..');
-const banksDir = path.resolve(dirname, 'banks');
+// Filename convention: <name>_<bic>.{ts,js} (skips bank.interface,
+// integration-bank, and any other helper without an underscore).
+const bankLoaders = import.meta.glob('./banks/*_*.{ts,js}');
async function loadBanks() {
- const bankHandlers = fs
- .readdirSync(banksDir)
- .filter(filename => filename.includes('_') && filename.endsWith('.js'));
-
const imports = await Promise.all(
- bankHandlers.map(file => {
- const fileUrlToBank = pathToFileURL(path.resolve(banksDir, file)); // pathToFileURL for ESM compatibility
- return import(fileUrlToBank.toString()).then(handler => handler.default);
- }),
+ Object.values(bankLoaders).map(loader =>
+ loader().then(handler => handler.default),
+ ),
);
return imports;
diff --git a/packages/sync-server/src/app.ts b/packages/sync-server/src/app.ts
index 34204fc037..e171d4d83c 100644
--- a/packages/sync-server/src/app.ts
+++ b/packages/sync-server/src/app.ts
@@ -126,17 +126,32 @@ app.get('/metrics', (_req, res) => {
});
});
-// The web frontend
+// The web frontend.
+// Dev mode proxies to Vite, which injects inline preamble scripts and uses
+// a websocket for HMR. Loosen script-src and connect-src accordingly.
+// `'unsafe-eval'` is required at runtime for the Electron app, so it is
+// kept in both branches.
+const isDev = process.env.NODE_ENV === 'development';
+const scriptSrc = isDev
+ ? "'self' 'unsafe-inline' 'unsafe-eval' blob:"
+ : "'self' 'unsafe-eval' blob:";
+const connectSrc = isDev ? "'self' ws: wss: http: https:" : 'http: https:';
+const csp = [
+ "default-src 'self' blob:",
+ "img-src 'self' blob: data:",
+ `script-src ${scriptSrc}`,
+ "style-src 'self' 'unsafe-inline'",
+ "font-src 'self' data:",
+ `connect-src ${connectSrc}`,
+].join('; ');
+
app.use((req, res, next) => {
res.set('Cross-Origin-Opener-Policy', 'same-origin');
res.set('Cross-Origin-Embedder-Policy', 'require-corp');
- res.set(
- 'Content-Security-Policy',
- "default-src 'self' blob:; img-src 'self' blob: data:; script-src 'self' 'unsafe-eval' blob:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; connect-src http: https:;",
- );
+ res.set('Content-Security-Policy', csp);
next();
});
-if (process.env.NODE_ENV === 'development') {
+if (isDev) {
console.log(
'Running in development mode - Proxying frontend routes to React Dev Server',
);
diff --git a/packages/sync-server/src/load-config.js b/packages/sync-server/src/load-config.js
index 82183ce310..5ddf78437d 100644
--- a/packages/sync-server/src/load-config.js
+++ b/packages/sync-server/src/load-config.js
@@ -21,8 +21,6 @@ const defaultDataDir = process.env.ACTUAL_DATA_DIR
debug(`Project root: '${projectRoot}'`);
-export const sqlDir = path.join(__dirname, 'sql');
-
const actualAppWebBuildPath = path.join(
path.dirname(require.resolve('@actual-app/web/package.json')),
'build',
diff --git a/packages/sync-server/src/migrations.ts b/packages/sync-server/src/migrations.ts
index 0ded782bc9..7a653d6277 100644
--- a/packages/sync-server/src/migrations.ts
+++ b/packages/sync-server/src/migrations.ts
@@ -1,40 +1,34 @@
-import { readdir } from 'node:fs/promises';
-import path, { dirname } from 'node:path';
-import { fileURLToPath, pathToFileURL } from 'node:url';
+import path from 'node:path';
import { load } from 'migrate';
import { config } from './load-config';
type MigrationCallback = (err?: Error) => void;
+type MigrationModule = {
+ up: (next?: MigrationCallback) => void;
+ down: (next?: MigrationCallback) => void;
+};
+
+// Vite resolves this glob at build time and inlines a static map of
+// () => import('chunks/...js') calls. Each migration becomes its own chunk.
+// Runtime fs reads against a migrations/ directory disappear.
+const migrationsLoaders = import.meta.glob<MigrationModule>(
+ '../migrations/*.{ts,js}',
+);
export async function run(direction: 'up' | 'down' = 'up'): Promise<void> {
console.log(
`Checking if there are any migrations to run for direction "${direction}"...`,
);
- const __dirname = dirname(fileURLToPath(import.meta.url)); // this directory
- const migrationsDir = path.join(__dirname, '../migrations');
-
try {
- // Load all script files in the migrations directory
- const files = await readdir(migrationsDir);
- const migrationsModules: Record<
- string,
- {
- up: (next?: MigrationCallback) => void;
- down: (next?: MigrationCallback) => void;
- }
- > = {};
-
- for (const f of files
- .filter(
- f => (f.endsWith('.js') || f.endsWith('.ts')) && !f.endsWith('.d.ts'),
- )
- .sort((a, b) => (a > b ? 1 : a < b ? -1 : 0))) {
- migrationsModules[f] = await import(
- pathToFileURL(path.join(migrationsDir, f)).href
- );
+ const sortedKeys = Object.keys(migrationsLoaders).sort();
+ const migrationsModules: Record<string, MigrationModule> = {};
+
+ for (const key of sortedKeys) {
+ const fileName = key.split('/').pop()!;
+ migrationsModules[fileName] = await migrationsLoaders[key]();
}
return new Promise<void>((resolve, reject) => {
diff --git a/packages/sync-server/src/sync-simple.js b/packages/sync-server/src/sync-simple.js
index de8eb4a4e8..aa19edd7db 100644
--- a/packages/sync-server/src/sync-simple.js
+++ b/packages/sync-server/src/sync-simple.js
@@ -1,10 +1,9 @@
-import { existsSync, readFileSync } from 'node:fs';
-import { join } from 'node:path';
+import { existsSync } from 'node:fs';
import { merkle, SyncProtoBuf, Timestamp } from '@actual-app/crdt';
import { openDatabase } from './db';
-import { sqlDir } from './load-config';
+import messagesSql from './sql/messages.sql?raw';
import { getPathForGroupFile } from './util/paths';
function getGroupDb(groupId) {
@@ -14,8 +13,7 @@ function getGroupDb(groupId) {
const db = openDatabase(path);
if (needsInit) {
- const sql = readFileSync(join(sqlDir, 'messages.sql'), 'utf8');
- db.exec(sql);
+ db.exec(messagesSql);
}
return db;
diff --git a/packages/sync-server/vite.config.mts b/packages/sync-server/vite.config.mts
new file mode 100644
index 0000000000..89d2e663a2
--- /dev/null
+++ b/packages/sync-server/vite.config.mts
@@ -0,0 +1,73 @@
+import { readFileSync } from 'node:fs';
+import path from 'node:path';
+
+import { defineConfig } from 'vite';
+import type { Plugin } from 'vite';
+
+const pkg = JSON.parse(
+ readFileSync(path.resolve(__dirname, 'package.json'), 'utf-8'),
+);
+
+const shebangPlugin = (entryFile: string): Plugin => ({
+ name: 'sync-server-shebang',
+ generateBundle(_options, bundle) {
+ const chunk = bundle[entryFile];
+ if (chunk?.type === 'chunk' && !chunk.code.startsWith('#!')) {
+ chunk.code = `#!/usr/bin/env node\n${chunk.code}`;
+ }
+ },
+});
+
+export default defineConfig({
+ ssr: {
+ target: 'node',
+ // Inline workspace deps that ship as TS source. Anything else
+ // (express, better-sqlite3, bcrypt, @actual-app/web, etc.) stays
+ // external so Node resolves it at runtime.
+ noExternal: ['@actual-app/crdt'],
+ },
+ build: {
+ ssr: true,
+ target: 'node22',
+ outDir: path.resolve(__dirname, 'build'),
+ emptyOutDir: true,
+ sourcemap: true,
+ minify: false,
+ rollupOptions: {
+ input: {
+ app: path.resolve(__dirname, 'app.ts'),
+ 'bin/actual-server': path.resolve(__dirname, 'bin/actual-server.js'),
+ 'scripts/run-migrations': path.resolve(
+ __dirname,
+ 'src/scripts/run-migrations.js',
+ ),
+ 'scripts/reset-password': path.resolve(
+ __dirname,
+ 'src/scripts/reset-password.js',
+ ),
+ 'scripts/disable-openid': path.resolve(
+ __dirname,
+ 'src/scripts/disable-openid.js',
+ ),
+ 'scripts/enable-openid': path.resolve(
+ __dirname,
+ 'src/scripts/enable-openid.js',
+ ),
+ 'scripts/health-check': path.resolve(
+ __dirname,
+ 'src/scripts/health-check.js',
+ ),
+ },
+ output: {
+ format: 'esm',
+ entryFileNames: '[name].js',
+ chunkFileNames: 'chunks/[name]-[hash].js',
+ },
+ },
+ },
+ define: {
+ __APP_VERSION__: JSON.stringify(pkg.version),
+ },
+ assetsInclude: ['**/*.sql'],
+ plugins: [shebangPlugin('bin/actual-server.js')],
+});
diff --git a/upcoming-release-notes/7702.md b/upcoming-release-notes/7702.md
new file mode 100644
index 0000000000..d6f7aaf5b4
--- /dev/null
+++ b/upcoming-release-notes/7702.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [MatissJanis]
+---
+
+Refactor module resolution to load `@actual-app/crdt` from source during development.
diff --git a/yarn.lock b/yarn.lock
index e45f424cec..d8e18e58c8 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -209,6 +209,7 @@ __metadata:
supertest: "npm:^7.2.2"
typescript-strict-plugin: "npm:^2.4.4"
uuid: "npm:^14.0.0"
+ vite: "npm:^8.0.5"
vitest: "npm:^4.1.2"
winston: "npm:^3.19.0"
bin: