@@ -154,12 +154,7 @@ function preload(
154
154
export function buildImportAnalysisPlugin ( config : ResolvedConfig ) : Plugin {
155
155
const ssr = ! ! config . build . ssr
156
156
const isWorker = config . isWorker
157
- const insertPreload = ! (
158
- ssr ||
159
- ! ! config . build . lib ||
160
- isWorker ||
161
- config . build . modulePreload === false
162
- )
157
+ const insertPreload = ! ( ssr || ! ! config . build . lib || isWorker )
163
158
164
159
const resolveModulePreloadDependencies =
165
160
config . build . modulePreload && config . build . modulePreload . resolveDependencies
@@ -448,12 +443,7 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
448
443
} ,
449
444
450
445
generateBundle ( { format } , bundle ) {
451
- if (
452
- format !== 'es' ||
453
- ssr ||
454
- isWorker ||
455
- config . build . modulePreload === false
456
- ) {
446
+ if ( format !== 'es' || ssr || isWorker ) {
457
447
return
458
448
}
459
449
@@ -564,14 +554,19 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
564
554
deps . size > 1 ||
565
555
// main chunk is removed
566
556
( hasRemovedPureCssChunk && deps . size > 0 )
567
- ? [ ...deps ]
557
+ ? modulePreload === false
558
+ ? // CSS deps use the same mechanism as module preloads, so even if disabled,
559
+ // we still need to pass these deps to the preload helper in dynamic imports.
560
+ [ ...deps ] . filter ( ( d ) => d . endsWith ( '.css' ) )
561
+ : [ ...deps ]
568
562
: [ ]
569
563
570
564
let renderedDeps : string [ ]
571
565
if ( normalizedFile && customModulePreloadPaths ) {
572
566
const { modulePreload } = config . build
573
- const resolveDependencies =
574
- modulePreload && modulePreload . resolveDependencies
567
+ const resolveDependencies = modulePreload
568
+ ? modulePreload . resolveDependencies
569
+ : undefined
575
570
let resolvedDeps : string [ ]
576
571
if ( resolveDependencies ) {
577
572
// We can't let the user remove css deps as these aren't really preloads, they are just using
0 commit comments