Skip to content

Commit

Permalink
fix(ssr): do not resolve to optimized deps during ssr
Browse files Browse the repository at this point in the history
fix #1860
  • Loading branch information
yyx990803 committed Feb 3, 2021
1 parent 879922d commit d021506
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/preAlias.ts
Expand Up @@ -13,8 +13,8 @@ export function preAliasPlugin(): Plugin {
configureServer(_server) {
server = _server
},
resolveId(id) {
if (bareImportRE.test(id)) {
resolveId(id, _, __, ssr) {
if (!ssr && bareImportRE.test(id)) {
return tryOptimizedResolve(id, server)
}
}
Expand Down
7 changes: 6 additions & 1 deletion packages/vite/src/node/plugins/resolve.ts
Expand Up @@ -172,7 +172,12 @@ export function resolvePlugin({

// bare package imports, perform node resolve
if (bareImportRE.test(id)) {
if (asSrc && server && (res = tryOptimizedResolve(id, server))) {
if (
asSrc &&
server &&
!ssr &&
(res = tryOptimizedResolve(id, server))
) {
return res
}

Expand Down

0 comments on commit d021506

Please sign in to comment.