@@ -8,12 +8,12 @@ import {
8
8
createFilesMatcher ,
9
9
parseTsconfig ,
10
10
} from 'get-tsconfig'
11
- import { type Version } from 'is-bun-module'
12
11
import { ResolverFactory } from 'rspack-resolver'
13
12
import { stableHash } from 'stable-hash'
14
13
15
14
import { IMPORT_RESOLVER_NAME , JS_EXT_PATTERN } from './constants.js'
16
15
import {
16
+ isBunBuiltin ,
17
17
mangleScopedPackage ,
18
18
removeQuerystring ,
19
19
sortProjectsByAffinity ,
@@ -53,11 +53,6 @@ const oxcResolve = (
53
53
}
54
54
}
55
55
56
- type IsBunModule = typeof import ( 'is-bun-module' )
57
- let isBunModule : IsBunModule | undefined
58
-
59
- const _filename = typeof __filename === 'string' ? __filename : import . meta. url
60
-
61
56
export const resolve = (
62
57
source : string ,
63
58
file : string ,
@@ -67,24 +62,9 @@ export const resolve = (
67
62
) : ResolvedResult => {
68
63
options ||= { }
69
64
70
- let bunVersion = process . versions . bun as Version | undefined
71
-
72
- // don't worry about bun core modules
73
- if ( bunVersion || options . bun ) {
74
- if (
75
- bunVersion
76
- ? module . isBuiltin ( source )
77
- : ( isBunModule ??= module . createRequire ( _filename ) (
78
- 'is-bun-module' ,
79
- ) as IsBunModule ) . isBunModule ( source , ( bunVersion = 'latest' ) ) ||
80
- isBunModule . isSupportedNodeModule ( source , bunVersion )
81
- ) {
82
- log ( 'matched bun core:' , source )
83
- return { found : true , path : null }
84
- }
85
- } else if ( module . isBuiltin ( source ) ) {
86
- // don't worry about node core modules
87
- log ( 'matched node core:' , source )
65
+ // don't worry about node/bun core modules
66
+ if ( module . isBuiltin ( source ) || ( options . bun && isBunBuiltin ( source ) ) ) {
67
+ log ( 'matched core:' , source )
88
68
return { found : true , path : null }
89
69
}
90
70
@@ -112,8 +92,6 @@ export const resolve = (
112
92
resolver = cached
113
93
}
114
94
115
- options ||= { }
116
-
117
95
// eslint-disable-next-line sonarjs/label-position, sonarjs/no-labels
118
96
createResolver: if ( ! resolver ) {
119
97
// must be a array with 2+ items here already ensured by `normalizeOptions`
0 commit comments