// less' browser build runs a page auto-init while its module loads: it // reaches for `window`, copies any `window.less` config, then — unless told // otherwise — hides `` and rescans the document's stylesheets. A worker // has none of that, so bind `window` to the worker scope, stub the single // `document` probe the init makes (null-safe downstream), and pre-set // `onReady: false` so init stops right after building the compiler. // The worker imports this for side effects before `less`, so ESM evaluation // order guarantees the shim exists by the time the auto-init runs. if (typeof window === 'undefined') { const worker = globalThis as unknown as Record worker.window = worker worker.document = { getElementsByTagName: () => [] } worker.less = { onReady: false } }