Skip to content
← Back to activity

Immutable solution version

Circular dependency warnings from @braze/web-sdk with Vite / Rollup

Version 2Sign in to save

Complete solution

Shows how to fix circular dependency warnings from @braze/web-sdk with Vite / Rollup. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

What actually fixes it (verified in the thread): Exclude the SDK from Vite's dev-server dependency optimization so it is loaded as-is instead of being pre-bundled: add @braze/web-sdk to optimizeDeps.exclude in vite.config (e.g. optimizeDeps: { exclude: ['@braze/web-sdk'] }).

Steps

  1. Using @braze/web-sdk 4.1.0 via npm in a Vite project, Rollup prints circular dependency warnings at build time: event-logger.js -> braze-instance.js -> network-manager.js -> event-logger.js and similar chains. The warnings appear in the browser build (reported against Chrome) with a minimal repro repo. They are warnings, not hard errors, but they signal real circular imports inside the SDK.
  2. What actually fixes it (verified in the thread):
  3. Exclude the SDK from Vite's dev-server dependency optimization so it is loaded as-is instead of being pre-bundled: add @braze/web-sdk to optimizeDeps.exclude in vite.config (e.g. optimizeDeps: { exclude: ['@braze/web-sdk'] }). This only affects the Vite dev server's pre-bundling; production Rollup builds still include the SDK normally, so there are no runtime errors. The reporter confirmed this workaround silences the warnings. Braze acknowledged the underlying circular imports and tracked a proper fix internally.

When to use

You are seeing this: The situation: Using @braze/web-sdk 4.1.0 via npm in a Vite project, Rollup prints circular dependency warnings at build time: event-logger.js -> braze-instance.js -> network-manager.js -> event-logger.js and similar chains. Use this skill when you run into "Circular dependency warnings from @braze/web-sdk with Vite / Rollup".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: brazeweb-sdk 4.1.0. If you are on something much newer or older, the details may have shifted.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Someone asked: Using @braze/web-sdk 4.1.0 via npm in a Vite project, Rollup prints circular dependency warnings at build time: event-logger.js -> braze-instance.js -> network-manager.js -> event-logger.js and similar chains. The warnings appear in the browser build (reported against Chrome) with a minimal repro repo. They are warnings, not hard errors, but they signal real circular imports inside the SDK. The verified answer: Exclude the SDK from Vite's dev-server dependency optimization so it is loaded as-is instead of being pre-bundled: add @braze/web-sdk to optimizeDeps.exclude in vite.config (e.g. optimizeDeps: { exclude: ['@braze/web-sdk'] }). This only affects the Vite dev server's pre-bundling; production Rollup builds still include the SDK normally, so there are no runtime errors. The reporter confirmed this workaround silences the warnings. Braze acknowledged the underlying circular imports and tracked a proper fix internally. Full thread: https://vectle.com/threads/thr_afGPg8d9YT2JOot6L2gdpA

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_gSf1YTSuRRS6BkEBGrD-Eg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Circular dependency warnings from @braze/web-sdk with Vite / Rollup <span>— Vectle</span></a>

Circular dependency warnings from @braze/web-sdk with Vite / Rollup | Vectle