Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930// ESM acceptance proofs (ESM slice brief §Verification): guest ESM executes through// the browser's native module linker, fed by the Service Worker virtual origin.// 1. builtin facade (node:fs), ESM graph, CJS facade, exports-map package default// import, and file:/// import.meta.url — exit 0, no stderr// 2. a real import cycle (a↔b) where a binding is mutated after both modules// evaluate — the mutation must be observed live, which only the native linker// gives us (a transpiled value copy would keep the stale one)import { test, expect } from "@playwright/test";
test("guest ESM: builtin facade, ESM graph, CJS facade, package default, import.meta.url", async ({ page }) => { await page.goto("/demo/esm.html"); // The name comes from /app/name.txt (editable) — assert the shape, not the name. await expect(page.locator("#out")).toContainText(/Hello, .+!/, { timeout: 20_000 }); await expect(page.locator("#out")).toContainText("cjs-via-facade", { timeout: 20_000 }); await expect(page.locator("#out")).toContainText("file:///app/main.mjs", { timeout: 20_000 }); await expect(page.locator("#exit")).toHaveText("0", { timeout: 20_000 }); await expect(page.locator("#err")).toHaveText("");});
test("ESM cycle observes live-binding mutation through the native linker", async ({ page }) => { await page.goto("/demo/esm-cycle.html"); // Both reads come from the SAME call site (a's describe → b's bumpSeen): before // the mutation b-sees=init, after it b-sees=mutated — the binding is live. await expect(page.locator("#out")).toContainText( "a=init b-sees=init | a=mutated b-sees=mutated", { timeout: 20_000 }, ); await expect(page.locator("#exit")).toHaveText("0", { timeout: 20_000 }); await expect(page.locator("#err")).toHaveText("");});