@@ -8,12 +8,12 @@ import {
88 createFilesMatcher ,
99 parseTsconfig ,
1010} from 'get-tsconfig'
11- import { type Version } from 'is-bun-module'
1211import { ResolverFactory } from 'rspack-resolver'
1312import { stableHash } from 'stable-hash'
1413
1514import { IMPORT_RESOLVER_NAME , JS_EXT_PATTERN } from './constants.js'
1615import {
16+ isBunBuiltin ,
1717 mangleScopedPackage ,
1818 removeQuerystring ,
1919 sortProjectsByAffinity ,
@@ -53,11 +53,6 @@ const oxcResolve = (
5353 }
5454}
5555
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-
6156export const resolve = (
6257 source : string ,
6358 file : string ,
@@ -67,24 +62,9 @@ export const resolve = (
6762) : ResolvedResult => {
6863 options ||= { }
6964
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 )
8868 return { found : true , path : null }
8969 }
9070
@@ -112,8 +92,6 @@ export const resolve = (
11292 resolver = cached
11393 }
11494
115- options ||= { }
116-
11795 // eslint-disable-next-line sonarjs/label-position, sonarjs/no-labels
11896 createResolver: if ( ! resolver ) {
11997 // must be a array with 2+ items here already ensured by `normalizeOptions`
0 commit comments