Skip to content

Commit 00a79ec

Browse files
authored
refactor: upgrade resolve.exports (#11712)
1 parent a6df6b4 commit 00a79ec

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

packages/vite/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
"postcss-import": "^15.1.0",
120120
"postcss-load-config": "^4.0.1",
121121
"postcss-modules": "^6.0.0",
122-
"resolve.exports": "^1.1.1",
122+
"resolve.exports": "^2.0.0",
123123
"rollup-plugin-license": "^3.0.1",
124124
"sirv": "^2.0.2",
125125
"source-map-js": "^1.0.2",

packages/vite/src/node/plugins/resolve.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'node:fs'
22
import path from 'node:path'
33
import colors from 'picocolors'
44
import type { PartialResolvedId } from 'rollup'
5-
import { resolve as _resolveExports } from 'resolve.exports'
5+
import { exports } from 'resolve.exports'
66
import { hasESMSyntax } from 'mlly'
77
import type { Plugin } from '../plugin'
88
import {
@@ -937,7 +937,7 @@ export function resolvePackageEntry(
937937
return cached
938938
}
939939
try {
940-
let entryPoint: string | undefined | void
940+
let entryPoint: string | undefined
941941

942942
// resolve exports field with highest priority
943943
// using https://github.com/lukeed/resolve.exports
@@ -1099,11 +1099,13 @@ function resolveExports(
10991099
conditions.push(...options.conditions)
11001100
}
11011101

1102-
return _resolveExports(pkg, key, {
1102+
const result = exports(pkg, key, {
11031103
browser: targetWeb && !conditions.includes('node'),
11041104
require: options.isRequire && !conditions.includes('import'),
11051105
conditions,
11061106
})
1107+
1108+
return result ? result[0] : undefined
11071109
}
11081110

11091111
function resolveDeepImport(

pnpm-lock.yaml

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)