File tree 2 files changed +8
-4
lines changed
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -707,7 +707,8 @@ export async function addManuallyIncludedOptimizeDeps(
707
707
const resolve = config . createResolver ( {
708
708
asSrc : false ,
709
709
scan : true ,
710
- ssrOptimizeCheck : ssr
710
+ ssrOptimizeCheck : ssr ,
711
+ ssrConfig : config . ssr
711
712
} )
712
713
for ( const id of [ ...optimizeDepsInclude , ...extra ] ) {
713
714
// normalize 'foo >bar` as 'foo > bar' to prevent same id being added
Original file line number Diff line number Diff line change @@ -800,11 +800,11 @@ export function tryNodeResolve(
800
800
: OPTIMIZABLE_ENTRY_RE . test ( resolved )
801
801
802
802
let exclude = depsOptimizer ?. options . exclude
803
- let include = depsOptimizer ?. options . exclude
803
+ let include = depsOptimizer ?. options . include
804
804
if ( options . ssrOptimizeCheck ) {
805
805
// we don't have the depsOptimizer
806
806
exclude = options . ssrConfig ?. optimizeDeps ?. exclude
807
- include = options . ssrConfig ?. optimizeDeps ?. exclude
807
+ include = options . ssrConfig ?. optimizeDeps ?. include
808
808
}
809
809
810
810
const skipOptimization =
@@ -813,7 +813,10 @@ export function tryNodeResolve(
813
813
exclude ?. includes ( pkgId ) ||
814
814
exclude ?. includes ( nestedPath ) ||
815
815
SPECIAL_QUERY_RE . test ( resolved ) ||
816
- ( ! isBuild && ssr ) ||
816
+ // During dev SSR, we don't have a way to reload the module graph if
817
+ // a non-optimized dep is found. So we need to skip optimization here.
818
+ // The only optimized deps are the ones explicitly listed in the config.
819
+ ( ! options . ssrOptimizeCheck && ! isBuild && ssr ) ||
817
820
// Only optimize non-external CJS deps during SSR by default
818
821
( ssr &&
819
822
! isCJS &&
You can’t perform that action at this time.
0 commit comments