diff --git a/lib/lbt/resources/ResourceCollector.js b/lib/lbt/resources/ResourceCollector.js index 3acc2f88d..b962ca9e7 100644 --- a/lib/lbt/resources/ResourceCollector.js +++ b/lib/lbt/resources/ResourceCollector.js @@ -193,17 +193,16 @@ class ResourceCollector { } async determineResourceDetails({ - debugResources, mergedResources, designtimeResources, supportResources, debugBundles + debugResources, mergedResources, designtimeResources, supportResources }) { const baseNames = new Set(); const debugFilter = new ResourceFilterList(debugResources); const mergeFilter = new ResourceFilterList(mergedResources); const designtimeFilter = new ResourceFilterList(designtimeResources); const supportFilter = new ResourceFilterList(supportResources); - const debugBundleFilter = new ResourceFilterList(debugBundles); const promises = []; - const nonBundledDebugResources = []; + const debugResourcesInfo = []; for (const [name, info] of this._resources.entries()) { if ( debugFilter.matches(name) ) { @@ -231,13 +230,14 @@ class ResourceCollector { } if ( /(?:\.js|\.view\.xml|\.control\.xml|\.fragment\.xml)$/.test(name) ) { - if ( (!info.isDebug || debugBundleFilter.matches(name)) ) { - // Only analyze non-debug files and special debug bundles (like sap-ui-core-dbg.js) + if ( !info.isDebug ) { + // Only analyze non-dbg files in first run promises.push( this.enrichWithDependencyInfo(info) ); } else { - nonBundledDebugResources.push(info); + // Collect dbg files to be handled in a second step (see below) + debugResourcesInfo.push(info); } } @@ -279,19 +279,37 @@ class ResourceCollector { await Promise.all(promises); - for (let i = nonBundledDebugResources.length - 1; i >= 0; i--) { - const dbgInfo = nonBundledDebugResources[i]; + const debugBundlePromises = []; + + for (let i = debugResourcesInfo.length - 1; i >= 0; i--) { + const dbgInfo = debugResourcesInfo[i]; const nonDebugName = ResourceInfoList.getNonDebugName(dbgInfo.name); const nonDbgInfo = this._resources.get(nonDebugName); - const newDbgInfo = new ResourceInfo(dbgInfo.name); - - // First copy info of analysis from non-dbg file (included, required, condRequired, ...) - newDbgInfo.copyFrom(null, nonDbgInfo); - // Then copy over info from dbg file to properly set name, isDebug, etc. - newDbgInfo.copyFrom(null, dbgInfo); - this._resources.set(dbgInfo.name, newDbgInfo); + // FIXME: "merged" property is only calculated in ResourceInfo#copyFrom + // Therefore using the same logic here to compute it. + if (nonDbgInfo.included != null && nonDbgInfo.included.size > 0) { + // We need to analyze the dbg resource if the non-dbg variant is a bundle + // because we will (usually) have different content. + debugBundlePromises.push( + this.enrichWithDependencyInfo(dbgInfo) + ); + } else { + // If the non-dbg resource is not a bundle, we can just copy over the info and skip + // analyzing the dbg variant as both should have the same info. + + const newDbgInfo = new ResourceInfo(dbgInfo.name); + + // First copy info of analysis from non-dbg file (included, required, condRequired, ...) + newDbgInfo.copyFrom(null, nonDbgInfo); + // Then copy over info from dbg file to properly set name, isDebug, etc. + newDbgInfo.copyFrom(null, dbgInfo); + + this._resources.set(dbgInfo.name, newDbgInfo); + } } + + await Promise.all(debugBundlePromises); } createOrphanFilters() { diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index ba012488a..c26e2fa54 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -66,17 +66,6 @@ const DEFAULT_SUPPORT_RESOURCES_FILTER = [ "**/*.support.js" ]; -/** - * Hard coded debug bundle, to trigger separate analysis for this filename - * because sap-ui-core.js and sap-ui-core-dbg.js have different includes - * - * @type {string[]} - */ -const DEBUG_BUNDLES = [ - "sap-ui-core-dbg.js", - "sap-ui-core-nojQuery-dbg.js" -]; - /** * Creates and adds resources.json entry (itself) to the list. * @@ -138,8 +127,7 @@ module.exports = async function({resources, dependencyResources = [], options}) debugResources: DEFAULT_DEBUG_RESOURCES_FILTER, mergedResources: DEFAULT_BUNDLE_RESOURCES_FILTER, designtimeResources: DEFAULT_DESIGNTIME_RESOURCES_FILTER, - supportResources: DEFAULT_SUPPORT_RESOURCES_FILTER, - debugBundles: DEBUG_BUNDLES + supportResources: DEFAULT_SUPPORT_RESOURCES_FILTER }, options); const pool = new LocatorResourcePool(); @@ -162,8 +150,7 @@ module.exports = async function({resources, dependencyResources = [], options}) debugResources: options.debugResources, mergedResources: options.mergedResources, designtimeResources: options.designtimeResources, - supportResources: options.supportResources, - debugBundles: options.debugBundles + supportResources: options.supportResources }); // group resources by components and create ResourceInfoLists