mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 14:48:41 +00:00
fix: update to check chunk.type
This commit is contained in:
parent
4d569dca48
commit
cf39ab3406
@ -5,7 +5,7 @@ import type {
|
||||
ImportSpecifier,
|
||||
} from 'es-module-lexer'
|
||||
import { init, parse as parseImports } from 'es-module-lexer'
|
||||
import type { OutputChunk, SourceMap } from 'rollup'
|
||||
import type { SourceMap } from 'rollup'
|
||||
import type { RawSourceMap } from '@ampproject/remapping'
|
||||
import convertSourceMap from 'convert-source-map'
|
||||
import {
|
||||
@ -377,16 +377,17 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
|
||||
if (filename === ownerFilename) return
|
||||
if (analyzed.has(filename)) return
|
||||
analyzed.add(filename)
|
||||
const chunk = bundle[filename] as OutputChunk | undefined
|
||||
const chunk = bundle[filename]
|
||||
if (chunk) {
|
||||
deps.add(chunk.fileName)
|
||||
if (chunk.imports) chunk.imports.forEach(addDeps)
|
||||
// Ensure that the css imported by current chunk is loaded after the dependencies.
|
||||
// So the style of current chunk won't be overwritten unexpectedly.
|
||||
if (chunk.viteMetadata)
|
||||
if (chunk.type === 'chunk') {
|
||||
chunk.imports.forEach(addDeps)
|
||||
// Ensure that the css imported by current chunk is loaded after the dependencies.
|
||||
// So the style of current chunk won't be overwritten unexpectedly.
|
||||
chunk.viteMetadata!.importedCss.forEach((file) => {
|
||||
deps.add(file)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
const removedPureCssFiles =
|
||||
removedPureCssFilesCache.get(config)!
|
||||
|
Loading…
Reference in New Issue
Block a user