-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(prerender): cache writing hashed assets
- Loading branch information
1 parent
044aa96
commit 96c44f8
Showing
3 changed files
with
128 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type * as d from '../../declarations'; | ||
|
||
export interface PrerenderContext { | ||
buildId: string; | ||
componentGraph: Map<string, string[]>; | ||
prerenderConfig: d.PrerenderConfig; | ||
ensuredDirs: Set<string>; | ||
templateHtml: string; | ||
hashedFile: Set<string>; | ||
} | ||
|
||
const prerenderCtx: PrerenderContext = { | ||
buildId: null, | ||
componentGraph: null, | ||
prerenderConfig: null, | ||
ensuredDirs: null, | ||
templateHtml: null, | ||
hashedFile: null, | ||
}; | ||
|
||
export const getPrerenderCtx = (prerenderRequest: d.PrerenderUrlRequest) => { | ||
if (prerenderRequest.buildId !== prerenderCtx.buildId) { | ||
prerenderCtx.buildId = prerenderRequest.buildId; | ||
prerenderCtx.componentGraph = null; | ||
prerenderCtx.prerenderConfig = null; | ||
prerenderCtx.ensuredDirs = new Set(); | ||
prerenderCtx.templateHtml = null; | ||
prerenderCtx.hashedFile = new Set(); | ||
} | ||
return prerenderCtx; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters