@@ -22,7 +22,8 @@ export default function cache(options: CacheOptions) {
2222 manifest : options . manifestPath
2323 } ;
2424 //if there's a server path
25- if ( paths . server ) {
25+ if ( typeof paths . server === 'string' ) {
26+ const server = paths . server ;
2627 //on pre render, try to use cache
2728 emitter . on ( 'render' , ( event : Event < string > ) => {
2829 //extract props and builder from params
@@ -31,7 +32,7 @@ export default function cache(options: CacheOptions) {
3132 //get id ie. abc123c
3233 const id = serialize ( builder . document . source ) ;
3334 //get cache file path ie. /path/to/docs/build/server/abc123c.js
34- const cache = path . join ( paths . server , `${ id } .js` ) ;
35+ const cache = path . join ( server , `${ id } .js` ) ;
3536 //if cache file exists
3637 if ( fs . existsSync ( cache ) ) {
3738 //get the build object
@@ -52,23 +53,24 @@ export default function cache(options: CacheOptions) {
5253 //get fs and id ie. abc123c
5354 const id = serialize ( builder . document . source ) ;
5455 //get cache file path ie. /path/to/docs/build/server/abc123c.js
55- const cache = path . join ( paths . server , `${ id } .js` ) ;
56+ const cache = path . join ( server , `${ id } .js` ) ;
5657 //if cache file exists, send it
5758 if ( fs . existsSync ( cache ) ) {
5859 event . set ( fs . readFileSync ( cache , 'utf8' ) ) ;
5960 }
6061 } ) ;
6162 }
6263 //if there's a client path
63- if ( paths . client ) {
64+ if ( typeof paths . client === 'string' ) {
65+ const client = paths . client ;
6466 //on pre client build, try to use cache
6567 emitter . on ( 'build-client' , ( event : Event < string > ) => {
6668 //extract builder from params
6769 const builder = event . params . builder as Builder ;
6870 //get fs and id ie. abc123c
6971 const id = serialize ( builder . document . source ) ;
7072 //get cache file path ie. /path/to/docs/build/client/abc123c.js
71- const cache = path . join ( paths . client , `${ id } .js` ) ;
73+ const cache = path . join ( client , `${ id } .js` ) ;
7274 //if cache file exists, send it
7375 if ( fs . existsSync ( cache ) ) {
7476 event . set ( fs . readFileSync ( cache , 'utf8' ) ) ;
@@ -82,15 +84,15 @@ export default function cache(options: CacheOptions) {
8284 //get fs and id ie. abc123c
8385 const id = serialize ( builder . document . source ) ;
8486 //get cache file path ie. /path/to/docs/build/client/abc123c.css
85- const cache = path . join ( paths . client , `${ id } .css` ) ;
87+ const cache = path . join ( client , `${ id } .css` ) ;
8688 //if cache file exists, send it
8789 if ( fs . existsSync ( cache ) ) {
8890 event . set ( fs . readFileSync ( cache , 'utf8' ) ) ;
8991 }
9092 } ) ;
9193 }
9294 //if there's a manifest
93- if ( paths . manifest && fs . existsSync ( paths . manifest ) ) {
95+ if ( typeof paths . manifest === 'string' && fs . existsSync ( paths . manifest ) ) {
9496 //load the manifest file
9597 compiler . manifest . load (
9698 JSON . parse ( fs . readFileSync ( paths . manifest , 'utf-8' ) )
0 commit comments