mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 07:18:54 +00:00
ae7bf74b3e
Node's ESM resolver does not consult NODE_PATH (unlike CJS require), so an ESM postcss.config.js shipped by a Hugo theme fails when loaded from the module cache: bare imports like `import x from "postcss-import"` have no node_modules to walk up to. Install a synchronous resolver hook (module.registerHooks) via --import=data:... on every Node invocation. On ERR_MODULE_NOT_FOUND for a bare specifier it resolves the package from each NODE_PATH entry via createRequire().resolve(). No-op for relative, absolute, URL-scheme and non-MODULE_NOT_FOUND failures. Synchronous hooks run on the main thread, so no --allow-worker is needed under the Node permission model. Fixes #13987 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>