Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: upgrade resolve.exports #11712

Merged
merged 1 commit into from
Jan 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor: upgrade resolve.exports
  • Loading branch information
bluwy committed Jan 17, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
addaleax Anna Henningsen
commit aa030fea097f97b19b51069ab878af4741cee0e4
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@
"postcss-import": "^15.1.0",
"postcss-load-config": "^4.0.1",
"postcss-modules": "^6.0.0",
"resolve.exports": "^1.1.1",
"resolve.exports": "^2.0.0",
"rollup-plugin-license": "^3.0.1",
"sirv": "^2.0.2",
"source-map-js": "^1.0.2",
8 changes: 5 additions & 3 deletions packages/vite/src/node/plugins/resolve.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import fs from 'node:fs'
import path from 'node:path'
import colors from 'picocolors'
import type { PartialResolvedId } from 'rollup'
import { resolve as _resolveExports } from 'resolve.exports'
import { exports } from 'resolve.exports'
import { hasESMSyntax } from 'mlly'
import type { Plugin } from '../plugin'
import {
@@ -937,7 +937,7 @@ export function resolvePackageEntry(
return cached
}
try {
let entryPoint: string | undefined | void
let entryPoint: string | undefined

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

return _resolveExports(pkg, key, {
const result = exports(pkg, key, {
browser: targetWeb && !conditions.includes('node'),
require: options.isRequire && !conditions.includes('import'),
conditions,
})

return result ? result[0] : undefined
}

function resolveDeepImport(
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.