@@ -142,48 +142,6 @@ function getSupportFilesBundleDefinition(namespace) {
142142 } ;
143143}
144144
145- function createLibraryBundles ( libraryNamespace , resources , excludes ) {
146- return Promise . all ( [
147- moduleBundler ( {
148- options : {
149- bundleDefinition : getBundleDefinition ( libraryNamespace , excludes ) ,
150- bundleOptions : {
151- optimize : true ,
152- usePredefineCalls : true ,
153- ignoreMissingModules : true
154- }
155- } ,
156- resources
157- } ) ,
158- moduleBundler ( {
159- options : {
160- bundleDefinition : getDesigntimeBundleDefinition ( libraryNamespace ) ,
161- bundleOptions : {
162- optimize : true ,
163- usePredefineCalls : true ,
164- ignoreMissingModules : true ,
165- skipIfEmpty : true
166- }
167- } ,
168- resources
169- } ) ,
170- moduleBundler ( {
171- options : {
172- bundleDefinition : getSupportFilesBundleDefinition ( libraryNamespace ) ,
173- bundleOptions : {
174- optimize : false ,
175- usePredefineCalls : true ,
176- ignoreMissingModules : true ,
177- skipIfEmpty : true
178- }
179- // Note: Although the bundle uses optimize=false, there is
180- // no moduleNameMapping needed, as support files are excluded from minification.
181- } ,
182- resources
183- } )
184- ] ) ;
185- }
186-
187145function getModuleBundlerOptions ( config ) {
188146 const moduleBundlerOptions = { } ;
189147
@@ -274,9 +232,10 @@ function getSapUiCoreBunDef(name, filters, preload) {
274232 * inclusion overrides an earlier exclusion, and vice versa.
275233 * @param {object } parameters.options Options
276234 * @param {string } parameters.options.projectName Project name
235+ * @param {string[] } [parameters.options.skipBundles] Names of bundles that should not be created
277236 * @returns {Promise<undefined> } Promise resolving with <code>undefined</code> once data has been written
278237 */
279- module . exports = function ( { workspace, taskUtil, options : { projectName, excludes = [ ] } } ) {
238+ module . exports = function ( { workspace, taskUtil, options : { projectName, skipBundles = [ ] , excludes = [ ] } } ) {
280239 let nonDbgWorkspace = workspace ;
281240 if ( taskUtil ) {
282241 nonDbgWorkspace = workspace . filter ( function ( resource ) {
@@ -285,6 +244,14 @@ module.exports = function({workspace, taskUtil, options: {projectName, excludes
285244 } ) ;
286245 }
287246
247+ const execModuleBundlerIfNeeded = ( { options, resources} ) => {
248+ if ( skipBundles . includes ( options . bundleDefinition . name ) ) {
249+ log . verbose ( `Skipping generation of bundle ${ options . bundleDefinition . name } ` ) ;
250+ return null ;
251+ }
252+ return moduleBundler ( { options, resources} ) ;
253+ } ;
254+
288255 return nonDbgWorkspace . byGlob ( "/**/*.{js,json,xml,html,properties,library,js.map}" ) . then ( async ( resources ) => {
289256 // Find all libraries and create a library-preload.js bundle
290257
@@ -326,32 +293,32 @@ module.exports = function({workspace, taskUtil, options: {projectName, excludes
326293 filters = [ "jquery.sap.global.js" ] ;
327294 }
328295 p = Promise . all ( [
329- moduleBundler ( {
296+ execModuleBundlerIfNeeded ( {
330297 options : getModuleBundlerOptions ( { name : "sap-ui-core.js" , filters, preload : true } ) ,
331298 resources
332299 } ) ,
333- moduleBundler ( {
300+ execModuleBundlerIfNeeded ( {
334301 options : getModuleBundlerOptions ( {
335302 name : "sap-ui-core-dbg.js" , filters, preload : false ,
336303 moduleNameMapping : unoptimizedModuleNameMapping
337304 } ) ,
338305 resources : unoptimizedResources
339306 } ) ,
340- moduleBundler ( {
307+ execModuleBundlerIfNeeded ( {
341308 options : getModuleBundlerOptions ( {
342309 name : "sap-ui-core-nojQuery.js" , filters, preload : true , provided : true
343310 } ) ,
344311 resources
345312 } ) ,
346- moduleBundler ( {
313+ execModuleBundlerIfNeeded ( {
347314 options : getModuleBundlerOptions ( {
348315 name : "sap-ui-core-nojQuery-dbg.js" , filters, preload : false , provided : true ,
349316 moduleNameMapping : unoptimizedModuleNameMapping
350317 } ) ,
351318 resources : unoptimizedResources
352319 } ) ,
353320 ] ) . then ( ( results ) => {
354- const bundles = Array . prototype . concat . apply ( [ ] , results ) ;
321+ const bundles = Array . prototype . concat . apply ( [ ] , results ) . filter ( Boolean ) ;
355322 return Promise . all ( bundles . map ( ( { bundle, sourceMap} ) => {
356323 if ( taskUtil ) {
357324 taskUtil . setTag ( bundle , taskUtil . STANDARD_TAGS . IsBundle ) ;
@@ -390,7 +357,7 @@ module.exports = function({workspace, taskUtil, options: {projectName, excludes
390357 return ;
391358 }
392359
393- return Promise . all ( libraryIndicatorResources . map ( ( libraryIndicatorResource ) => {
360+ return Promise . all ( libraryIndicatorResources . map ( async ( libraryIndicatorResource ) => {
394361 // Determine library namespace from library indicator file path
395362 // ending with either ".library" or "library.js" (see fallback logic above)
396363 // e.g. /resources/sap/foo/.library => sap/foo
@@ -400,28 +367,64 @@ module.exports = function({workspace, taskUtil, options: {projectName, excludes
400367 const libraryNamespaceMatch = libraryIndicatorPath . match ( libraryNamespacePattern ) ;
401368 if ( libraryNamespaceMatch && libraryNamespaceMatch [ 1 ] ) {
402369 const libraryNamespace = libraryNamespaceMatch [ 1 ] ;
403- return createLibraryBundles ( libraryNamespace , resources , excludes )
404- . then ( ( results ) => {
405- const bundles = Array . prototype . concat . apply ( [ ] , results ) ;
406- return Promise . all ( bundles . map ( ( { bundle, sourceMap} = { } ) => {
407- if ( bundle ) {
408- if ( taskUtil ) {
409- taskUtil . setTag ( bundle , taskUtil . STANDARD_TAGS . IsBundle ) ;
410- if ( sourceMap ) {
411- // Clear tag that might have been set by the minify task, in cases where
412- // the bundle name is identical to a source file
413- taskUtil . clearTag ( sourceMap ,
414- taskUtil . STANDARD_TAGS . OmitFromBuildResult ) ;
415- }
416- }
417- const writes = [ workspace . write ( bundle ) ] ;
418- if ( sourceMap ) {
419- writes . push ( workspace . write ( sourceMap ) ) ;
420- }
421- return Promise . all ( writes ) ;
370+ const results = await Promise . all ( [
371+ execModuleBundlerIfNeeded ( {
372+ options : {
373+ bundleDefinition : getBundleDefinition ( libraryNamespace , excludes ) ,
374+ bundleOptions : {
375+ optimize : true ,
376+ usePredefineCalls : true ,
377+ ignoreMissingModules : true
378+ }
379+ } ,
380+ resources
381+ } ) ,
382+ execModuleBundlerIfNeeded ( {
383+ options : {
384+ bundleDefinition : getDesigntimeBundleDefinition ( libraryNamespace ) ,
385+ bundleOptions : {
386+ optimize : true ,
387+ usePredefineCalls : true ,
388+ ignoreMissingModules : true ,
389+ skipIfEmpty : true
422390 }
423- } ) ) ;
424- } ) ;
391+ } ,
392+ resources
393+ } ) ,
394+ execModuleBundlerIfNeeded ( {
395+ options : {
396+ bundleDefinition : getSupportFilesBundleDefinition ( libraryNamespace ) ,
397+ bundleOptions : {
398+ optimize : false ,
399+ usePredefineCalls : true ,
400+ ignoreMissingModules : true ,
401+ skipIfEmpty : true
402+ }
403+ // Note: Although the bundle uses optimize=false, there is
404+ // no moduleNameMapping needed, as support files are excluded from minification.
405+ } ,
406+ resources
407+ } )
408+ ] ) ;
409+ const bundles = Array . prototype . concat . apply ( [ ] , results ) . filter ( Boolean ) ;
410+ return Promise . all ( bundles . map ( ( { bundle, sourceMap} = { } ) => {
411+ if ( bundle ) {
412+ if ( taskUtil ) {
413+ taskUtil . setTag ( bundle , taskUtil . STANDARD_TAGS . IsBundle ) ;
414+ if ( sourceMap ) {
415+ // Clear tag that might have been set by the minify task, in cases where
416+ // the bundle name is identical to a source file
417+ taskUtil . clearTag ( sourceMap ,
418+ taskUtil . STANDARD_TAGS . OmitFromBuildResult ) ;
419+ }
420+ }
421+ const writes = [ workspace . write ( bundle ) ] ;
422+ if ( sourceMap ) {
423+ writes . push ( workspace . write ( sourceMap ) ) ;
424+ }
425+ return Promise . all ( writes ) ;
426+ }
427+ } ) ) ;
425428 } else {
426429 log . verbose (
427430 `Could not determine library namespace from file "${ libraryIndicatorPath } " ` +
0 commit comments