Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940// A napi-rs package's wasm32-wasi binding loading and running in the runtime: the// installer picks it (it installs as a wasm32 linux), the package's own loader falls// back to it, and the binding runs on node:wasi and emnapi. tailwind's oxide is the// case: tests/fixtures/wasm32-oxide is npm's own lockfile for it under --cpu wasm32.import { readFileSync } from "node:fs";import { test, expect } from "@playwright/test";import type { Kernel } from "../src/host/index";import { cacheTarballs } from "./tarball-cache";
declare global { interface Window { __runtime?: Kernel }}
test.beforeEach(async ({ context }) => cacheTarballs(context));
test("tailwind's oxide loads its wasm32-wasi binding and scans a file's candidates", async ({ page }) => { await page.goto("/demo/fixture.html"); await page.waitForFunction(() => window.__runtime !== undefined, undefined, { timeout: 20_000 }); const lock = readFileSync("tests/fixtures/wasm32-oxide/package-lock.json", "utf8"); const res = await page.evaluate(async (lock) => { const runtime = window.__runtime!; runtime.writeTree({ "/app/package-lock.json": lock, "/app/src/index.html": '<div class="flex p-4"></div>', "/app/main.cjs": [ 'const { Scanner } = require("@tailwindcss/oxide");', 'const scanner = new Scanner({ sources: [{ base: "/app/src", pattern: "**/*", negated: false }] });', "console.log(JSON.stringify(scanner.scan()));", ].join("\n"), }); await runtime.install(); const proc = runtime.exec("/app/main.cjs", { cwd: "/app" }); const dec = new TextDecoder(); let stdout = ""; await Promise.all([proc.stdout.pipeTo(new WritableStream({ write: (c) => { stdout += dec.decode(c); } })), proc.exited]); return { code: await proc.exited, stdout }; }, lock); expect(res).toEqual({ code: 0, stdout: '["class","flex","p-4"]\n' });});