Skip to main content

Bundler Configuration

GenosDB uses dynamic imports with import.meta.url for loading optional modules. Some bundlers may require additional configuration to handle this correctly.

Zero Runtime Dependencies

GenosDB publishes a self-contained bundle: the npm package ships only the pre-built dist/ files, with every build-time library (ethers, pako, @msgpack/msgpack, and the internal GenosRTC module) inlined at build time. Installing GenosDB therefore pulls no transitive npm dependencies:
This keeps the runtime attack surface minimal and aligned with GenosDB’s zero-trust design.
Note on npm audit: Tools like npm audit may report advisories for devDependencies (used only to build the project, e.g. the bundler toolchain). These never reach consumers, since they are not part of the published dist/ and their code is not present in the bundle.

Vite

If using Vite, add the following to your vite.config.js:
This tells Vite to skip pre-bundling GenosDB, allowing the dynamic imports to resolve correctly at runtime.

Production builds

exclude only affects the dev server. GenosDB resolves its own modules relative to itself (import.meta.url), so re-bundling it in a production build can leave those modules unemitted (404). Keep GenosDB’s dist/ intact in your output — ship it as a single folder and load GenosDB from that path — and set build.target: 'es2022' (GenosDB uses top-level await).

Webpack

No additional configuration is typically required for Webpack 5+.

esbuild / Bun

Bun Example (bundler.ts)

When using Bun.build, add a step to copy the assets after the build completes:
No additional configuration required.

CDN Usage

When loading GenosDB directly from a CDN, no bundler configuration is needed: