@@ -31,7 +31,9 @@ function saveBundleAndMap(bundle, options, log) {
3131 bundleOutput,
3232 bundleEncoding : encoding ,
3333 dev,
34- sourcemapOutput
34+ sourcemapOutput,
35+ // @mc -zone
36+ manifestOutput,
3537 } = options ;
3638
3739 log ( 'start' ) ;
@@ -49,14 +51,35 @@ function saveBundleAndMap(bundle, options, log) {
4951 Promise . all ( [ writeBundle , writeMetadata ] )
5052 . then ( ( ) => log ( 'Done writing bundle output' ) ) ;
5153
54+ // @mc -zone
55+ const writeTasks = [ writeBundle ] ;
56+
5257 if ( sourcemapOutput ) {
5358 log ( 'Writing sourcemap output to:' , sourcemapOutput ) ;
5459 const writeMap = writeFile ( sourcemapOutput , codeWithMap . map , null ) ;
5560 writeMap . then ( ( ) => log ( 'Done writing sourcemap output' ) ) ;
56- return Promise . all ( [ writeBundle , writeMetadata , writeMap ] ) ;
57- } else {
58- return writeBundle ;
61+ // @mc -zone
62+ // return Promise.all([writeBundle, writeMetadata, writeMap]);
63+ // } else {
64+ // return writeBundle;
65+ writeTasks . push ( writeMetadata , writeMap ) ;
66+ }
67+
68+ // @mc -zone
69+ if ( manifestOutput ) {
70+ log ( 'Writing manifest output to:' , manifestOutput ) ;
71+ const manifest = createBundleManifest ( bundle ) ;
72+ const writeManifest = writeFile ( manifestOutput , manifest , null ) ;
73+ writeManifest . then ( ( ) => log ( 'Done writing manifest output' ) ) ;
74+ writeTasks . push ( writeManifest ) ;
5975 }
76+
77+ return Promise . all ( writeTasks ) ;
78+ }
79+
80+ // @mc -zone
81+ function createBundleManifest ( bundle ) {
82+ return JSON . stringify ( bundle . getManifest ( ) , null , 2 ) ;
6083}
6184
6285exports . build = buildBundle ;
0 commit comments