@@ -106,6 +106,46 @@ function getBundleDefinition(namespace, excludes) {
106106 } ;
107107}
108108
109+ function getBundleInfoPreloadDefinition ( namespace , excludes ) {
110+ return {
111+ name : `${ namespace } /library-preload.js` ,
112+ sections : [ {
113+ mode : "preload" ,
114+ filters : [
115+ `${ namespace } /library.js` ,
116+ ] ,
117+ resolve : true
118+ } ,
119+ {
120+ mode : "bundleInfo" ,
121+ name : `${ namespace } /library-content.js` ,
122+ filters : getDefaultLibraryPreloadFilters ( namespace , excludes ) ,
123+ resolve : false ,
124+ resolveConditional : false ,
125+ renderer : true
126+ } ]
127+ } ;
128+ }
129+
130+ function getContentBundleDefinition ( namespace , excludes ) {
131+ return {
132+ name : `${ namespace } /library-content.js` ,
133+ sections : [ {
134+ mode : "provided" ,
135+ filters : [
136+ `${ namespace } /library.js` ,
137+ ] ,
138+ resolve : true
139+ } , {
140+ mode : "preload" ,
141+ filters : getDefaultLibraryPreloadFilters ( namespace , excludes ) ,
142+ resolve : false ,
143+ resolveConditional : false ,
144+ renderer : true
145+ } ]
146+ } ;
147+ }
148+
109149function getDesigntimeBundleDefinition ( namespace ) {
110150 return {
111151 name : `${ namespace } /designtime/library-preload.designtime.js` ,
@@ -258,6 +298,7 @@ export default async function({workspace, taskUtil, options: {skipBundles = [],
258298 }
259299 const coreVersion = taskUtil ?. getProject ( "sap.ui.core" ) ?. getVersion ( ) ;
260300 const allowStringBundling = taskUtil ?. getProject ( ) . getSpecVersion ( ) . lt ( "4.0" ) ;
301+ const createBundleInfoPreload = ! ! process . env . UI5_CLI_EXPERIMENTAL_BUNDLE_INFO_PRELOAD ;
261302 const execModuleBundlerIfNeeded = ( { options, resources} ) => {
262303 if ( skipBundles . includes ( options . bundleDefinition . name ) ) {
263304 log . verbose ( `Skipping generation of bundle ${ options . bundleDefinition . name } ` ) ;
@@ -390,42 +431,97 @@ export default async function({workspace, taskUtil, options: {skipBundles = [],
390431 const libraryNamespaceMatch = libraryIndicatorPath . match ( libraryNamespacePattern ) ;
391432 if ( libraryNamespaceMatch && libraryNamespaceMatch [ 1 ] ) {
392433 const libraryNamespace = libraryNamespaceMatch [ 1 ] ;
393- const results = await Promise . all ( [
394- execModuleBundlerIfNeeded ( {
395- options : {
396- bundleDefinition : getBundleDefinition ( libraryNamespace , excludes ) ,
397- bundleOptions : {
398- optimize : true ,
399- ignoreMissingModules : true
400- }
401- } ,
402- resources
403- } ) ,
404- execModuleBundlerIfNeeded ( {
405- options : {
406- bundleDefinition : getDesigntimeBundleDefinition ( libraryNamespace ) ,
407- bundleOptions : {
408- optimize : true ,
409- ignoreMissingModules : true ,
410- skipIfEmpty : true
411- }
412- } ,
413- resources
414- } ) ,
415- execModuleBundlerIfNeeded ( {
416- options : {
417- bundleDefinition : getSupportFilesBundleDefinition ( libraryNamespace ) ,
418- bundleOptions : {
419- optimize : false ,
420- ignoreMissingModules : true ,
421- skipIfEmpty : true
422- }
423- // Note: Although the bundle uses optimize=false, there is
424- // no moduleNameMapping needed, as support files are excluded from minification.
425- } ,
426- resources
427- } )
428- ] ) ;
434+ let results ;
435+ if ( ! createBundleInfoPreload ) {
436+ // Regular bundling
437+ results = await Promise . all ( [
438+ execModuleBundlerIfNeeded ( {
439+ options : {
440+ bundleDefinition : getBundleDefinition ( libraryNamespace , excludes ) ,
441+ bundleOptions : {
442+ optimize : true ,
443+ ignoreMissingModules : true
444+ }
445+ } ,
446+ resources
447+ } ) ,
448+ execModuleBundlerIfNeeded ( {
449+ options : {
450+ bundleDefinition : getDesigntimeBundleDefinition ( libraryNamespace ) ,
451+ bundleOptions : {
452+ optimize : true ,
453+ ignoreMissingModules : true ,
454+ skipIfEmpty : true
455+ }
456+ } ,
457+ resources
458+ } ) ,
459+ execModuleBundlerIfNeeded ( {
460+ options : {
461+ bundleDefinition : getSupportFilesBundleDefinition ( libraryNamespace ) ,
462+ bundleOptions : {
463+ optimize : false ,
464+ ignoreMissingModules : true ,
465+ skipIfEmpty : true
466+ }
467+ // Note: Although the bundle uses optimize=false, there is
468+ // no moduleNameMapping needed, as support files are excluded from minification.
469+ } ,
470+ resources
471+ } )
472+ ] ) ;
473+ } else {
474+ log . info (
475+ `Using experimental bundling with bundle info preload ` +
476+ `for library ${ libraryNamespace } in project ${ projectName } .` ) ;
477+ // Experimental bundling with bundle info preload
478+ results = await Promise . all ( [
479+ execModuleBundlerIfNeeded ( {
480+ options : {
481+ bundleDefinition : getBundleInfoPreloadDefinition ( libraryNamespace , excludes ) ,
482+ bundleOptions : {
483+ optimize : true ,
484+ ignoreMissingModules : true
485+ }
486+ } ,
487+ resources
488+ } ) ,
489+ execModuleBundlerIfNeeded ( {
490+ options : {
491+ bundleDefinition : getContentBundleDefinition ( libraryNamespace , excludes ) ,
492+ bundleOptions : {
493+ optimize : true ,
494+ ignoreMissingModules : true
495+ }
496+ } ,
497+ resources
498+ } ) ,
499+ execModuleBundlerIfNeeded ( {
500+ options : {
501+ bundleDefinition : getDesigntimeBundleDefinition ( libraryNamespace ) ,
502+ bundleOptions : {
503+ optimize : true ,
504+ ignoreMissingModules : true ,
505+ skipIfEmpty : true
506+ }
507+ } ,
508+ resources
509+ } ) ,
510+ execModuleBundlerIfNeeded ( {
511+ options : {
512+ bundleDefinition : getSupportFilesBundleDefinition ( libraryNamespace ) ,
513+ bundleOptions : {
514+ optimize : false ,
515+ ignoreMissingModules : true ,
516+ skipIfEmpty : true
517+ }
518+ // Note: Although the bundle uses optimize=false, there is
519+ // no moduleNameMapping needed, as support files are excluded from minification.
520+ } ,
521+ resources
522+ } )
523+ ] ) ;
524+ }
429525 const bundles = Array . prototype . concat . apply ( [ ] , results ) . filter ( Boolean ) ;
430526 return Promise . all ( bundles . map ( ( { bundle, sourceMap} = { } ) => {
431527 if ( bundle ) {
0 commit comments