@@ -901,6 +901,37 @@ describe('watch-hmr regression text helpers', () => {
901901 expect ( elapsed ) . toBeGreaterThanOrEqual ( 0 )
902902 } )
903903
904+ it ( 'allows style compile settle to observe CSS output mtimes' , async ( ) => {
905+ const tempDir = await mkdtemp ( path . join ( os . tmpdir ( ) , 'weapp-tw-watch-style-settle-' ) )
906+ tempDirs . push ( tempDir )
907+ const styleFile = path . join ( tempDir , 'index.wxss' )
908+ await writeFilePreserveEol ( styleFile , '.anchor{}' , '.anchor{}' )
909+ const phaseStartedAt = Date . now ( )
910+
911+ await new Promise ( resolve => setTimeout ( resolve , 20 ) )
912+ await writeFilePreserveEol ( styleFile , '.anchor{color:red}' , '.anchor{}' )
913+
914+ const elapsed = await waitForCompileSettled (
915+ {
916+ label : 'demo/weapp-vite-tailwindcss-v4' ,
917+ outputWxml : '/missing/index.wxml' ,
918+ outputJs : '/missing/index.js' ,
919+ } as any ,
920+ {
921+ timeoutMs : 2_000 ,
922+ pollMs : 20 ,
923+ } as CliOptions ,
924+ {
925+ ensureRunning ( ) { } ,
926+ lastCompileSuccessAt : ( ) => 0 ,
927+ } as any ,
928+ phaseStartedAt ,
929+ [ styleFile ] ,
930+ )
931+
932+ expect ( elapsed ) . toBeGreaterThanOrEqual ( 0 )
933+ } )
934+
904935 it ( 'allows style-only compile settle to use a stable plugin total sample' , async ( ) => {
905936 const pluginTotalAt = Date . now ( ) - 700
906937 const elapsed = await waitForCompileSettled (
@@ -930,6 +961,56 @@ describe('watch-hmr regression text helpers', () => {
930961 expect ( elapsed ) . toBeGreaterThanOrEqual ( 0 )
931962 } )
932963
964+ it ( 'waits for CSS outputs when a compile success signal arrives first' , async ( ) => {
965+ const tempDir = await mkdtemp ( path . join ( os . tmpdir ( ) , 'weapp-tw-watch-css-lag-' ) )
966+ tempDirs . push ( tempDir )
967+ const wxmlFile = path . join ( tempDir , 'index.wxml' )
968+ const jsFile = path . join ( tempDir , 'index.js' )
969+ const styleFile = path . join ( tempDir , 'app.wxss' )
970+ await Promise . all ( [
971+ writeFilePreserveEol ( wxmlFile , '<view />' , '<view />' ) ,
972+ writeFilePreserveEol ( jsFile , 'Page({})' , 'Page({})' ) ,
973+ writeFilePreserveEol ( styleFile , '.baseline{}' , '.baseline{}' ) ,
974+ ] )
975+
976+ await new Promise ( resolve => setTimeout ( resolve , 40 ) )
977+ const phaseStartedAt = Date . now ( )
978+ let compileSuccessAt = 0
979+ setTimeout ( ( ) => {
980+ compileSuccessAt = Date . now ( )
981+ void writeFilePreserveEol ( jsFile , 'Page({ ready: true })' , 'Page({})' ) . catch ( ( ) => undefined )
982+ } , 20 )
983+ setTimeout ( ( ) => {
984+ void rm ( styleFile , { force : true } ) . catch ( ( ) => undefined )
985+ } , 100 )
986+ setTimeout ( ( ) => {
987+ void writeFilePreserveEol ( styleFile , '.updated{color:red}' , '.baseline{}' ) . catch ( ( ) => undefined )
988+ } , 900 )
989+
990+ await waitForCompileSettled (
991+ {
992+ label : 'demo/uni-app-vite-tailwindcss-v4' ,
993+ outputWxml : wxmlFile ,
994+ outputJs : jsFile ,
995+ outputStyleCandidates : [ styleFile ] ,
996+ globalStyleCandidates : [ styleFile ] ,
997+ } as any ,
998+ {
999+ timeoutMs : 3_000 ,
1000+ pollMs : 20 ,
1001+ } as CliOptions ,
1002+ {
1003+ ensureRunning ( ) { } ,
1004+ lastCompileSuccessAt : ( ) => compileSuccessAt ,
1005+ pluginProcessSamplesSince : ( ) => [ ] ,
1006+ } as any ,
1007+ phaseStartedAt ,
1008+ )
1009+
1010+ expect ( compileSuccessAt ) . toBeGreaterThan ( phaseStartedAt )
1011+ await expect ( readFile ( styleFile , 'utf8' ) ) . resolves . toBe ( '.updated{color:red}' )
1012+ } )
1013+
9331014 it ( 'waits for added-class rollback compilation to settle before returning' , async ( ) => {
9341015 const tempDir = await mkdtemp ( path . join ( os . tmpdir ( ) , 'weapp-tw-added-class-rollback-' ) )
9351016 tempDirs . push ( tempDir )
0 commit comments