Sprint 25: qwik.dev — ES Module fallback: document is not defined #87

Closed
opened 2026-06-18 20:37:50 +00:00 by Artur · 2 comments
Owner

Problembeschreibung

qwik.dev hat 3 uncaught Errors im Crawl. Einer davon: Beim Fallback eines ES Module Imports crasht das Modul mit document is not defined.

Crawl-Output:

[ExecutionRealm] URL module load failed for https://qwik.dev/build/q-naDMFAHy.js,
falling back to inline: ReferenceError: document is not defined

Interpretation: Das Modul q-naDMFAHy.js wird vom CDN geladen (via Bun Plugin), der Plugin versucht es als data: URL zu laden. Wenn das fehlschlägt, wird der Inhalt via executeRaw() als Classic-Script ausgeführt. Aber das Script enthält import/export Statements → der klassische Modus kann document nicht auflösen → ReferenceError.

Aktuelle Architektur

executeModule(url, code):
  1. Versuche native import(url) via Bun Plugin
     → Plugin resolved zu data:text/javascript;base64,...
     → Bun importiert
  2. Bei Fehler: Fallback auf executeRaw() (classic)
     → Script enthält import/export
     → ReferenceError: document is not defined

Option A: Fallback auf Temp-File statt executeRaw()

Kombiniert mit Sprint 22 (NameTooLong): Statt executeRaw() im Fallback den Modul-Code in eine .mjs Temp-Datei schreiben und per import("file:///tmp/...") laden.

Vorteile: Löst sowohl NameTooLong als auch document-is-not-defined.

Option B: ES Module Shim vor Fallback

Vor executeRaw() einen minimalen ES Module Shim injecten: var exports = {}; var module = { exports: exports }; plus import/export transpilen.

Abgelehnt — transpiling von 100KB+ Bundles ist zu teuer.

Option C: Error-Handling verbessern

Akzeptieren dass einige Module nicht fallback-executed werden können, und den Error sauber ans Error-Reporting weitergeben.

Notlösung — qwik.dev hat 177KB DOM trotz der Errors (Haupt-App läuft). Nur Sub-Module crashen.

Vorschlag: Als Sprint 22 Sub-Task implementieren

Wenn Sprint 22 (Temp-File) implementiert ist, löst sich dieses Issue automatisch:

  • NameTooLong → Temp-File statt data: URL
  • Module Fallback → Temp-File statt executeRaw
  • document is not defined → import() via Temp-File hat document im Scope

Akzeptanzkriterien:

  • qwik.dev 0 uncaught errors
  • Kein document is not defined im Fallback
  • 177KB+ DOM bleibt erhalten
## Problembeschreibung qwik.dev hat 3 uncaught Errors im Crawl. Einer davon: Beim Fallback eines ES Module Imports crasht das Modul mit `document is not defined`. **Crawl-Output:** ``` [ExecutionRealm] URL module load failed for https://qwik.dev/build/q-naDMFAHy.js, falling back to inline: ReferenceError: document is not defined ``` **Interpretation:** Das Modul `q-naDMFAHy.js` wird vom CDN geladen (via Bun Plugin), der Plugin versucht es als data: URL zu laden. Wenn das fehlschlägt, wird der Inhalt via `executeRaw()` als Classic-Script ausgeführt. Aber das Script enthält `import`/`export` Statements → der klassische Modus kann `document` nicht auflösen → ReferenceError. ## Aktuelle Architektur ``` executeModule(url, code): 1. Versuche native import(url) via Bun Plugin → Plugin resolved zu data:text/javascript;base64,... → Bun importiert 2. Bei Fehler: Fallback auf executeRaw() (classic) → Script enthält import/export → ReferenceError: document is not defined ``` ## Option A: Fallback auf Temp-File statt `executeRaw()` Kombiniert mit Sprint 22 (NameTooLong): Statt `executeRaw()` im Fallback den Modul-Code in eine `.mjs` Temp-Datei schreiben und per `import("file:///tmp/...")` laden. **Vorteile:** Löst sowohl NameTooLong als auch document-is-not-defined. ## Option B: ES Module Shim vor Fallback Vor `executeRaw()` einen minimalen ES Module Shim injecten: `var exports = {}; var module = { exports: exports };` plus import/export transpilen. **Abgelehnt** — transpiling von 100KB+ Bundles ist zu teuer. ## Option C: Error-Handling verbessern Akzeptieren dass einige Module nicht fallback-executed werden können, und den Error sauber ans Error-Reporting weitergeben. **Notlösung** — qwik.dev hat 177KB DOM trotz der Errors (Haupt-App läuft). Nur Sub-Module crashen. ## Vorschlag: Als Sprint 22 Sub-Task implementieren Wenn Sprint 22 (Temp-File) implementiert ist, löst sich dieses Issue automatisch: - NameTooLong → Temp-File statt data: URL - Module Fallback → Temp-File statt executeRaw - document is not defined → import() via Temp-File hat document im Scope **Akzeptanzkriterien:** - [ ] qwik.dev 0 uncaught errors - [ ] Kein `document is not defined` im Fallback - [ ] 177KB+ DOM bleibt erhalten
Author
Owner

Test comment - ignore

Test comment - ignore
Author
Owner

Status: Crash gefixt — Spec fehlt noch

Der akute document is not defined-Crash im Fallback ist gefixt (seit Sprint 22-23). Aktueller Code nutzt _loadFromBase64() / _loadFromBlobURL() statt executeRaw() für Module-Fallback — import() hat document im Scope.

Was noch fehlt (kompletter ES Module Spec-Stack):

  • Live Bindings — Object.assign(win, mod) kopiert Werte statt Live-Referenzen
  • Module Map — URL-basiertes Dedup (aktuell Hash-basiert)
  • import.meta.url, .resolve()
  • Dynamic import() im Proxy-Realm — aktuell entweicht aus dem Sandbox
  • Circular Dependency Resolution

→ Wird in einem neuen Issue als kompletter ES Module Spec-Stack adressiert.

## Status: Crash gefixt — Spec fehlt noch Der akute `document is not defined`-Crash im Fallback **ist gefixt** (seit Sprint 22-23). Aktueller Code nutzt `_loadFromBase64()` / `_loadFromBlobURL()` statt `executeRaw()` für Module-Fallback — `import()` hat `document` im Scope. **Was noch fehlt (kompletter ES Module Spec-Stack):** - Live Bindings — `Object.assign(win, mod)` kopiert Werte statt Live-Referenzen - Module Map — URL-basiertes Dedup (aktuell Hash-basiert) - `import.meta` — `.url`, `.resolve()` - Dynamic `import()` im Proxy-Realm — aktuell entweicht aus dem Sandbox - Circular Dependency Resolution → Wird in einem neuen Issue als kompletter ES Module Spec-Stack adressiert.
Artur closed this issue 2026-06-19 10:57:39 +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#87
No description provided.