diff --git a/lib/lbt/bundle/AutoSplitter.js b/lib/lbt/bundle/AutoSplitter.js index d9eb9091d..114471f8a 100644 --- a/lib/lbt/bundle/AutoSplitter.js +++ b/lib/lbt/bundle/AutoSplitter.js @@ -47,7 +47,7 @@ class AutoSplitter { this.optimize = !!options.optimize; // ---- resolve module definition - const resolvedModule = await this.resolver.resolve(moduleDef, options); + const resolvedModule = await this.resolver.resolve(moduleDef); // ---- calculate overall size of merged module if ( moduleDef.configuration ) { diff --git a/lib/lbt/bundle/Builder.js b/lib/lbt/bundle/Builder.js index c4993704f..819d54e4e 100644 --- a/lib/lbt/bundle/Builder.js +++ b/lib/lbt/bundle/Builder.js @@ -133,7 +133,7 @@ class BundleBuilder { } async _createBundle(module, options) { - const resolvedModule = await this.resolver.resolve(module, options); + const resolvedModule = await this.resolver.resolve(module); if ( options.skipIfEmpty && isEmptyBundle(resolvedModule) ) { log.verbose(" skipping empty bundle " + module.name); return undefined; diff --git a/lib/lbt/bundle/Resolver.js b/lib/lbt/bundle/Resolver.js index 495704d8d..37b180e4a 100644 --- a/lib/lbt/bundle/Resolver.js +++ b/lib/lbt/bundle/Resolver.js @@ -13,6 +13,17 @@ const log = require("@ui5/logger").getLogger("lbt:bundle:Resolver"); let dependencyTracker; +const DEFAULT_FILE_TYPES = [ + ".js", + ".control.xml", // XMLComposite + ".fragment.html", + ".fragment.json", + ".fragment.xml", + ".view.html", + ".view.json", + ".view.xml" +]; + /** * Resolve a bundle definition. * @@ -32,13 +43,11 @@ class BundleResolver { /** * @param {ModuleDefinition} bundle Bundle definition to resolve - * @param {object} [options] Options - * @param {string[]} [options.defaultFileTypes] List of default file types to which a prefix pattern shall be expanded. * @returns {Promise} */ - resolve(bundle, options) { - const fileTypes = (options && options.defaultFileTypes) || undefined; + resolve(bundle) { + const fileTypes = bundle.defaultFileTypes || DEFAULT_FILE_TYPES; let visitedResources = Object.create(null); let selectedResources = Object.create(null); let selectedResourcesSequence = []; diff --git a/lib/processors/bundlers/moduleBundler.js b/lib/processors/bundlers/moduleBundler.js index c82d87bc4..604bc38a8 100644 --- a/lib/processors/bundlers/moduleBundler.js +++ b/lib/processors/bundlers/moduleBundler.js @@ -64,16 +64,18 @@ const log = require("@ui5/logger").getLogger("builder:processors:bundlers:module * @property {boolean} [sort=true] Whether the modules should be sorted by their dependencies */ +/* eslint-disable max-len */ /** * Module bundle definition * * @public * @typedef {object} ModuleBundleDefinition * @property {string} name The module bundle name - * @property {string[]} [defaultFileTypes=[".js", ".fragment.xml", ".view.xml", ".properties", ".json"]] + * @property {string[]} [defaultFileTypes=[".js", ".control.xml", ".fragment.html", ".fragment.json", ".fragment.xml", ".view.html", ".view.json", ".view.xml"]] * List of default file types to be included in the bundle * @property {ModuleBundleDefinitionSection[]} sections List of module bundle definition sections. */ +/* eslint-enable max-len */ /** * Module bundle options diff --git a/lib/tasks/bundlers/generateComponentPreload.js b/lib/tasks/bundlers/generateComponentPreload.js index c4e90c41f..b9d8faaf5 100644 --- a/lib/tasks/bundlers/generateComponentPreload.js +++ b/lib/tasks/bundlers/generateComponentPreload.js @@ -67,8 +67,10 @@ module.exports = function({ const bundleDefinitions = allNamespaces.map((namespace) => { const filters = [ `${namespace}/`, - `!${namespace}/test/`, - `!${namespace}/*.html` + `${namespace}/**/manifest.json`, + `${namespace}/changes/changes-bundle.json`, + `${namespace}/changes/flexibility-bundle.json`, + `!${namespace}/test/` ]; // Add configured excludes for namespace @@ -85,12 +87,25 @@ module.exports = function({ allNamespaces.forEach((ns) => { if (ns !== namespace && ns.startsWith(`${namespace}/`)) { filters.push(`!${ns}/`); + // Explicitly exclude manifest.json files of subcomponents since the general exclude above this + // comment only applies to the configured default file types, which do not include ".json" + filters.push(`!${ns}/**/manifest.json`); } }); return { name: `${namespace}/Component-preload.js`, - defaultFileTypes: [".js", ".fragment.xml", ".view.xml", ".properties", ".json"], + defaultFileTypes: [ + ".js", + ".control.xml", + ".fragment.html", + ".fragment.json", + ".fragment.xml", + ".view.html", + ".view.json", + ".view.xml", + ".properties" + ], sections: [ { mode: "preload", diff --git a/lib/tasks/bundlers/generateLibraryPreload.js b/lib/tasks/bundlers/generateLibraryPreload.js index 2943588e5..1ca11e2a7 100644 --- a/lib/tasks/bundlers/generateLibraryPreload.js +++ b/lib/tasks/bundlers/generateLibraryPreload.js @@ -3,29 +3,14 @@ const moduleBundler = require("../../processors/bundlers/moduleBundler"); const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized; const {negateFilters} = require("../../lbt/resources/ResourceFilterList"); -const DEFAULT_FILE_TYPES = [ - ".js", - ".control.xml", // XMLComposite - ".fragment.html", - ".fragment.json", - ".fragment.xml", - ".view.html", - ".view.json", - ".view.xml", - ".properties", - ".json" -]; - function getDefaultLibraryPreloadFilters(namespace, excludes) { const filters = [ `${namespace}/`, - `!${namespace}/.library`, + `${namespace}/**/manifest.json`, `!${namespace}/*-preload.js`, // exclude all bundles `!${namespace}/designtime/`, `!${namespace}/**/*.designtime.js`, - `!${namespace}/**/*.support.js`, - `!${namespace}/themes/`, - `!${namespace}/messagebundle*` + `!${namespace}/**/*.support.js` ]; if (Array.isArray(excludes)) { @@ -50,7 +35,6 @@ function getBundleDefinition(namespace, excludes) { if (namespace === "sap/ui/core") { return { name: `${namespace}/library-preload.js`, - defaultFileTypes: DEFAULT_FILE_TYPES, sections: [ { // exclude the content of sap-ui-core by declaring it as 'provided' @@ -106,7 +90,6 @@ function getBundleDefinition(namespace, excludes) { } return { name: `${namespace}/library-preload.js`, - defaultFileTypes: DEFAULT_FILE_TYPES, sections: [ { mode: "preload", @@ -122,7 +105,6 @@ function getBundleDefinition(namespace, excludes) { function getDesigntimeBundleDefinition(namespace) { return { name: `${namespace}/designtime/library-preload.designtime.js`, - defaultFileTypes: DEFAULT_FILE_TYPES, sections: [ { mode: "preload", @@ -145,7 +127,6 @@ function getDesigntimeBundleDefinition(namespace) { function getSupportFilesBundleDefinition(namespace) { return { name: `${namespace}/library-preload.support.js`, - defaultFileTypes: DEFAULT_FILE_TYPES, sections: [ { mode: "preload", diff --git a/lib/tasks/bundlers/generateStandaloneAppBundle.js b/lib/tasks/bundlers/generateStandaloneAppBundle.js index ecb1bfae5..ea6129b86 100644 --- a/lib/tasks/bundlers/generateStandaloneAppBundle.js +++ b/lib/tasks/bundlers/generateStandaloneAppBundle.js @@ -4,7 +4,17 @@ const moduleBundler = require("../../processors/bundlers/moduleBundler"); function getBundleDefinition(config) { const bundleDefinition = { name: config.name, - defaultFileTypes: [".js", ".fragment.xml", ".view.xml", ".properties", ".json"], + defaultFileTypes: [ + ".js", + ".control.xml", + ".fragment.html", + ".fragment.json", + ".fragment.xml", + ".view.html", + ".view.json", + ".view.xml", + ".properties" + ], sections: [] }; @@ -23,9 +33,11 @@ function getBundleDefinition(config) { bundleDefinition.sections.push({ mode: "preload", filters: [ - `${config.namespace|| ""}/`, + `${config.namespace || ""}/`, + `${config.namespace || ""}/**/manifest.json`, + `${config.namespace || ""}/changes/changes-bundle.json`, + `${config.namespace || ""}/changes/flexibility-bundle.json`, `!${config.namespace || ""}/test/`, - `!${config.namespace || ""}/*.html`, "sap/ui/core/Core.js" ], resolve: true, diff --git a/test/lib/tasks/bundlers/generateComponentPreload.js b/test/lib/tasks/bundlers/generateComponentPreload.js index 2dcba81c4..fc6546139 100644 --- a/test/lib/tasks/bundlers/generateComponentPreload.js +++ b/test/lib/tasks/bundlers/generateComponentPreload.js @@ -63,18 +63,24 @@ test.serial("generateComponentPreload - one namespace", async (t) => { bundleDefinition: { defaultFileTypes: [ ".js", + ".control.xml", + ".fragment.html", + ".fragment.json", ".fragment.xml", + ".view.html", + ".view.json", ".view.xml", - ".properties", - ".json", + ".properties" ], name: "my/app/Component-preload.js", sections: [ { filters: [ "my/app/", + "my/app/**/manifest.json", + "my/app/changes/changes-bundle.json", + "my/app/changes/flexibility-bundle.json", "!my/app/test/", - "!my/app/*.html" ], mode: "preload", renderer: false, @@ -140,18 +146,24 @@ test.serial("generateComponentPreload - one namespace - excludes", async (t) => bundleDefinition: { defaultFileTypes: [ ".js", + ".control.xml", + ".fragment.html", + ".fragment.json", ".fragment.xml", + ".view.html", + ".view.json", ".view.xml", - ".properties", - ".json", + ".properties" ], name: "my/app/Component-preload.js", sections: [ { filters: [ "my/app/", + "my/app/**/manifest.json", + "my/app/changes/changes-bundle.json", + "my/app/changes/flexibility-bundle.json", "!my/app/test/", - "!my/app/*.html", "!my/app/thirdparty/", "+my/app/thirdparty/NotExcluded.js" ], @@ -219,18 +231,24 @@ test.serial("generateComponentPreload - one namespace - excludes w/o namespace", bundleDefinition: { defaultFileTypes: [ ".js", + ".control.xml", + ".fragment.html", + ".fragment.json", ".fragment.xml", + ".view.html", + ".view.json", ".view.xml", - ".properties", - ".json", + ".properties" ], name: "my/app/Component-preload.js", sections: [ { filters: [ "my/app/", + "my/app/**/manifest.json", + "my/app/changes/changes-bundle.json", + "my/app/changes/flexibility-bundle.json", "!my/app/test/", - "!my/app/*.html", "!thirdparty/", ], mode: "preload", @@ -302,18 +320,24 @@ test.serial("generateComponentPreload - multiple namespaces - excludes", async ( bundleDefinition: { defaultFileTypes: [ ".js", + ".control.xml", + ".fragment.html", + ".fragment.json", ".fragment.xml", + ".view.html", + ".view.json", ".view.xml", - ".properties", - ".json", + ".properties" ], name: "my/app1/Component-preload.js", sections: [ { filters: [ "my/app1/", + "my/app1/**/manifest.json", + "my/app1/changes/changes-bundle.json", + "my/app1/changes/flexibility-bundle.json", "!my/app1/test/", - "!my/app1/*.html", "!my/app1/thirdparty1/", "+my/app1/thirdparty1/NotExcluded.js", "!my/app2/thirdparty2/", @@ -337,18 +361,24 @@ test.serial("generateComponentPreload - multiple namespaces - excludes", async ( bundleDefinition: { defaultFileTypes: [ ".js", + ".control.xml", + ".fragment.html", + ".fragment.json", ".fragment.xml", + ".view.html", + ".view.json", ".view.xml", - ".properties", - ".json", + ".properties" ], name: "my/app2/Component-preload.js", sections: [ { filters: [ "my/app2/", + "my/app2/**/manifest.json", + "my/app2/changes/changes-bundle.json", + "my/app2/changes/flexibility-bundle.json", "!my/app2/test/", - "!my/app2/*.html", "!my/app1/thirdparty1/", "!my/app2/thirdparty2/", "+my/app2/thirdparty2/NotExcluded.js" @@ -469,18 +499,24 @@ test.serial("generateComponentPreload - nested namespaces - excludes", async (t) bundleDefinition: { defaultFileTypes: [ ".js", + ".control.xml", + ".fragment.html", + ".fragment.json", ".fragment.xml", + ".view.html", + ".view.json", ".view.xml", - ".properties", - ".json", + ".properties" ], name: "my/project/component1/Component-preload.js", sections: [ { filters: [ "my/project/component1/", + "my/project/component1/**/manifest.json", + "my/project/component1/changes/changes-bundle.json", + "my/project/component1/changes/flexibility-bundle.json", "!my/project/component1/test/", - "!my/project/component1/*.html", // via excludes config "!my/project/component1/foo/" @@ -504,18 +540,24 @@ test.serial("generateComponentPreload - nested namespaces - excludes", async (t) bundleDefinition: { defaultFileTypes: [ ".js", + ".control.xml", + ".fragment.html", + ".fragment.json", ".fragment.xml", + ".view.html", + ".view.json", ".view.xml", - ".properties", - ".json", + ".properties" ], name: "my/project/Component-preload.js", sections: [ { filters: [ "my/project/", + "my/project/**/manifest.json", + "my/project/changes/changes-bundle.json", + "my/project/changes/flexibility-bundle.json", "!my/project/test/", - "!my/project/*.html", // via excludes config "!my/project/component1/foo/", @@ -524,7 +566,9 @@ test.serial("generateComponentPreload - nested namespaces - excludes", async (t) // sub-namespaces are excluded "!my/project/component1/", + "!my/project/component1/**/manifest.json", "!my/project/component2/", + "!my/project/component2/**/manifest.json", ], mode: "preload", renderer: false, @@ -545,18 +589,24 @@ test.serial("generateComponentPreload - nested namespaces - excludes", async (t) bundleDefinition: { defaultFileTypes: [ ".js", + ".control.xml", + ".fragment.html", + ".fragment.json", ".fragment.xml", + ".view.html", + ".view.json", ".view.xml", - ".properties", - ".json", + ".properties" ], name: "my/project/component2/Component-preload.js", sections: [ { filters: [ "my/project/component2/", + "my/project/component2/**/manifest.json", + "my/project/component2/changes/changes-bundle.json", + "my/project/component2/changes/flexibility-bundle.json", "!my/project/component2/test/", - "!my/project/component2/*.html", // via excludes config "!my/project/component1/foo/", diff --git a/test/lib/tasks/bundlers/generateLibraryPreload.js b/test/lib/tasks/bundlers/generateLibraryPreload.js index 99e3b6a64..1f1a63e46 100644 --- a/test/lib/tasks/bundlers/generateLibraryPreload.js +++ b/test/lib/tasks/bundlers/generateLibraryPreload.js @@ -64,30 +64,16 @@ test.serial("generateLibraryPreload", async (t) => { t.deepEqual(moduleBundlerStub.getCall(0).args, [{ options: { bundleDefinition: { - defaultFileTypes: [ - ".js", - ".control.xml", - ".fragment.html", - ".fragment.json", - ".fragment.xml", - ".view.html", - ".view.json", - ".view.xml", - ".properties", - ".json" - ], name: "my/lib/library-preload.js", sections: [ { filters: [ "my/lib/", - "!my/lib/.library", + "my/lib/**/manifest.json", "!my/lib/*-preload.js", "!my/lib/designtime/", "!my/lib/**/*.designtime.js", "!my/lib/**/*.support.js", - "!my/lib/themes/", - "!my/lib/messagebundle*", ], mode: "preload", renderer: true, @@ -107,18 +93,6 @@ test.serial("generateLibraryPreload", async (t) => { t.deepEqual(moduleBundlerStub.getCall(1).args, [{ options: { bundleDefinition: { - defaultFileTypes: [ - ".js", - ".control.xml", - ".fragment.html", - ".fragment.json", - ".fragment.xml", - ".view.html", - ".view.json", - ".view.xml", - ".properties", - ".json" - ], name: "my/lib/designtime/library-preload.designtime.js", sections: [ { @@ -149,18 +123,6 @@ test.serial("generateLibraryPreload", async (t) => { t.deepEqual(moduleBundlerStub.getCall(2).args, [{ options: { bundleDefinition: { - defaultFileTypes: [ - ".js", - ".control.xml", - ".fragment.html", - ".fragment.json", - ".fragment.xml", - ".view.html", - ".view.json", - ".view.xml", - ".properties", - ".json" - ], name: "my/lib/library-preload.support.js", sections: [ { @@ -387,18 +349,6 @@ test.serial("generateLibraryPreload for sap.ui.core (w/o ui5loader.js)", async ( t.deepEqual(moduleBundlerStub.getCall(4).args, [{ options: { bundleDefinition: { - defaultFileTypes: [ - ".js", - ".control.xml", - ".fragment.html", - ".fragment.json", - ".fragment.xml", - ".view.html", - ".view.json", - ".view.xml", - ".properties", - ".json" - ], name: "sap/ui/core/library-preload.js", sections: [ { @@ -412,13 +362,11 @@ test.serial("generateLibraryPreload for sap.ui.core (w/o ui5loader.js)", async ( { filters: [ "sap/ui/core/", - "!sap/ui/core/.library", + "sap/ui/core/**/manifest.json", "!sap/ui/core/*-preload.js", "!sap/ui/core/designtime/", "!sap/ui/core/**/*.designtime.js", "!sap/ui/core/**/*.support.js", - "!sap/ui/core/themes/", - "!sap/ui/core/messagebundle*", "!sap/ui/core/cldr/", "*.js", @@ -662,18 +610,6 @@ test.serial("generateLibraryPreload for sap.ui.core (/w ui5loader.js)", async (t t.deepEqual(moduleBundlerStub.getCall(4).args, [{ options: { bundleDefinition: { - defaultFileTypes: [ - ".js", - ".control.xml", - ".fragment.html", - ".fragment.json", - ".fragment.xml", - ".view.html", - ".view.json", - ".view.xml", - ".properties", - ".json" - ], name: "sap/ui/core/library-preload.js", sections: [ { @@ -687,13 +623,11 @@ test.serial("generateLibraryPreload for sap.ui.core (/w ui5loader.js)", async (t { filters: [ "sap/ui/core/", - "!sap/ui/core/.library", + "sap/ui/core/**/manifest.json", "!sap/ui/core/*-preload.js", "!sap/ui/core/designtime/", "!sap/ui/core/**/*.designtime.js", "!sap/ui/core/**/*.support.js", - "!sap/ui/core/themes/", - "!sap/ui/core/messagebundle*", "!sap/ui/core/cldr/", "*.js", @@ -735,18 +669,6 @@ test.serial("generateLibraryPreload for sap.ui.core (/w ui5loader.js)", async (t t.deepEqual(moduleBundlerStub.getCall(5).args, [{ options: { bundleDefinition: { - defaultFileTypes: [ - ".js", - ".control.xml", - ".fragment.html", - ".fragment.json", - ".fragment.xml", - ".view.html", - ".view.json", - ".view.xml", - ".properties", - ".json" - ], name: "sap/ui/core/designtime/library-preload.designtime.js", sections: [ { @@ -777,18 +699,6 @@ test.serial("generateLibraryPreload for sap.ui.core (/w ui5loader.js)", async (t t.deepEqual(moduleBundlerStub.getCall(6).args, [{ options: { bundleDefinition: { - defaultFileTypes: [ - ".js", - ".control.xml", - ".fragment.html", - ".fragment.json", - ".fragment.xml", - ".view.html", - ".view.json", - ".view.xml", - ".properties", - ".json" - ], name: "sap/ui/core/library-preload.support.js", sections: [ { @@ -855,30 +765,16 @@ test.serial("generateLibraryPreload with excludes", async (t) => { t.deepEqual(moduleBundlerStub.getCall(0).args, [{ options: { bundleDefinition: { - defaultFileTypes: [ - ".js", - ".control.xml", - ".fragment.html", - ".fragment.json", - ".fragment.xml", - ".view.html", - ".view.json", - ".view.xml", - ".properties", - ".json" - ], name: "my/lib/library-preload.js", sections: [ { filters: [ "my/lib/", - "!my/lib/.library", + "my/lib/**/manifest.json", "!my/lib/*-preload.js", "!my/lib/designtime/", "!my/lib/**/*.designtime.js", "!my/lib/**/*.support.js", - "!my/lib/themes/", - "!my/lib/messagebundle*", // via excludes option "!my/lib/thirdparty/", @@ -943,30 +839,16 @@ test.serial("generateLibraryPreload with invalid excludes", async (t) => { t.deepEqual(moduleBundlerStub.getCall(0).args, [{ options: { bundleDefinition: { - defaultFileTypes: [ - ".js", - ".control.xml", - ".fragment.html", - ".fragment.json", - ".fragment.xml", - ".view.html", - ".view.json", - ".view.xml", - ".properties", - ".json" - ], name: "my/lib/library-preload.js", sections: [ { filters: [ "my/lib/", - "!my/lib/.library", + "my/lib/**/manifest.json", "!my/lib/*-preload.js", "!my/lib/designtime/", "!my/lib/**/*.designtime.js", - "!my/lib/**/*.support.js", - "!my/lib/themes/", - "!my/lib/messagebundle*" + "!my/lib/**/*.support.js" ], mode: "preload", renderer: true, diff --git a/test/lib/tasks/bundlers/generateStandaloneAppBundle.js b/test/lib/tasks/bundlers/generateStandaloneAppBundle.js index 75857cc1c..774092cdf 100644 --- a/test/lib/tasks/bundlers/generateStandaloneAppBundle.js +++ b/test/lib/tasks/bundlers/generateStandaloneAppBundle.js @@ -53,10 +53,23 @@ test.serial("execute module bundler and write results", async (t) => { ], "Correct filter in first bundle definition section"); t.deepEqual(options.bundleDefinition.sections[1].filters, [ "some/project/namespace/", + "some/project/namespace/**/manifest.json", + "some/project/namespace/changes/changes-bundle.json", + "some/project/namespace/changes/flexibility-bundle.json", "!some/project/namespace/test/", - "!some/project/namespace/*.html", "sap/ui/core/Core.js" ], "Correct filter in second bundle definition section"); + t.deepEqual(options.bundleDefinition.defaultFileTypes, [ + ".js", + ".control.xml", + ".fragment.html", + ".fragment.json", + ".fragment.xml", + ".view.html", + ".view.json", + ".view.xml", + ".properties" + ], "Correct default file types in bundle definition"); }); test.serial("execute module bundler and write results without namespace", async (t) => { @@ -90,8 +103,10 @@ test.serial("execute module bundler and write results without namespace", async ], "Correct filter in first bundle definition section"); t.deepEqual(options.bundleDefinition.sections[1].filters, [ "/", + "/**/manifest.json", + "/changes/changes-bundle.json", + "/changes/flexibility-bundle.json", "!/test/", - "!/*.html", "sap/ui/core/Core.js" ], "Correct filter in second bundle definition section"); }); @@ -129,8 +144,10 @@ test.serial("execute module bundler and write results in evo mode", async (t) => ], "Evo mode active - Correct filter in first bundle definition section"); t.deepEqual(options.bundleDefinition.sections[1].filters, [ "some/project/namespace/", + "some/project/namespace/**/manifest.json", + "some/project/namespace/changes/changes-bundle.json", + "some/project/namespace/changes/flexibility-bundle.json", "!some/project/namespace/test/", - "!some/project/namespace/*.html", "sap/ui/core/Core.js" ], "Correct filter in second bundle definition section"); });