The #encryptForGithub method used an inline dynamic import
with a SodiumFull type downcast and default-export fallback
to work around webpack's immutable ESM namespace. The library
(0.8.x) provides its own types that cover crypto_box_seal as
a named export, so the workaround is unnecessary.
Replace with a top-level default import and await sodium.ready
at the call site. Add allowSyntheticDefaultImports to tsconfig
so TypeScript accepts the default import from the CJS types.
Remove the deprecated @types/libsodium-wrappers stub (the
library ships its own type definitions).
Note: libsodium is now bundled eagerly instead of lazy-loaded,
adding ~100 KiB to the main vendor chunk. Total bundle size
is unchanged.
Signed-off-by: Matej Vašek <matejvasek@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Summary
import('libsodium-wrappers')inGithubService.#encryptForGithubwith a top-level default importSodiumFulltype alias, double type cast, and runtimetypeofguardallowSyntheticDefaultImportsto tsconfig for CJS default import compatibility@types/libsodium-wrappersstub (library ships its own types)Detail
The
#encryptForGithubmethod used a dynamic import with a customSodiumFullintersection type and a(mod as unknown as { default?: SodiumFull }).default ?? modfallback to work around webpack freezing the ESM namespace object (which prevented crypto functions from being populated after WASM init). Importing the default export directly avoids the immutable namespace entirely, so the workaround is no longer needed.The method body goes from 17 lines to 5.
libsodium is now bundled eagerly instead of lazy-loaded, adding ~100 KiB to the main vendor chunk. Total bundle size is unchanged.
Test plan
yarn cipasses (lint, 126 tests, webpack build)crypto_box_seal not foundwarning fromimport *is gone)🤖 Generated with Claude Code