// PROVEN 2026-08-01 by the spike + Spencer's build. Measured evidence: // - main.tsx.js: 4352 KB -> 4446 KB (+94 KB - the loader shim + webpack's chunk-loading // runtime, NOT the SDK itself). // - 460.js emitted at 1241 KB and contains Chime (webpack id hint: vendors, [immutable]). // - Control: main.tsx.js does NOT contain the string `DefaultMeetingSession` - the SDK did // not leak into the main bundle. // - webpack's `Entrypoint main.tsx` lists only main.tsx.css, main.tsx.js, main.tsx-rtl.css, // main.tsx.asset.php - the Chime chunk (460.js) is absent from the entrypoint. // - Build exit 0, 2 warnings, both pre-existing asset-size warnings unrelated to this change. // This proves webpack emits a separate, loadable chunk and excludes it from the initial // entrypoint under WP's enqueue of build/main.tsx.js (publicPath 'auto' resolves against // document.currentScript, i.e. the plugin's own build dir). It does NOT prove the browser // actually fetches that chunk successfully at runtime - that closes the first time // loadChimeSdk() runs on a real page (Task 4+). Keep this the ONLY import site for the SDK. import type * as ChimeSdk from 'amazon-chime-sdk-js'; // Cache the PROMISE, not the resolved value: two callers racing before the first `await` // resolves must share one `import()`, not both trigger their own. let cachedPromise: Promise | null = null; export function loadChimeSdk(): Promise { cachedPromise ??= import('amazon-chime-sdk-js'); return cachedPromise; }