Skip to content

Commit a10fc79

Browse files
committed
Revert "fix(lib): remove pure CSS dynamic import (vitejs#17601)"
This reverts commit 055f1c1.
1 parent 41caf7a commit a10fc79

File tree

2 files changed

+1
-11
lines changed

2 files changed

+1
-11
lines changed

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,7 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
403403
return
404404
}
405405

406-
// If preload is not enabled, we parse through each imports and remove any imports to pure CSS chunks
407-
// as they are removed from the bundle
408-
if (!insertPreload) {
406+
if (ssr || isWorker) {
409407
const removedPureCssFiles = removedPureCssFilesCache.get(config)
410408
if (removedPureCssFiles && removedPureCssFiles.size > 0) {
411409
for (const file in bundle) {

playground/lib/__tests__/lib.spec.ts

-8
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ describe.runIf(isBuild)('build', () => {
6767
expect(code).toMatch(/await import\("\.\/message-[-\w]{8}.js"\)/)
6868
})
6969

70-
test('Library mode does not have any reference to pure CSS chunks', async () => {
71-
const code = readFile('dist/lib/dynamic-import-message.es.mjs')
72-
73-
// Does not import pure CSS chunks and replaced by `Promise.resolve({})` instead
74-
expect(code).not.toMatch(/await import\("\.\/dynamic-[-\w]{8}.js"\)/)
75-
expect(code).toMatch(/await Promise.resolve\(\{.*\}\)/)
76-
})
77-
7870
test('@import hoist', async () => {
7971
serverLogs.forEach((log) => {
8072
// no warning from esbuild css minifier

0 commit comments

Comments
 (0)