fix(core): resolve watcher binding require lazily (#42122)

This commit is contained in:
Kit Langton 2026-08-12 15:40:41 -04:00 committed by GitHub
parent c9539979bd
commit d8f62cfdcb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,9 +2,10 @@ import { createRequire } from "node:module"
declare const OPENCODE_LIBC: string | undefined
const require = createRequire(import.meta.url)
// Lazy: on workerd import.meta.url is undefined and the watcher is never
// loaded, so createRequire must not run at module scope.
export default function load() {
const require = createRequire(import.meta.url)
const libc = typeof OPENCODE_LIBC === "undefined" ? undefined : OPENCODE_LIBC
return require(
process.env.OPENCODE_PARCEL_WATCHER_PATH ??