This repository was archived by the owner on Dec 7, 2018. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,15 +27,7 @@ function testPathToChunkUrl(testPath) {
2727 */
2828function middleware ( routeBuilder ) {
2929 return function middleware ( req , res , next ) {
30- const commonAssetsObj = _ . omitBy (
31- res . locals . webpackStats . toJson ( ) . assetsByChunkName ,
32- value => / \. b u n d l e .j s $ / . test ( value )
33- ) ;
34- const commonAssets = Object . keys ( commonAssetsObj ) . reduce ( ( result , item ) => {
35- result . push ( assetsRoot ( ) + commonAssetsObj [ item ] ) ;
36- return result ;
37- } , [ ] ) ;
38-
30+ const commonAssets = readCommonAssets ( res . locals . webpackStats ) ;
3931 log ( `request to ${ req . path } ` ) ;
4032 if ( routeBuilder . isUrlRegistered ( req . path ) ) {
4133 log ( 'this is a test page url' ) ;
@@ -48,6 +40,19 @@ function middleware(routeBuilder) {
4840 } ;
4941}
5042
43+ function readCommonAssets ( webpackStats ) {
44+ if ( ! webpackStats ) {
45+ return [ ] ;
46+ }
47+ const commonAssetsObj = _ . omitBy (
48+ webpackStats . toJson ( ) . assetsByChunkName ,
49+ value => / \. b u n d l e .j s $ / . test ( value )
50+ ) ;
51+ return Object . keys ( commonAssetsObj ) . reduce ( ( result , item ) => {
52+ result . push ( assetsRoot ( ) + commonAssetsObj [ item ] ) ;
53+ return result ;
54+ } , [ ] ) ;
55+ }
5156
5257exports . testPathToChunkName = testPathToChunkName ;
5358exports . testPathToChunkUrl = testPathToChunkUrl ;
You can’t perform that action at this time.
0 commit comments