Sprint 2: globalThis Sync in Sub-Module Resolution (_resolveSubModuleImports) #52

Closed
opened 2026-06-18 10:37:20 +00:00 by Artur · 1 comment
Owner

Problembeschreibung

executeModule() sync't proxy-window Properties nach globalThis vor import() — aber _resolveSubModuleImports() (für rekursiv geladene Sub-Modules) tut das nicht. Dadurch sehen tiefere Module keine Config-Variablen als Bare-Globals.

Betroffene Sites: vuejs.org (__VP_HASH_MAP__), discord.com (__OVERLAY__, GLOBAL_ENV), x.com (__INITIAL_STATE__)

Aktueller Code

executeModule() (execution-realm.ts ~L340):

// Sync proxy window properties to globalThis
for (const key of Object.keys(win)) {
  if (knownGlobals.has(key)) continue;
  const val = (win as any)[key];
  if (val !== undefined && val !== null) {
    try { (globalThis as any)[key] = val; } catch {}
  }
}

_resolveSubModuleImports() (execution-realm.ts ~L400) — KEIN Sync vorhanden.

Lösung

Den Sync-Code in _resolveSubModuleImports einbauen, vor dem Bun.write() der Sub-Module.

Akzeptanzkriterien

  • Sub-Modules sehen Proxy-Window-Properties als Bare-Globals
  • __VP_HASH_MAP__ ist in Sub-Modules von vuejs.org definiert
  • __INITIAL_STATE__ ist in Sub-Modules von x.com definiert
  • __OVERLAY__ ist in Sub-Modules von discord.com definiert

Betroffene Dateien

Datei Änderung
src/js/execution-realm.ts Sync-Code in _resolveSubModuleImports einfügen

Cross-Ref

  • Sprint 1 (a274576): Module Sub-Import Resolution
  • #37: Inline Scripts blockieren Module Execution
## Problembeschreibung `executeModule()` sync't proxy-window Properties nach `globalThis` vor `import()` — aber `_resolveSubModuleImports()` (für rekursiv geladene Sub-Modules) tut das nicht. Dadurch sehen tiefere Module keine Config-Variablen als Bare-Globals. **Betroffene Sites:** vuejs.org (`__VP_HASH_MAP__`), discord.com (`__OVERLAY__`, `GLOBAL_ENV`), x.com (`__INITIAL_STATE__`) ## Aktueller Code `executeModule()` (execution-realm.ts ~L340): ```typescript // Sync proxy window properties to globalThis for (const key of Object.keys(win)) { if (knownGlobals.has(key)) continue; const val = (win as any)[key]; if (val !== undefined && val !== null) { try { (globalThis as any)[key] = val; } catch {} } } ``` `_resolveSubModuleImports()` (execution-realm.ts ~L400) — **KEIN Sync vorhanden**. ## Lösung Den Sync-Code in `_resolveSubModuleImports` einbauen, vor dem `Bun.write()` der Sub-Module. ## Akzeptanzkriterien - [ ] Sub-Modules sehen Proxy-Window-Properties als Bare-Globals - [ ] `__VP_HASH_MAP__` ist in Sub-Modules von vuejs.org definiert - [ ] `__INITIAL_STATE__` ist in Sub-Modules von x.com definiert - [ ] `__OVERLAY__` ist in Sub-Modules von discord.com definiert ## Betroffene Dateien | Datei | Änderung | |-------|----------| | `src/js/execution-realm.ts` | Sync-Code in `_resolveSubModuleImports` einfügen | ## Cross-Ref - Sprint 1 (a274576): Module Sub-Import Resolution - #37: Inline Scripts blockieren Module Execution
Author
Owner

Implemented in 9fa5e83:

  • Extracted _syncGlobalsToGlobalThis() as shared private method
  • Called from executeModule() before import() — main module sees inline config
  • Called from _resolveSubModuleImports() before Bun.write() — sub-modules see inline config
  • Sync copies all non-standard proxy-window properties to globalThis (filters Bun/node globals)
  • Sub-module files get same module prologue + globalThis sync as main modules

Verified: window.__CFG__ set by inline script is visible as __CFG__ (bare global) inside type="module" scripts.

Implemented in 9fa5e83: - Extracted `_syncGlobalsToGlobalThis()` as shared private method - Called from `executeModule()` before `import()` — main module sees inline config - Called from `_resolveSubModuleImports()` before `Bun.write()` — sub-modules see inline config - Sync copies all non-standard proxy-window properties to `globalThis` (filters Bun/node globals) - Sub-module files get same module prologue + globalThis sync as main modules **Verified:** `window.__CFG__` set by inline script is visible as `__CFG__` (bare global) inside type="module" scripts.
Artur closed this issue 2026-06-18 10:38:12 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
glow-all/true-headless-browser#52
No description provided.