@@ -31,7 +31,7 @@ const { downloadFile } = require('../packages/runtime/src/templates/handlerUtils
31
31
const { getExtendedApiRouteConfigs } = require ( '../packages/runtime/src/helpers/functions' )
32
32
const nextRuntimeFactory = require ( '../packages/runtime/src' )
33
33
const nextRuntime = nextRuntimeFactory ( { } )
34
- const { startWatching } = require ( '../packages/runtime/src/helpers/compiler' )
34
+ const { watchForMiddlewareChanges } = require ( '../packages/runtime/src/helpers/compiler' )
35
35
const { HANDLER_FUNCTION_NAME , ODB_FUNCTION_NAME , IMAGE_FUNCTION_NAME } = require ( '../packages/runtime/src/constants' )
36
36
const { join } = require ( 'pathe' )
37
37
const {
@@ -1837,7 +1837,7 @@ fdescribe('the dev middleware watcher', () => {
1837
1837
await moveNextDist ( '.next' , true )
1838
1838
await writeFile ( path . join ( process . cwd ( ) , 'middleware.ts' ) , middlewareSourceTs )
1839
1839
expect ( middlewareExists ( ) ) . toBeFalsy ( )
1840
- const { watcher, isReady } = startWatching ( process . cwd ( ) )
1840
+ const { watcher, isReady } = watchForMiddlewareChanges ( process . cwd ( ) )
1841
1841
watchers . push ( watcher )
1842
1842
await isReady
1843
1843
expect ( middlewareExists ( ) ) . toBeTruthy ( )
@@ -1847,7 +1847,7 @@ fdescribe('the dev middleware watcher', () => {
1847
1847
it ( 'should compile a file if it is written after the watcher starts' , async ( ) => {
1848
1848
console . log ( 'starting should compile a file if it is written after the watcher starts' )
1849
1849
await moveNextDist ( '.next' , true )
1850
- const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1850
+ const { watcher, isReady, nextBuild } = watchForMiddlewareChanges ( process . cwd ( ) )
1851
1851
watchers . push ( watcher )
1852
1852
await isReady
1853
1853
expect ( middlewareExists ( ) ) . toBeFalsy ( )
@@ -1861,7 +1861,7 @@ fdescribe('the dev middleware watcher', () => {
1861
1861
it ( 'should remove the output if the middleware is removed after the watcher starts' , async ( ) => {
1862
1862
console . log ( 'starting should remove the output if the middleware is removed after the watcher starts' )
1863
1863
await moveNextDist ( '.next' , true )
1864
- const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1864
+ const { watcher, isReady, nextBuild } = watchForMiddlewareChanges ( process . cwd ( ) )
1865
1865
watchers . push ( watcher )
1866
1866
await isReady
1867
1867
expect ( middlewareExists ( ) ) . toBeFalsy ( )
@@ -1879,7 +1879,7 @@ fdescribe('the dev middleware watcher', () => {
1879
1879
it ( 'should remove the output if invalid middleware is written after the watcher starts' , async ( ) => {
1880
1880
console . log ( 'starting should remove the output if invalid middleware is written after the watcher starts' )
1881
1881
await moveNextDist ( '.next' , true )
1882
- const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1882
+ const { watcher, isReady, nextBuild } = watchForMiddlewareChanges ( process . cwd ( ) )
1883
1883
watchers . push ( watcher )
1884
1884
await isReady
1885
1885
expect ( middlewareExists ( ) ) . toBeFalsy ( )
@@ -1899,7 +1899,7 @@ fdescribe('the dev middleware watcher', () => {
1899
1899
'starting should recompile the middleware if it is moved into the src directory after the watcher starts' ,
1900
1900
)
1901
1901
await moveNextDist ( '.next' , true )
1902
- const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1902
+ const { watcher, isReady, nextBuild } = watchForMiddlewareChanges ( process . cwd ( ) )
1903
1903
watchers . push ( watcher )
1904
1904
await isReady
1905
1905
expect ( middlewareExists ( ) ) . toBeFalsy ( )
@@ -1919,7 +1919,7 @@ fdescribe('the dev middleware watcher', () => {
1919
1919
'starting should recompile the middleware if it is moved into the root directory after the watcher starts' ,
1920
1920
)
1921
1921
await moveNextDist ( '.next' , true )
1922
- const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1922
+ const { watcher, isReady, nextBuild } = watchForMiddlewareChanges ( process . cwd ( ) )
1923
1923
watchers . push ( watcher )
1924
1924
await isReady
1925
1925
expect ( middlewareExists ( ) ) . toBeFalsy ( )
@@ -1940,7 +1940,7 @@ fdescribe('the dev middleware watcher', () => {
1940
1940
'starting should compile the middleware if invalid source is replaced with valid source after the watcher starts' ,
1941
1941
)
1942
1942
await moveNextDist ( '.next' , true )
1943
- const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1943
+ const { watcher, isReady, nextBuild } = watchForMiddlewareChanges ( process . cwd ( ) )
1944
1944
watchers . push ( watcher )
1945
1945
await isReady
1946
1946
expect ( middlewareExists ( ) ) . toBeFalsy ( )
@@ -1960,7 +1960,7 @@ fdescribe('the dev middleware watcher', () => {
1960
1960
it ( 'should not compile middleware if more than one middleware file exists' , async ( ) => {
1961
1961
console . log ( 'starting should not compile middleware if more than one middleware file exists' )
1962
1962
await moveNextDist ( '.next' , true )
1963
- const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1963
+ const { watcher, isReady, nextBuild } = watchForMiddlewareChanges ( process . cwd ( ) )
1964
1964
watchers . push ( watcher )
1965
1965
await isReady
1966
1966
expect ( middlewareExists ( ) ) . toBeFalsy ( )
@@ -1975,7 +1975,7 @@ fdescribe('the dev middleware watcher', () => {
1975
1975
it ( 'should not compile middleware if a second middleware file is added after the watcher starts' , async ( ) => {
1976
1976
console . log ( 'starting should not compile middleware if a second middleware file is added after the watcher starts' )
1977
1977
await moveNextDist ( '.next' , true )
1978
- const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1978
+ const { watcher, isReady, nextBuild } = watchForMiddlewareChanges ( process . cwd ( ) )
1979
1979
watchers . push ( watcher )
1980
1980
await isReady
1981
1981
expect ( middlewareExists ( ) ) . toBeFalsy ( )
@@ -1993,7 +1993,7 @@ fdescribe('the dev middleware watcher', () => {
1993
1993
it ( 'should compile middleware if a second middleware file is removed after the watcher starts' , async ( ) => {
1994
1994
console . log ( 'starting should compile middleware if a second middleware file is removed after the watcher starts' )
1995
1995
await moveNextDist ( '.next' , true )
1996
- const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1996
+ const { watcher, isReady, nextBuild } = watchForMiddlewareChanges ( process . cwd ( ) )
1997
1997
watchers . push ( watcher )
1998
1998
await isReady
1999
1999
expect ( middlewareExists ( ) ) . toBeFalsy ( )
@@ -2020,7 +2020,7 @@ fdescribe('the dev middleware watcher', () => {
2020
2020
const consoleErrorSpy = jest
2021
2021
. spyOn ( console , 'error' )
2022
2022
. mockImplementation ( ( args ) => console . warn ( args ?. errors ?. [ 0 ] ?. text ) )
2023
- const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
2023
+ const { watcher, isReady, nextBuild } = watchForMiddlewareChanges ( process . cwd ( ) )
2024
2024
watchers . push ( watcher )
2025
2025
await isReady
2026
2026
expect ( middlewareExists ( ) ) . toBeFalsy ( )
0 commit comments