@@ -53,35 +53,43 @@ module.exports = (api, options) => {
5353    } 
5454
5555    process . env . VUE_CLI_BUILD_TARGET  =  args . target 
56-     if  ( args . module  &&  args . target  ===  'app' )  { 
57-       process . env . VUE_CLI_MODERN_MODE  =  true 
58-       if  ( ! process . env . VUE_CLI_MODERN_BUILD )  { 
59-         // main-process for legacy build 
60-         await  build ( Object . assign ( { } ,  args ,  { 
61-           modernBuild : false , 
62-           keepAlive : true 
63-         } ) ,  api ,  options ) 
64-         // spawn sub-process of self for modern build 
65-         const  {  execa }  =  require ( '@vue/cli-shared-utils' ) 
66-         const  cliBin  =  require ( 'path' ) . resolve ( __dirname ,  '../../../bin/vue-cli-service.js' ) 
67-         await  execa ( 'node' ,  [ cliBin ,  'build' ,  ...rawArgs ] ,  { 
68-           stdio : 'inherit' , 
69-           env : { 
70-             VUE_CLI_MODERN_BUILD : true 
71-           } 
72-         } ) 
73-       }  else  { 
74-         // sub-process for modern build 
75-         await  build ( Object . assign ( { } ,  args ,  { 
76-           modernBuild : true , 
77-           clean : false 
78-         } ) ,  api ,  options ) 
79-       } 
80-       delete  process . env . VUE_CLI_MODERN_MODE 
81-     }  else  { 
56+ 
57+     const  {  log,  execa }  =  require ( '@vue/cli-shared-utils' ) 
58+     const  {  allProjectTargetsSupportModule }  =  require ( '../../util/targets' ) 
59+ 
60+     let  needsDifferentialLoading  =  args . target  ===  'app'  &&  args . module 
61+     if  ( allProjectTargetsSupportModule )  { 
62+       log ( 
63+         `All browser targets in the browserslist configuration have supported ES module.\n`  + 
64+         `Therefore we don't build two separate bundles for differential loading.\n` 
65+       ) 
66+       needsDifferentialLoading  =  false 
67+     } 
68+ 
69+     if  ( ! needsDifferentialLoading )  { 
8270      await  build ( args ,  api ,  options ) 
71+       return 
72+     } 
73+ 
74+     process . env . VUE_CLI_MODERN_MODE  =  true 
75+     if  ( ! process . env . VUE_CLI_MODERN_BUILD )  { 
76+       // main-process for legacy build 
77+       const  legacyBuildArgs  =  {  ...args ,  moduleBuild : false ,  keepAlive : true  } 
78+       await  build ( legacyBuildArgs ,  api ,  options ) 
79+ 
80+       // spawn sub-process of self for modern build 
81+       const  cliBin  =  require ( 'path' ) . resolve ( __dirname ,  '../../../bin/vue-cli-service.js' ) 
82+       await  execa ( 'node' ,  [ cliBin ,  'build' ,  ...rawArgs ] ,  { 
83+         stdio : 'inherit' , 
84+         env : { 
85+           VUE_CLI_MODERN_BUILD : true 
86+         } 
87+       } ) 
88+     }  else  { 
89+       // sub-process for modern build 
90+       const  moduleBuildArgs  =  {  ...args ,  moduleBuild : true ,  clean : false  } 
91+       await  build ( moduleBuildArgs ,  api ,  options ) 
8392    } 
84-     delete  process . env . VUE_CLI_BUILD_TARGET 
8593  } ) 
8694} 
8795
@@ -104,8 +112,8 @@ async function build (args, api, options) {
104112  const  mode  =  api . service . mode 
105113  if  ( args . target  ===  'app' )  { 
106114    const  bundleTag  =  args . module 
107-       ? args . modernBuild 
108-         ? `modern  bundle ` 
115+       ? args . moduleBuild 
116+         ? `module  bundle ` 
109117        : `legacy bundle ` 
110118      : `` 
111119    logWithSpinner ( `Building ${ bundleTag } ${ mode }  ) 
@@ -125,7 +133,7 @@ async function build (args, api, options) {
125133  } 
126134
127135  const  targetDir  =  api . resolve ( options . outputDir ) 
128-   const  isLegacyBuild  =  args . target  ===  'app'  &&  args . module  &&  ! args . modernBuild 
136+   const  isLegacyBuild  =  args . target  ===  'app'  &&  args . module  &&  ! args . moduleBuild 
129137
130138  // resolve raw webpack config 
131139  let  webpackConfig 
@@ -162,7 +170,7 @@ async function build (args, api, options) {
162170    modifyConfig ( webpackConfig ,  config  =>  { 
163171      config . plugins . push ( new  DashboardPlugin ( { 
164172        type : 'build' , 
165-         modernBuild : args . modernBuild , 
173+         moduleBuild : args . moduleBuild , 
166174        keepAlive : args . keepAlive 
167175      } ) ) 
168176    } ) 
0 commit comments