8000 fix: analysing build chunk without dependencies (#15469) · vitejs/vite@bd52283 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bd52283

Browse files
fix: analysing build chunk without dependencies (#15469)
Co-authored-by: patak <matias.capeletto@gmail.com>
1 parent ab823ab commit bd52283

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

packages/vite/src/node/plugins/importAnalysisBuild.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
ImportSpecifier,
66
} from 'es-module-lexer'
77
import { init, parse as parseImports } from 'es-module-lexer'
8-
import type { OutputChunk, SourceMap } from 'rollup'
8+
import type { SourceMap } from 'rollup'
99
import type { RawSourceMap } from '@ampproject/remapping'
1010
import convertSourceMap from 'convert-source-map'
1111
import {
@@ -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)!

0 commit comments

Comments
 (0)
0