P0a: ES Module Execution — NameTooLong Fix + Dependency Resolution #74
Labels
No labels
bug
docs
feature
housekeeping
html-spec
performance
react-compat
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
glow-all/true-headless-browser#74
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
P0a: ES Module Execution — NameTooLong Bug + Dependency Resolution
Priority: CRITICAL
Betrifft: vuejs.org, solidjs.com, qwik.dev, angular.io, web.dev — alle VitePress/Vite-Sites
Impact: Framework-Seiten laden nur statisches HTML. App bootstrapped nie.
Problembeschreibung
executeModule()inexecution-realm.tslädt Module viadata:text/javascript,${encodeURIComponent(code)}.Zwei fundamentale Probleme:
Problem 1: NameTooLong
Bun's
import()wirftNameTooLongfür Vite-Bundles >~500KB (ein typischer VuePress/Vite-Bundle).encodeURIComponent()erzeugt extrem lange data:-URLs → Bun's URL-Parser bricht ab.Problem 2: Relative Import Resolution
Module mit
import { D } from "./chunks/runtime-core.esm-bundler.js"schlagen fehl, weildata:URLs keinen Base-Path haben. Relative Imports werden nicht aufgelöst.Aktuelles Verhalten
Lösungsansätze
Option A: File-Write statt data: URL (EMPFEHLUNG)
Vorteile:
Nachteile:
Option B: Base64-Encoding
Vorteile: Kürzer, kein NameTooLong mehr
Nachteile: Relative Imports funktionieren immer noch nicht
Option C: Bun Plugin für Module Resolution
Entscheidung
Option A + B kombiniert:
Akzeptanzkriterien
Betroffene Dateien
src/js/execution-realm.tstests/unit/sprint16-es-module.test.tsDependencies
Performance-Impact
✅ Sprint 16 implementiert — ES Module NameTooLong Fix
Was wurde gemacht:
executeModule(): Base64 stattencodeURIComponent()für data:-URLs (kürzer, kein NameTooLong)/tmp/thb-modules/<hash>.mjsschreiben +import(filePath)ensureModuleDir()Helper für/tmp/thb-modules/executeModuleStatic()Verbleibend (separates Issue):
./chunks/...relative Imports können nicht aufgelöst werden (data:/file: URLs haben keinen Base-Path)Commit:
eca1765✅ ES Module Dependency Resolution implementiert!
Neue Datei:
src/js/module-resolver.tsAnsatz: Bun Plugin der
import()-Aufrufe für ES Module interceptet:onResolve (
thb-module:Namespace +./relative/path):./chunks/foo.js→https://vuejs.org/assets/chunks/foo.jsonLoad (fetch vom CDN + Sandbox-Blockers):
fetch(url)→ Security Check → Content-Type Prüfungvar Bun = void 0; var process = void 0; ...Fallback-Strategie (3-stufig):
Ablauf:
script-loader.ts:executeRaw(type="module")→realm.executeModule(code, url)executeModule(url)→loadModuleFromUrl(url)→import("thb-module:https://...")import("./chunks/foo.js")→ onResolve resolved absolut → onLoad lädtCommit:
0204d41✅ Finale Implementierung: Source-Level Import Rewriting
Bun.plugin()interceptiert KEINE runtimeimport()-Aufrufe auf Bun 1.3.14.→ Alternative: Source-Code-Rewriting vor dem Base64-Encoding.
Was jetzt passiert:
executeModule(code, url)mit HTTP(S)-URL →_loadUrlModule(url)rewriteRelativeImports():import { X } from "./chunks/foo.js"→import { X } from "https://cdn/assets/chunks/foo.js"var Bun = void 0; var process = void 0; ...data:text/javascript;base64,...— keine Imports im Code mehrModule loading hierarchy:
Commit:
397e769