Files
Tom MoorandClaude Fable 5 67b53220ce perf: Limit PWA precache and skip service worker on share views (#13519)
* perf: Cache JS chunks on first use instead of precaching entire build

The service worker precached every JS chunk (~590 files) in the
background for every visitor. Chunks are content-hashed and immutable,
so a CacheFirst runtime route provides the same repeat-visit behavior
while only fetching chunks that are actually used.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* perf: Do not register service worker on public share views

Anonymous share visitors gain nothing from the worker or the PWA
cache, shares always require the API. The server now exposes an
isShare flag in window.env and the client skips registration when
it is set.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-21 20:54:30 -04:00

25 lines
793 B
TypeScript

import type { IntegrationType, PublicEnv } from "@shared/types";
import type { Environment } from "@server/env";
import type { Integration } from "@server/models";
// Note: This entire object is stringified in the HTML exposed to the client
// do not add anything here that should be a secret or password
export default function present(
env: Environment,
options: {
analytics?: Integration<IntegrationType.Analytics>[];
rootShareId?: string | null;
isShare?: boolean;
} = {}
): PublicEnv {
return {
ROOT_SHARE_ID: options.rootShareId || undefined,
isShare: options.isShare || undefined,
analytics: (options.analytics ?? []).map((integration) => ({
service: integration?.service,
settings: integration?.settings,
})),
...env.public,
};
}