cduss Claude Opus 4.7 commited on
Commit
813100e
·
1 Parent(s): bcd5ee8

Shim window.process for CDN-loaded host bundle

Browse files

mountHost's chunk references process.env.NODE_ENV expecting a
bundler-time substitution that doesn't happen when the file is loaded
raw from jsdelivr. Crashes on first execution with "process is not
defined". Tiny shim assigned before the module imports clears it.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

Files changed (1) hide show
  1. index.html +16 -0
index.html CHANGED
@@ -46,6 +46,22 @@
46
  })();
47
  </script>
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  <!-- Pre-paint visibility gate. Both paths start with #mainApp hidden:
50
  - Standalone: mountHost() owns the page; #mainApp stays hidden.
51
  - Embed: #mainApp is revealed by the embed handler once
 
46
  })();
47
  </script>
48
 
49
+ <!-- `process` shim for CDN-loaded ESM.
50
+ The host bundle (`host/dist/entry/auto.js`) was built expecting
51
+ a downstream bundler (Vite/Rollup) to substitute `process.env.NODE_ENV`
52
+ at build time. Loaded raw from jsdelivr that substitution never
53
+ happens, and the chunk crashes on first reference with
54
+ `ReferenceError: process is not defined`. A tiny shim assigned
55
+ BEFORE the module imports run resolves it. The double-`??=` keeps
56
+ us a polite citizen in case any later loader brings a real `process`.
57
+ (We DON'T need this when using a bundler — see the `dashboard/`
58
+ sibling app, where Vite handles the substitution.) -->
59
+ <script>
60
+ globalThis.process ??= { env: {} };
61
+ globalThis.process.env ??= {};
62
+ globalThis.process.env.NODE_ENV ??= 'production';
63
+ </script>
64
+
65
  <!-- Pre-paint visibility gate. Both paths start with #mainApp hidden:
66
  - Standalone: mountHost() owns the page; #mainApp stays hidden.
67
  - Embed: #mainApp is revealed by the embed handler once