@@ -223,7 +223,7 @@ export function buildWebpackBrowser(
223
223
const host = new NodeJsSyncHost ( ) ;
224
224
const root = normalize ( context . workspaceRoot ) ;
225
225
226
- const projectName = context . target && context . target . project ;
226
+ const projectName = context . target ? .project ;
227
227
if ( ! projectName ) {
228
228
throw new Error ( 'The builder requires a target.' ) ;
229
229
}
@@ -596,9 +596,9 @@ export function buildWebpackBrowser(
596
596
{
597
597
size : bundle . size ,
598
598
files : bundle . map ? [ bundle . filename , bundle . map . filename ] : [ bundle . filename ] ,
599
- names : chunk && chunk . names ,
600
- entry : ! ! chunk && chunk . names . includes ( 'runtime' ) ,
601
- initial : ! ! chunk && chunk . initial ,
599
+ names : chunk ? .names ,
600
+ entry : ! ! chunk ? .names . includes ( 'runtime' ) ,
601
+ initial : ! ! chunk ? .initial ,
602
602
rendered : true ,
603
603
} ,
604
604
true ,
@@ -607,8 +607,7 @@ export function buildWebpackBrowser(
607
607
608
608
const bundleInfoStats : BundleStats [ ] = [ ] ;
609
609
for ( const result of processResults ) {
610
- const chunk = webpackStats . chunks
611
- && webpackStats . chunks . find ( ( chunk ) => chunk . id . toString ( ) === result . name ) ;
610
+ const chunk = webpackStats . chunks ?. find ( ( chunk ) => chunk . id . toString ( ) === result . name ) ;
612
611
613
612
if ( result . original ) {
614
613
bundleInfoStats . push ( generateBundleInfoStats ( result . original , chunk ) ) ;
@@ -619,22 +618,20 @@ export function buildWebpackBrowser(
619
618
}
620
619
}
621
620
622
- const unprocessedChunks = webpackStats . chunks && webpackStats . chunks
623
- . filter ( ( chunk ) => ! processResults
624
- . find ( ( result ) => chunk . id . toString ( ) === result . name ) ,
625
- ) || [ ] ;
621
+ const unprocessedChunks = webpackStats . chunks ?. filter ( ( chunk ) => ! processResults
622
+ . find ( ( result ) => chunk . id . toString ( ) === result . name ) ,
623
+ ) || [ ] ;
626
624
for ( const chunk of unprocessedChunks ) {
627
- const asset =
628
- webpackStats . assets && webpackStats . assets . find ( a => a . name === chunk . files [ 0 ] ) ;
629
- bundleInfoStats . push ( generateBundleStats ( { ...chunk , size : asset && asset . size } , true ) ) ;
625
+ const asset = webpackStats . assets ?. find ( a => a . name === chunk . files [ 0 ] ) ;
626
+ bundleInfoStats . push ( generateBundleStats ( { ...chunk , size : asset ?. size } , true ) ) ;
630
627
}
631
628
632
629
context . logger . info (
633
630
'\n' +
634
631
generateBuildStatsTable ( bundleInfoStats , colors . enabled ) +
635
632
'\n\n' +
636
633
generateBuildStats (
637
- ( webpackStats && webpackStats . hash ) || '<unknown>' ,
634
+ webpackStats ? .hash || '<unknown>' ,
638
635
Date . now ( ) - startTime ,
639
636
true ,
640
637
) ,
@@ -706,17 +703,17 @@ export function buildWebpackBrowser(
706
703
}
707
704
}
708
705
709
- if ( options . index ) {
710
- for ( const [ locale , outputPath ] of outputPaths . entries ( ) ) {
711
- let localeBaseHref ;
712
- if ( i18n . locales [ locale ] && i18n . locales [ locale ] . baseHref !== '' ) {
713
- localeBaseHref = urlJoin (
714
- options . baseHref || '' ,
715
- i18n . locales [ locale ] . baseHref ?? `/${ locale } /` ,
716
- ) ;
717
- }
706
+ for ( const [ locale , outputPath ] of outputPaths . entries ( ) ) {
707
+ let localeBaseHref ;
708
+ if ( i18n . locales [ locale ] && i18n . locales [ locale ] . baseHref !== '' ) {
709
+ localeBaseHref = urlJoin (
710
+ options . baseHref || '' ,
711
+ i18n . locales [ locale ] . baseHref ?? `/${ locale } /` ,
712
+ ) ;
713
+ }
718
714
719
- try {
715
+ try {
716
+ if ( options . index ) {
720
717
await generateIndex (
721
718
outputPath ,
722
719
options ,
@@ -729,23 +726,9 @@ export function buildWebpackBrowser(
729
726
locale || options . i18nLocale ,
730
727
localeBaseHref || options . baseHref ,
731
728
) ;
732
- } catch ( err ) {
733
- return { success : false , error : mapErrorToMessage ( err ) } ;
734
729
}
735
- }
736
- }
737
730
738
- if ( options . serviceWorker ) {
739
- for ( const [ locale , outputPath ] of outputPaths . entries ( ) ) {
740
- let localeBaseHref ;
741
- if ( i18n . locales [ locale ] && i18n . locales [ locale ] . baseHref !== '' ) {
742
- localeBaseHref = urlJoin (
743
- options . baseHref || '' ,
744
- i18n . locales [ locale ] . baseHref ?? `/${ locale } /` ,
745
- ) ;
746
- }
747
-
748
- try {
731
+ if ( options . serviceWorker ) {
749
732
await augmentAppWithServiceWorker (
750
733
host ,
751
734
root ,
@@ -754,9 +737,9 @@ export function buildWebpackBrowser(
754
737
localeBaseHref || options . baseHref || '/' ,
755
738
options . ngswConfigPath ,
756
739
) ;
757
- } catch ( err ) {
758
- return { success : false , error : mapErrorToMessage ( err ) } ;
759
740
}
741
+ } catch ( err ) {
742
+ return { success : false , error : mapErrorToMessage ( err ) } ;
760
743
}
761
744
}
762
745
}
0 commit comments