◐ Shell
clean mode source ↗

Request: Backport loader fix to v22.x

Version

22.x

Platform

macOS 26.2 (arm64)
Node.js: v22.22.0
Package manager: npm 10.9.4

Subsystem

N/A

What steps will reproduce the bug?

I would like to request a backport of the fix that resolved an issue in v24.11.1 to the v22.x release line.

We are currently experiencing an issue that was fixed in v24.11.1. However, our project is still supporting v22.x and would benefit from having this fix backported.

import module from 'node:module'

module.registerHooks({
  load(url, context, defaultLoad) {
    return defaultLoad(url, context)
  },
})

await import('@intlify/unplugin-vue-i18n/vite')

How often does it reproduce? Is there a required condition?

Node.js < v24.11.1

What is the expected behavior? Why is that the expected behavior?

No errors

What do you see instead?

node:internal/modules/esm/translators:152
    return cjsCache.get(job.url).exports;
                                ^

TypeError: Cannot read properties of undefined (reading 'exports')
    at require (node:internal/modules/esm/translators:152:33)
    at Object.getPkg (/private/tmp/tsdown_issue_example/node_modules/jsonc-eslint-parser/lib/parser/visitor-keys.js:40:28)
    at loadNewest (/private/tmp/tsdown_issue_example/node_modules/jsonc-eslint-parser/lib/parser/modules/require-utils.js:73:26)
    at getVisitorKeys (/private/tmp/tsdown_issue_example/node_modules/jsonc-eslint-parser/lib/parser/visitor-keys.js:21:51)
    at Object.<anonymous> (/private/tmp/tsdown_issue_example/node_modules/jsonc-eslint-parser/lib/index.js:40:57)
    at loadCJSModule (node:internal/modules/esm/translators:166:3)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:202:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:343:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:665:26)
    at async file:///private/tmp/tsdown_issue_example/start.js:10:1

Additional information

Potentially Related PRs

Based on my investigation, the fix may have been introduced in one or both of these PRs:

downstream issue: rolldown/tsdown#766