File tree 2 files changed +14
-3
lines changed
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 {
2729
2729
// use in performanceCore.ts.
2730
2730
return typeof process !== "undefined"
2731
2731
&& ! ! process . nextTick
2732
- && ! ( process as any ) . browser
2733
- && typeof ( process as any ) . getBuiltinModule === "function" ;
2732
+ && ! ( process as any ) . browser ;
2734
2733
}
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.
2
14
const mod = nodeGetBuiltinModule ( "module" ) as typeof import ( "module" ) | undefined ;
3
15
if ( ! mod ) throw new Error ( "missing node:module" ) ;
4
16
return mod . createRequire ( path ) ;
You can’t perform that action at this time.
0 commit comments