|
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 |
64 |
| - if ( |
65 |
| - module.isBuiltin(source) || |
66 |
| - isBunModule(source, process.versions.bun as Version) |
67 |
| - ) { |
68 |
| - log('matched core:', source) |
| 63 | + options ||= {} |
69 | 64 |
|
70 |
| - return { |
71 |
| - found: true, |
72 |
| - path: null, |
| 65 | + let bunVersion = process.versions.bun as Version | undefined |
| 66 | + |
| 67 | + // don't worry about bun core modules |
| 68 | + if (bunVersion || options.bun) { |
| 69 | + bunVersion ??= 'latest' |
| 70 | + if ( |
| 71 | + isBunModule(source, bunVersion) || |
| 72 | + isSupportedNodeModule(source, bunVersion) |
| 73 | + ) { |
| 74 | + log('matched bun core:', source) |
| 75 | + return { found: true, path: null } |
73 | 76 | }
|
| 77 | + } else if (module.isBuiltin(source)) { |
| 78 | + // don't worry about node core modules |
| 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