-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(legacy): error in build with --watch and manifest enabled (#14450)
Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
- Loading branch information
1 parent
03c371e
commit b9ee620
Showing
6 changed files
with
81 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
playground/legacy/__tests__/watch/styles-only-entry-watch.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { expect, test } from 'vitest' | ||
import { | ||
editFile, | ||
findAssetFile, | ||
isBuild, | ||
notifyRebuildComplete, | ||
readManifest, | ||
watcher, | ||
} from '~utils' | ||
|
||
test.runIf(isBuild)('rebuilds styles only entry on change', async () => { | ||
expect(findAssetFile(/style-only-entry-.+\.css/, 'watch')).toContain( | ||
'hotpink', | ||
) | ||
expect(findAssetFile(/style-only-entry-legacy-.+\.js/, 'watch')).toContain( | ||
'hotpink', | ||
) | ||
expect(findAssetFile(/polyfills-legacy-.+\.js/, 'watch')).toBeTruthy() | ||
const numberOfManifestEntries = Object.keys(readManifest('watch')).length | ||
expect(numberOfManifestEntries).toBe(3) | ||
|
||
editFile( | ||
'style-only-entry.css', | ||
(originalContents) => originalContents.replace('hotpink', 'lightpink'), | ||
true, | ||
) | ||
await notifyRebuildComplete(watcher) | ||
|
||
const updatedManifest = readManifest('watch') | ||
expect(Object.keys(updatedManifest)).toHaveLength(numberOfManifestEntries) | ||
|
||
// We must use the file referenced in the manifest here, | ||
// since there'll be different versions of the file with different hashes. | ||
const reRenderedCssFile = findAssetFile( | ||
updatedManifest['style-only-entry.css']!.file.substring('assets/'.length), | ||
'watch', | ||
) | ||
expect(reRenderedCssFile).toContain('lightpink') | ||
const reRenderedCssLegacyFile = findAssetFile( | ||
updatedManifest['style-only-entry-legacy.css']!.file.substring( | ||
'assets/'.length, | ||
), | ||
'watch', | ||
) | ||
expect(reRenderedCssLegacyFile).toContain('lightpink') | ||
expect(findAssetFile(/polyfills-legacy-.+\.js/, 'watch')).toBeTruthy() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
:root { | ||
background: hotpink; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { resolve } from 'node:path' | ||
import legacy from '@vitejs/plugin-legacy' | ||
import { defineConfig } from 'vite' | ||
|
||
export default defineConfig({ | ||
plugins: [legacy()], | ||
build: { | ||
manifest: true, | ||
rollupOptions: { | ||
input: { | ||
'style-only-entry': resolve(__dirname, 'style-only-entry.css'), | ||
}, | ||
}, | ||
watch: {}, | ||
outDir: 'dist/watch', | ||
}, | ||
}) |