mirror of
https://github.com/actualbudget/actual.git
synced 2026-07-25 05:54:03 -05:00
* [AI] Reduce dependencies (lodash, ua-parser-js, memoize-one, promise-retry, resize-observer polyfill) Remove or replace several low-usage / native-coverable dependencies to shrink the dependency surface and transitive deps: - lodash -> es-toolkit (es-toolkit/compat) for the 5 functions in use (debounce, keyBy, isMatch, isEqual, uniqueId) - ua-parser-js -> inline UA regex checks in loot-core shared/platform - memoize-one -> small local memoizeOne helper in loot-core shared - promise-retry -> small local retry helper (loot-core shared + a local copy in desktop-electron, which loads compiled JS at runtime) - @juggle/resize-observer polyfill removed; native ResizeObserver is supported by all current targets uuid was intentionally left untouched: crypto.randomUUID is only available in secure contexts, which would break self-hosted instances served over plain HTTP (including loot-core code running in the browser web worker). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JdZrw7VVwyF6VJgb34U9Qo * [AI] Use es-toolkit main entry for keyBy in report spreadsheets The two report spreadsheet files only used keyBy from es-toolkit/compat. Switch them to the lighter main es-toolkit entry (which takes a key function instead of a string), so these chunks no longer pull in the compat layer. Runtime behavior is identical. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JdZrw7VVwyF6VJgb34U9Qo * [AI] Rename release note to slug and reword for readability Rename the dependency-reduction release note from the guessed PR number to a descriptive slug, and reword the body to read clearly as changelog content. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JdZrw7VVwyF6VJgb34U9Qo * [AI] Shorten release note wording Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JdZrw7VVwyF6VJgb34U9Qo * [AI] Harden retry helper against sync throws; simplify memoizeOne typing - retry: run fn inside a promise chain so synchronous throws (and synchronous retry() calls) are routed through the rejection handler instead of escaping uncaught. Applied to both loot-core and desktop-electron copies. - memoizeOne: use separate Args/Result generics and drop the `as T` cast. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JdZrw7VVwyF6VJgb34U9Qo * [AI] Update yarn.lock after merge and install Co-authored-by: Matiss Janis Aboltins <MatissJanis@users.noreply.github.com> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Matiss Janis Aboltins <MatissJanis@users.noreply.github.com>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { retry as promiseRetry } from './retry';
|
|
|
|
const BACKEND_IMPORT_MAX_RETRIES = 30;
|
|
|
|
const lazyLoadBackend = async (isDev: boolean) => {
|
|
if (process.env.lootCoreScript === undefined) {
|
|
throw new Error(
|
|
'The environment variable `lootCoreScript` is not defined. Please define it to point to the server bundle.',
|
|
);
|
|
}
|
|
|
|
try {
|
|
// These retries are primarily for dev mode, where we watch for changes in loot-core
|
|
// In a packaged build this should always work the first time.
|
|
const bundle = await promiseRetry(
|
|
async (retry, number) => {
|
|
try {
|
|
return await import(process.env.lootCoreScript!);
|
|
} catch (error) {
|
|
console.info(
|
|
`Loading server bundle: Attempt ${number} of ${BACKEND_IMPORT_MAX_RETRIES}`,
|
|
);
|
|
|
|
retry(error);
|
|
}
|
|
},
|
|
{
|
|
retries: BACKEND_IMPORT_MAX_RETRIES,
|
|
minTimeout: 1000,
|
|
maxTimeout: 1000,
|
|
factor: 1, // No exponential backoff
|
|
},
|
|
);
|
|
bundle.initApp(isDev);
|
|
} catch (error) {
|
|
console.error('Failed to init the server bundle after all retries:', error);
|
|
throw new Error(
|
|
`Failed to init the server bundle after all retries: ${String(error)}`,
|
|
);
|
|
}
|
|
};
|
|
|
|
const isDev = false;
|
|
|
|
// Start the app
|
|
void lazyLoadBackend(isDev);
|