Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

desktop-external-packages.ts

31 lines1.1 KB

1/**
2 * Both `apps/desktop/vite.config.ts` and the artifact stage in
3 * scripts/build-desktop-artifact.ts derive from this list, so a package that is
4 * external is also the only kind of package the staged production install
5 * carries.
6 */
7export const DESKTOP_RUNTIME_EXTERNAL_PREFIXES = [
8 // Native addons and the wrappers that dlopen them by real path.
9 "@napi-rs/keyring",
10 "@crowecawcaw/xa11y",
11 "@clerk/electron-passkeys",
12 "electron-webauthn",
13 "ffi-rs",
14 "@yuuang/",
15 // Reads its own bundle from disk by resolving `playwright-core/package.json`
16 // at runtime and ships the browser driver alongside; there is nothing to
17 // gain from inlining a 10 MB file the code re-reads as text.
18 "playwright-core",
19] as const;
20​
21export function isDesktopRuntimeExternalDependency(id: string): boolean {
22 return DESKTOP_RUNTIME_EXTERNAL_PREFIXES.some((prefix) => id.startsWith(prefix));
24​
25export function selectDesktopRuntimeExternalDependencies(
26 dependencies: Readonly<Record<string, string>>,
27): Record<string, string> {
28 return Object.fromEntries(
29 Object.entries(dependencies).filter(([name]) => isDesktopRuntimeExternalDependency(name)),
30 );