@@ -437,7 +437,7 @@ export default class Project {
437
437
438
438
for await ( const { path : p } of walk ( pagesDir , walkOptions ) ) {
439
439
const rp = path . resolve ( util . trimPrefix ( p , pagesDir ) ) || '/'
440
- const pagePath = rp . replace ( reModuleExt , '' ) . replace ( / \s + / g, '-' ) . replace ( / \/ ? i n d e x $ / i, '/' )
440
+ const pagePath = rp . replace ( reModuleExt , '' ) . replace ( / \s + / g, '-' ) . replace ( / \/ i n d e x $ / i, '' ) || '/'
441
441
this . #pageModules. set ( pagePath , {
442
442
moduleId : './pages' + rp . replace ( reModuleExt , '' ) + '.js' ,
443
443
rendered : new Map ( )
@@ -518,9 +518,15 @@ export default class Project {
518
518
this . _clearPageRenderCache ( )
519
519
} else if ( moduleId . startsWith ( './pages/' ) ) {
520
520
if ( removed ) {
521
- this . _removePageModule ( moduleId )
521
+ this . _removePageModuleById ( moduleId )
522
522
} else {
523
- this . _clearPageRenderCache ( moduleId )
523
+ if ( this . #pageModules. has ( moduleId ) ) {
524
+ this . _clearPageRenderCache ( moduleId )
525
+ } else {
526
+ const pagePath = util . trimPrefix ( moduleId , './pages' ) . replace ( reModuleExt , '' ) . replace ( / \s + / g, '-' ) . replace ( / \/ i n d e x $ / i, '' ) || '/'
527
+ console . log ( ">" , pagePath )
528
+ this . #pageModules. set ( pagePath , { moduleId, rendered : new Map ( ) } )
529
+ }
524
530
}
525
531
}
526
532
this . _createMainModule ( )
@@ -564,7 +570,7 @@ export default class Project {
564
570
}
565
571
}
566
572
567
- private _removePageModule ( moduleId : string ) {
573
+ private _removePageModuleById ( moduleId : string ) {
568
574
let pagePath = ''
569
575
for ( const [ p , pm ] of this . #pageModules. entries ( ) ) {
570
576
if ( pm . moduleId === moduleId ) {
@@ -579,7 +585,9 @@ export default class Project {
579
585
580
586
private _clearPageRenderCache ( moduleId ?: string ) {
581
587
for ( const [ _ , p ] of this . #pageModules. entries ( ) ) {
582
- if ( moduleId === undefined || p . moduleId === moduleId ) {
588
+ if ( ! moduleId ) {
589
+ p . rendered . clear ( )
590
+ } else if ( p . moduleId == moduleId ) {
583
591
p . rendered . clear ( )
584
592
break
585
593
}
0 commit comments