Last active
October 7, 2025 19:59
-
-
Save pi0/272e4284cc8bd792d6e599efff431dd1 to your computer and use it in GitHub Desktop.
`process.getBuiltinModule` polyfill
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createRequire, builtinModules } from 'node:module' | |
| // Node.js below v22.3.0, v20.16.0 | |
| if (!globalThis.process.getBuiltinModule) { | |
| const _require = createRequire(import.meta.url) | |
| globalThis.process.getBuiltinModule = (name) => { | |
| if (name.startsWith("node:") || builtinModules.includes(name)) { | |
| return _require(name) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment