fix(ui): make fixture bundle browser-safe, fast and cacheable
The UI fixture bundle crashed at runtime, so every test waited out its 45s timeout: - server-only modules leaked into the bundle and referenced node built-ins, the process global, and validated env at import time - the previous platform: 'node' fix kept esbuild happy but emitted require() calls that cannot run in the browser Fix it at the bundle boundary: - alias node:* imports to e2e/ui/node-stubs.mjs (shape-compatible stubs, no real I/O) - inject e2e/ui/process-shim.mjs for the process global - define process.env.SKIP_ENV_VALIDATION=1 so src/env.ts skips parsing in the fixture (same escape hatch vitest uses) Also make the fixture server fast to start: - build JS and Tailwind CSS in parallel - cache built assets in node_modules/.cache/nexst-ui-fixture keyed on a content hash of src/, fixtures, stubs and the server file - startup drops from ~1.7s to ~220ms on cache hits
This commit is contained in:
1 parent
c9b363d60d
commit
1dd584cd82
27 files changed
+334
-67
No files matched your search
@@ -0,0 +1,25 @@
|
||||
// Minimal `process` shim injected into the UI fixture bundle. Server-only
|
||||
// modules that leak into the bundle reference the `process` global at module
|
||||
// scope (release ids, paths, etc). esbuild's `inject` rewrites those free
|
||||
// identifier references to import from this file so evaluation cannot crash
|
||||
// in the browser.
|
||||
|
||||
export const process = {
|
||||
env: { NODE_ENV: "production" },
|
||||
platform: "linux",
|
||||
arch: "x64",
|
||||
version: "v20.0.0",
|
||||
versions: { node: "20.0.0" },
|
||||
argv: [],
|
||||
cwd: () => "/",
|
||||
nextTick: (fn, ...args) => setTimeout(() => fn(...args), 0),
|
||||
on: () => {},
|
||||
once: () => {},
|
||||
emit: () => {},
|
||||
exit: () => {},
|
||||
hrtime: Object.assign(() => [0, 0], { bigint: () => 0n }),
|
||||
memoryUsage: () => ({ heapUsed: 0, rss: 0 }),
|
||||
pid: 0,
|
||||
};
|
||||
|
||||
export default process;
|
||||
Reference in new issue
Block a user