@@ -222,4 +222,56 @@ test.group('Loader', () => {
222
222
223
223
assert . isDefined ( result )
224
224
} )
225
+
226
+ test ( 'dependent files of reload paths should trigger a full reload' , async ( { fs, assert } ) => {
227
+ await fakeInstall ( fs . basePath )
228
+
229
+ await fs . createJson ( 'package.json' , { type : 'module' } )
230
+ await fs . create (
231
+ 'config/test.js' ,
232
+ `
233
+ import '../app/test.js'
234
+ console.log("Hello")
235
+ `
236
+ )
237
+ await fs . create ( 'app/test.js' , 'console.log("Hello")' )
238
+ await fs . create (
239
+ 'server.js' ,
240
+ `import * as http from 'http'
241
+ import { hot } from 'hot-hook'
242
+ import { join } from 'node:path'
243
+ import { setTimeout } from 'node:timers/promises'
244
+
245
+ await hot.init({
246
+ projectRoot: join(import.meta.dirname, '.'),
247
+ reload: ['config/**/*'],
248
+ })
249
+
250
+ await import('./config/test.js')
251
+ await setTimeout(100)
252
+ console.log('Server is running')
253
+ await setTimeout(2000)
254
+ `
255
+ )
256
+
257
+ const server = runProcess ( 'server.js' , {
258
+ cwd : fs . basePath ,
259
+ env : { NODE_DEBUG : 'hot-hook' } ,
260
+ } )
261
+
262
+ await server . waitForOutput ( 'Server is running' )
263
+
264
+ await fs . create ( 'app/test.js' , 'console.log("Hello Updated")' )
265
+ await setTimeout ( 100 )
266
+
267
+ const result = await pEvent (
268
+ server . child ,
269
+ 'message' ,
270
+ ( message : any ) =>
271
+ message ?. type === 'hot-hook:full-reload' &&
272
+ message . path === join ( fs . basePath , 'app/test.js' )
273
+ )
274
+
275
+ assert . isDefined ( result )
276
+ } )
225
277
} )
0 commit comments