@@ -5,7 +5,7 @@ import type {
5
5
ImportSpecifier ,
6
6
} from 'es-module-lexer'
7
7
import { init , parse as parseImports } from 'es-module-lexer'
8
- import type { OutputChunk , SourceMap } from 'rollup'
8
+ import type { SourceMap } from 'rollup'
9
9
import type { RawSourceMap } from '@ampproject/remapping'
10
10
import convertSourceMap from 'convert-source-map'
11
11
import {
@@ -377,15 +377,17 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
377
377
if ( filename === ownerFilename ) return
378
378
if ( analyzed . has ( filename ) ) return
379
379
analyzed . add ( filename )
380
- const chunk = bundle [ filename ] as OutputChunk | undefined
380
+ const chunk = bundle [ filename ]
381
381
if ( chunk ) {
382
382
deps . add ( chunk . fileName )
383
- chunk . imports . forEach ( addDeps )
384
- // Ensure that the css imported by current chunk is loaded after the dependencies.
385
- // So the style of current chunk won't be overwritten unexpectedly.
386
- chunk . viteMetadata ! . importedCss . forEach ( ( file ) => {
387
- deps . add ( file )
388
- } )
383
+ if ( chunk . type === 'chunk' ) {
384
+ chunk . imports . forEach ( addDeps )
385
+ // Ensure that the css imported by current chunk is loaded after the dependencies.
386
+ // So the style of current chunk won't be overwritten unexpectedly.
387
+ chunk . viteMetadata ! . importedCss . forEach ( ( file ) => {
388
+ deps . add ( file )
389
+ } )
390
+ }
389
391
} else {
390
392
const removedPureCssFiles =
391
393
removedPureCssFilesCache . get ( config ) !
0 commit comments