diff --git a/lib/lbt/resources/ResourceCollector.js b/lib/lbt/resources/ResourceCollector.js index 9b6361a96..79790fb18 100644 --- a/lib/lbt/resources/ResourceCollector.js +++ b/lib/lbt/resources/ResourceCollector.js @@ -150,16 +150,25 @@ class ResourceCollector { }); } - async determineResourceDetails({pool, debugResources, mergedResources, designtimeResources, supportResources}) { + async determineResourceDetails({ + debugResources, mergedResources, designtimeResources, supportResources, debugBundles + }) { 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 = []; for (const [name, info] of this._resources.entries()) { + if ( debugFilter.matches(name) ) { + info.isDebug = true; + log.verbose(` found potential debug resource '${name}'`); + } + // log.verbose(` checking ${name}`); let m; if ( m = LOCALE.exec(name) ) { @@ -180,9 +189,14 @@ class ResourceCollector { } if ( /(?:\.js|\.view\.xml|\.control\.xml|\.fragment\.xml)$/.test(name) ) { - promises.push( - this.enrichWithDependencyInfo(info) - ); + if ( (!info.isDebug || debugBundleFilter.matches(name)) ) { + // Only analyze non-debug files which are not special debug bundles (like sap-ui-core-dbg.js) + promises.push( + this.enrichWithDependencyInfo(info) + ); + } else { + nonBundledDebugResources.push(info); + } } // set the module name for .properties and .json @@ -197,11 +211,6 @@ class ResourceCollector { })); } - if ( debugFilter.matches(name) ) { - info.isDebug = true; - log.verbose(` found potential debug resource '${name}'`); - } - if ( mergeFilter.matches(name) ) { info.merged = true; log.verbose(` found potential merged resource '${name}'`); @@ -226,7 +235,17 @@ class ResourceCollector { } } - return Promise.all(promises); + await Promise.all(promises); + + for (let i = nonBundledDebugResources.length - 1; i >= 0; i--) { + const dbgInfo = nonBundledDebugResources[i]; + const nonDebugName = ResourceInfoList.getNonDebugName(dbgInfo.name); + const nonDbgInfo = this._resources.get(nonDebugName); + const newDbgInfo = new ResourceInfo(dbgInfo.name); + newDbgInfo.copyFrom(null, nonDbgInfo); + newDbgInfo.copyFrom(null, dbgInfo); + this._resources.set(dbgInfo.name, newDbgInfo); + } } createOrphanFilters() { @@ -253,19 +272,17 @@ class ResourceCollector { groupResourcesByComponents(options) { const orphanFilters = this.createOrphanFilters(); - const debugBundlesFilter = new ResourceFilterList(options.debugBundles); for (const resource of this._resources.values()) { let contained = false; for (const [prefix, list] of this._components.entries()) { - const isDebugBundle = debugBundlesFilter.matches(resource.name); if ( resource.name.startsWith(prefix) ) { - list.add(resource, !isDebugBundle); + list.add(resource); contained = true; } else if ( orphanFilters.has(prefix) ) { // log.verbose(` checking '${resource.name}' against orphan filter ` + // `'${orphanFilters.get(prefix)}' (${prefix})`); if ( orphanFilters.get(prefix).matches(resource.name) ) { - list.add(resource, !isDebugBundle); + list.add(resource); contained = true; } } diff --git a/lib/lbt/resources/ResourceInfoList.js b/lib/lbt/resources/ResourceInfoList.js index af5b655ea..2a0413898 100644 --- a/lib/lbt/resources/ResourceInfoList.js +++ b/lib/lbt/resources/ResourceInfoList.js @@ -39,37 +39,12 @@ class ResourceInfoList { * Add ResourceInfo to list * * @param {ResourceInfo} info - * @param {boolean} shareDebugInformation */ - add(info, shareDebugInformation=true) { + add(info) { const relativeName = ResourceInfoList.makePathRelativeTo(this.name, info.name); - // search for a resource with the same name let myInfo = this.resourcesByName.get(relativeName); - if ( myInfo == null && shareDebugInformation) { - // when not found, check if the given resource is a debug resource and - // share the information with the non-dbg version - const nonDbgName = ResourceInfoList.getNonDebugName(relativeName); - const dbgName = ResourceInfoList.getDebugName(relativeName); - if ( nonDbgName != null && this.resourcesByName.has(nonDbgName) ) { - // copy from source - myInfo = new ResourceInfo(relativeName); - const source = this.resourcesByName.get(nonDbgName); - myInfo.copyFrom(this.name, source); - this.resources.push(myInfo); - this.resourcesByName.set(relativeName, myInfo); - } else if (dbgName != null && this.resourcesByName.has(dbgName)) { - // copy from debug - myInfo = new ResourceInfo(relativeName); - const source = this.resourcesByName.get(dbgName); - myInfo.copyFrom(this.name, source); - myInfo.module = ResourceInfoList.getNonDebugName(source.module); - this.resources.push(myInfo); - this.resourcesByName.set(relativeName, myInfo); - } - } - // this is the assumption, that the debug one is the same as the non-dbg one if ( myInfo == null ) { myInfo = new ResourceInfo(relativeName); diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 0ac67e1e6..11645fc17 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -73,7 +73,8 @@ const DEFAULT_SUPPORT_RESOURCES_FILTER = [ * @type {string[]} */ const DEBUG_BUNDLES = [ - "sap-ui-core-dbg.js" + "sap-ui-core-dbg.js", + "sap-ui-core-nojQuery-dbg.js" ]; /** @@ -159,13 +160,12 @@ module.exports = async function({resources, options}) { debugResources: options.debugResources, mergedResources: options.mergedResources, designtimeResources: options.designtimeResources, - supportResources: options.supportResources + supportResources: options.supportResources, + debugBundles: options.debugBundles }); // group resources by components and create ResourceInfoLists - collector.groupResourcesByComponents({ - debugBundles: options.debugBundles - }); + collector.groupResourcesByComponents(); const resourceLists = [];