Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(build): stop Rollup folding the brownout import specifier and breaking the deploy

nirholasb948e1bc2081
diff --git a/src/shared/failover-fetch.js b/src/shared/failover-fetch.js
index 0272ce400..1e899ed8a 100644
--- a/src/shared/failover-fetch.js
+++ b/src/shared/failover-fetch.js
@@ -46,14 +46,20 @@ let _brownoutMod = null;
// `"AsyncLocalStorage" is not exported by "__vite-browser-external"` even though
// the guard above means a browser never evaluates it. Rollup resolves a string
// literal here regardless of @vite-ignore, and constant-folds a `const` holding
-// one, so the path is joined from parts: an expression no optimizer folds.
-// Node resolves it relative to this module, which is what the server needs.
-const BROWNOUT_SPECIFIER = ['..', '..', 'api', '_lib', 'brownout', 'index.js'].join('/');
+// one.
+//
+// A local `['..', 'api', …].join('/')` was the first attempt and it stopped
+// working: Rollup 4 folds that expression too, and the deploy build died again
+// on the same line. So the path is parked on `globalThis` and read back from a
+// member expression, which no bundler can evaluate at build time because it
+// cannot know what else may have written there. Node resolves the relative
+// specifier against THIS module, which is what the server needs.
+globalThis.__threewsBrownoutSpecifier ||= ['..', '..', 'api', '_lib', 'brownout', 'index.js'].join('/');
function brownout() {
if (_brownoutPromise !== undefined) return _brownoutPromise;
_brownoutPromise = null;
if (typeof window === 'undefined') {
- _brownoutPromise = import(/* @vite-ignore */ BROWNOUT_SPECIFIER)
+ _brownoutPromise = import(/* @vite-ignore */ globalThis.__threewsBrownoutSpecifier)
.then((m) => {
_brownoutMod = m;
return m;