mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 10:24:02 +00:00
Since the UI moved to single-file components, every unit-test process compiled the views it imports from scratch, and the loader ran off-thread (module.register), adding a round trip to every module a test imports, including the ones that are not components. Core's unit tests took about twice as long, and a host running Core's suite on smaller runners passed its CI time limit. register-vue now installs synchronous hooks on the loading thread (module.registerHooks). Compiled components are kept in the system temp directory, keyed by the file's path and text, the Vue version and the loader's own code, so each one compiles once across test processes; the compiler itself loads only on a cache miss. Cached modules run as code, so the directory is used only when it is a real directory owned by the current user and writable by no one else; on Windows it lives in the user's local app data instead of a temp directory that may be shared. The cache never sits inside the package tree, and GEV_VUE_CACHE=0 compiles every time. On four cores the full suite went from 441 s to 240 s from a cold cache.
9 lines
399 B
JavaScript
9 lines
399 B
JavaScript
import { registerHooks } from 'node:module';
|
|
import { load } from './vueLoader.js';
|
|
|
|
// Lets Node import single-file components: `node --import=<this file>`.
|
|
// Hosts reach it as `<core package>/build/register-vue`. The hooks run on the
|
|
// loading thread: off-thread hooks (module.register) would add a round trip
|
|
// to every module a test imports, not only the components.
|
|
registerHooks({ load });
|