|
8 | 8 | createFilesMatcher, |
9 | 9 | parseTsconfig, |
10 | 10 | } from 'get-tsconfig' |
11 | | -import { type Version, isBunModule } from 'is-bun-module' |
| 11 | +import { type Version, isBunModule, isSupportedNodeModule } from 'is-bun-module' |
12 | 12 | import { ResolverFactory } from 'rspack-resolver' |
13 | 13 | import { stableHash } from 'stable-hash' |
14 | 14 |
|
@@ -60,32 +60,37 @@ export const resolve = ( |
60 | 60 | resolver?: ResolverFactory | null, |
61 | 61 | // eslint-disable-next-line sonarjs/cognitive-complexity |
62 | 62 | ): ResolvedResult => { |
63 | | - // don't worry about core node/bun modules |
| 63 | + options ||= {} |
| 64 | + |
| 65 | + let bunVersion = process.versions.bun as Version | undefined |
| 66 | + |
| 67 | + // don't worry about bun core modules |
64 | 68 | if ( |
65 | | - module.isBuiltin(source) || |
66 | | - isBunModule(source, process.versions.bun as Version) |
| 69 | + (bunVersion || options.bun) && |
| 70 | + (isBunModule(source, (bunVersion ??= 'latest')) || |
| 71 | + isSupportedNodeModule(source, bunVersion)) |
67 | 72 | ) { |
68 | | - log('matched core:', source) |
| 73 | + log('matched bun core:', source) |
| 74 | + return { found: true, path: null } |
| 75 | + } |
69 | 76 |
|
70 | | - return { |
71 | | - found: true, |
72 | | - path: null, |
73 | | - } |
| 77 | + // don't worry about node core modules |
| 78 | + if (module.isBuiltin(source)) { |
| 79 | + log('matched node core:', source) |
| 80 | + return { found: true, path: null } |
74 | 81 | } |
75 | 82 |
|
76 | 83 | if (process.versions.pnp && source === 'pnpapi') { |
77 | 84 | return { |
78 | 85 | found: true, |
79 | | - path: module.findPnpApi(file).resolveToUnqualified(source, file, { |
80 | | - considerBuiltins: false, |
81 | | - }), |
| 86 | + path: module |
| 87 | + .findPnpApi(file) |
| 88 | + .resolveToUnqualified(source, file, { considerBuiltins: false }), |
82 | 89 | } |
83 | 90 | } |
84 | 91 |
|
85 | 92 | source = removeQuerystring(source) |
86 | 93 |
|
87 | | - options ||= {} |
88 | | - |
89 | 94 | if (!resolver) { |
90 | 95 | const optionsHash = stableHash(options) |
91 | 96 | const cwd = process.cwd() |
|
0 commit comments