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 @@ -2713,6 +2713,5 @@ export function isNodeLikeSystem(): boolean {
2713
2713
// use in performanceCore.ts.
2714
2714
return typeof process !== "undefined"
2715
2715
&& ! ! process . nextTick
2716
- && ! ( process as any ) . browser
2717
- && typeof ( process as any ) . getBuiltinModule === "function" ;
2716
+ && ! ( process as any ) . browser ;
2718
2717
}
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