File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -2729,6 +2729,5 @@ export function isNodeLikeSystem(): boolean {
27292729 // use in performanceCore.ts.
27302730 return typeof process !== "undefined"
27312731 && ! ! process . nextTick
2732- && ! ( process as any ) . browser
2733- && typeof ( process as any ) . getBuiltinModule === "function" ;
2732+ && ! ( process as any ) . browser ;
27342733}
Original file line number Diff line number Diff line change 1- export function nodeCreateRequire ( path : string ) : NodeJS . Require {
1+ export function nodeCreateRequire ( path : string ) : ( id : string ) => any {
2+ /* eslint-disable no-restricted-globals */
3+ // If we're running in an environment that already has `require`, use it.
4+ // We're probably in bun or a bundler that provides `require` even within ESM.
5+ if ( typeof require === "function" && typeof require . resolve === "function" ) {
6+ return id => {
7+ const p = require . resolve ( id , { paths : [ path ] } ) ;
8+ return require ( p ) ;
9+ } ;
10+ }
11+ /* eslint-enable no-restricted-globals */
12+
13+ // Otherwise, try and build a `require` function from the `module` module.
214 const mod = nodeGetBuiltinModule ( "module" ) as typeof import ( "module" ) | undefined ;
315 if ( ! mod ) throw new Error ( "missing node:module" ) ;
416 return mod . createRequire ( path ) ;
You can’t perform that action at this time.
0 commit comments