diff --git a/src/utils/initClient.ts b/src/utils/initClient.ts index 12bfe8d24..ce0e7d988 100644 --- a/src/utils/initClient.ts +++ b/src/utils/initClient.ts @@ -17,13 +17,8 @@ import { import { type ISyncStateData, type SyncState } from "matrix-js-sdk/lib/sync"; import { logger } from "matrix-js-sdk/lib/logger"; -// This import is why `initClient` has a module of its own: -// - The bundler emits the worker file (11 MB: the Matrix SDK and its crypto -// wasm) the moment it loads this import — whether or not anything ever calls -// `new IndexedDBWorker()`. Tree shaking drops the call, not the file. -// - So it may only sit in a module the component build never loads. It used -// to be in `./matrix`, which the component reaches for the room URL helpers, -// and the worker shipped in the package, unused and unusable by any host. +// This import pulls in many MBs of SDK code and crypto WASM which should only +// be included in full SPA builds, which is why `initClient` gets its own module. import IndexedDBWorker from "../IndexedDBWorker?worker"; import { getUrlParams } from "../UrlParams"; import { Config } from "../config/Config"; diff --git a/src/utils/matrix.ts b/src/utils/matrix.ts index 5c10b1c3f..e1d32ee15 100644 --- a/src/utils/matrix.ts +++ b/src/utils/matrix.ts @@ -5,6 +5,8 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE in the repository root for full details. */ +// *Do not* import any client stores in this module, to keep the component +// build lean. import { ClientEvent, Preset, Visibility } from "matrix-js-sdk"; import { logger } from "matrix-js-sdk/lib/logger"; import { secureRandomBase64Url } from "matrix-js-sdk/lib/randomstring"; @@ -18,11 +20,6 @@ import { saveKeyForRoom, } from "../e2ee/sharedKeyManagement"; -// Shared with the component, which reaches this module for the room URLs. So -// nothing in here may import the client store worker: the bundler emits the -// worker file on loading the import, used or not. The one function that needs -// it, `initClient`, lives in `./initClient` for that reason. - export const fallbackICEServerAllowed = import.meta.env.VITE_FALLBACK_STUN_ALLOWED === "true";