mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 22:59:10 +00:00
fix(lib): remove pure CSS dynamic import (#17601)
This commit is contained in:
parent
dafff4ae6e
commit
055f1c16e5
@ -403,7 +403,9 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
|
||||
return
|
||||
}
|
||||
|
||||
if (ssr || isWorker) {
|
||||
// If preload is not enabled, we parse through each imports and remove any imports to pure CSS chunks
|
||||
// as they are removed from the bundle
|
||||
if (!insertPreload) {
|
||||
const removedPureCssFiles = removedPureCssFilesCache.get(config)
|
||||
if (removedPureCssFiles && removedPureCssFiles.size > 0) {
|
||||
for (const file in bundle) {
|
||||
|
@ -67,6 +67,14 @@ describe.runIf(isBuild)('build', () => {
|
||||
expect(code).toMatch(/await import\("\.\/message-[-\w]{8}.js"\)/)
|
||||
})
|
||||
|
||||
test('Library mode does not have any reference to pure CSS chunks', async () => {
|
||||
const code = readFile('dist/lib/dynamic-import-message.es.mjs')
|
||||
|
||||
// Does not import pure CSS chunks and replaced by `Promise.resolve({})` instead
|
||||
expect(code).not.toMatch(/await import\("\.\/dynamic-[-\w]{8}.js"\)/)
|
||||
expect(code).toMatch(/await Promise.resolve\(\{.*\}\)/)
|
||||
})
|
||||
|
||||
test('@import hoist', async () => {
|
||||
serverLogs.forEach((log) => {
|
||||
// no warning from esbuild css minifier
|
||||
|
Loading…
Reference in New Issue
Block a user