File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
packages/vite/src/node/plugins Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import type {
55 ImportSpecifier ,
66} from 'es-module-lexer'
77import { init , parse as parseImports } from 'es-module-lexer'
8- import type { OutputChunk , SourceMap } from 'rollup'
8+ import type { SourceMap } from 'rollup'
99import type { RawSourceMap } from '@ampproject/remapping'
1010import convertSourceMap from 'convert-source-map'
1111import {
@@ -377,15 +377,17 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
377377 if ( filename === ownerFilename ) return
378378 if ( analyzed . has ( filename ) ) return
379379 analyzed . add ( filename )
380- const chunk = bundle [ filename ] as OutputChunk | undefined
380+ const chunk = bundle [ filename ]
381381 if ( chunk ) {
382382 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+ }
389391 } else {
390392 const removedPureCssFiles =
391393 removedPureCssFilesCache . get ( config ) !
You can’t perform that action at this time.
0 commit comments