@@ -3,6 +3,7 @@ import { EventEmitter } from 'events'
33import { join } from 'path'
44import { parse } from 'url'
55import resolvePath from './resolve'
6+ import touch from 'touch'
67
78const ADDED = Symbol ( )
89const BUILDING = Symbol ( )
@@ -16,6 +17,7 @@ export default function onDemandEntryHandler (devMiddleware, compiler, {
1617 const entries = { }
1718 const lastAccessPages = [ '' ]
1819 const doneCallbacks = new EventEmitter ( )
20+ let touchedAPage = false
1921
2022 compiler . plugin ( 'make' , function ( compilation , done ) {
2123 const allEntries = Object . keys ( entries ) . map ( ( page ) => {
@@ -35,6 +37,17 @@ export default function onDemandEntryHandler (devMiddleware, compiler, {
3537 const entryInfo = entries [ page ]
3638 if ( entryInfo . status !== BUILDING ) return
3739
40+ // With this, we are triggering a filesystem based watch trigger
41+ // It'll memorize some timestamp related info related to common files used
42+ // in the page
43+ // That'll reduce the page building time significantly.
44+ if ( ! touchedAPage ) {
45+ setTimeout ( ( ) => {
46+ touch . sync ( entryInfo . pathname )
47+ } , 0 )
48+ touchedAPage = true
49+ }
50+
3851 entryInfo . status = BUILT
3952 entries [ page ] . lastActiveTime = Date . now ( )
4053 doneCallbacks . emit ( page )
@@ -76,7 +89,7 @@ export default function onDemandEntryHandler (devMiddleware, compiler, {
7689
7790 console . log ( `> Building page: ${ page } ` )
7891
79- entries [ page ] = { name, entry, status : ADDED }
92+ entries [ page ] = { name, entry, pathname , status : ADDED }
8093 doneCallbacks . on ( page , processCallback )
8194
8295 devMiddleware . invalidate ( )
0 commit comments