@@ -78,33 +78,16 @@ function createHandler(dir) {
78
78
}
79
79
} ) ;
80
80
81
- Object . keys ( functions ) . forEach ( name => {
82
- const fn = functions [ name ] ;
83
- const clearCache = action => ( ) => {
84
- if ( action !== "added" ) {
85
- console . log (
86
- `${ NETLIFYDEVLOG } function ${ chalk . yellow (
87
- name
88
- ) } ${ action } , reloading...`
89
- ) ; // eslint-disable-line no-console
90
- }
91
- const before = module . paths ;
92
- module . paths = [ fn . moduleDir ] ;
93
- delete require . cache [ require . resolve ( fn . functionPath ) ] ;
94
- module . paths = before ;
95
- } ;
96
- const pathsToWatch = [ fn . functionPath ] ;
97
- if ( fn . moduleDir ) {
98
- pathsToWatch . push ( path . join ( fn . moduleDir , "package.json" ) ) ;
99
- }
100
- fn . watcher = chokidar . watch ( pathsToWatch , {
101
- ignored : / n o d e _ m o d u l e s /
81
+ const clearCache = action => path => {
82
+ console . log ( `${ NETLIFYDEVLOG } ${ path } ${ action } , reloading...` ) ; // eslint-disable-line no-console
83
+ Object . keys ( require . cache ) . forEach ( k => {
84
+ delete require . cache [ k ] ;
102
85
} ) ;
103
- fn . watcher
104
- . on ( "add" , clearCache ( "added" ) )
105
- . on ( "change" , clearCache ( "modified" ) )
106
- . on ( "unlink " , clearCache ( "deleted " ) ) ;
107
- } ) ;
86
+ } ;
87
+ const watcher = chokidar . watch ( dir , { ignored : / n o d e _ m o d u l e s / } ) ;
88
+ watcher
89
+ . on ( "change " , clearCache ( "modified " ) )
90
+ . on ( "unlink" , clearCache ( "deleted" ) ) ;
108
91
109
92
return function ( request , response ) {
110
93
// handle proxies without path re-writes (http-servr)
0 commit comments