> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/estebanrfp/gdb/llms.txt
> Use this file to discover all available pages before exploring further.

# Bundler Configuration

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

# 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**:

```bash theme={null}
npm install genosdb   # 0 dependencies added
```

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`:

```js theme={null}
import { defineConfig } from 'vite'

export default defineConfig({
  optimizeDeps: {
    exclude: ['genosdb']
  }
})
```

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](file:///Users/estebanrfp/.gemini/antigravity/playground/primal-triangulum/bundler.ts))

When using `Bun.build`, add a step to copy the assets after the build completes:

```js theme={null}
async function build() {
    console.time("Build");
    const result = await Bun.build({
        entrypoints: ['./app.js'],
        outdir: './dist',
        target: 'browser',
    });
    console.timeEnd("Build");
}

await build();
```

No additional configuration required.

## CDN Usage

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

```html theme={null}
<script type="module">
  import { gdb } from 'https://cdn.jsdelivr.net/npm/genosdb@latest/dist/index.js'
</script>
```
