Skip to content

Commit 42f6474

Browse files
matz3RandomByte
andauthored
[FIX] moduleBundler: Apply defaultFileTypes (#580)
Use default if not provided in bundle definition. In the past neither a default, nor the bundle definition configuration was used, since the parameter was mistakenly expected on the bundle options. Also align the defaults for library- and component-bundles with Maven. Co-authored-by: Merlin Beutlberger <[email protected]>
1 parent fe61d6e commit 42f6474

File tree

10 files changed

+153
-185
lines changed

10 files changed

+153
-185
lines changed

lib/lbt/bundle/AutoSplitter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class AutoSplitter {
4747
this.optimize = !!options.optimize;
4848

4949
// ---- resolve module definition
50-
const resolvedModule = await this.resolver.resolve(moduleDef, options);
50+
const resolvedModule = await this.resolver.resolve(moduleDef);
5151
// ---- calculate overall size of merged module
5252

5353
if ( moduleDef.configuration ) {

lib/lbt/bundle/Builder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class BundleBuilder {
133133
}
134134

135135
async _createBundle(module, options) {
136-
const resolvedModule = await this.resolver.resolve(module, options);
136+
const resolvedModule = await this.resolver.resolve(module);
137137
if ( options.skipIfEmpty && isEmptyBundle(resolvedModule) ) {
138138
log.verbose(" skipping empty bundle " + module.name);
139139
return undefined;

lib/lbt/bundle/Resolver.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ const log = require("@ui5/logger").getLogger("lbt:bundle:Resolver");
1313

1414
let dependencyTracker;
1515

16+
const DEFAULT_FILE_TYPES = [
17+
".js",
18+
".control.xml", // XMLComposite
19+
".fragment.html",
20+
".fragment.json",
21+
".fragment.xml",
22+
".view.html",
23+
".view.json",
24+
".view.xml"
25+
];
26+
1627
/**
1728
* Resolve a bundle definition.
1829
*
@@ -32,13 +43,11 @@ class BundleResolver {
3243

3344
/**
3445
* @param {ModuleDefinition} bundle Bundle definition to resolve
35-
* @param {object} [options] Options
36-
* @param {string[]} [options.defaultFileTypes]
3746
List of default file types to which a prefix pattern shall be expanded.
3847
* @returns {Promise<ResolvedBundleDefinition>}
3948
*/
40-
resolve(bundle, options) {
41-
const fileTypes = (options && options.defaultFileTypes) || undefined;
49+
resolve(bundle) {
50+
const fileTypes = bundle.defaultFileTypes || DEFAULT_FILE_TYPES;
4251
let visitedResources = Object.create(null);
4352
let selectedResources = Object.create(null);
4453
let selectedResourcesSequence = [];

lib/processors/bundlers/moduleBundler.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,18 @@ const log = require("@ui5/logger").getLogger("builder:processors:bundlers:module
6464
* @property {boolean} [sort=true] Whether the modules should be sorted by their dependencies
6565
*/
6666

67+
/* eslint-disable max-len */
6768
/**
6869
* Module bundle definition
6970
*
7071
* @public
7172
* @typedef {object} ModuleBundleDefinition
7273
* @property {string} name The module bundle name
73-
* @property {string[]} [defaultFileTypes=[".js", ".fragment.xml", ".view.xml", ".properties", ".json"]]
74+
* @property {string[]} [defaultFileTypes=[".js", ".control.xml", ".fragment.html", ".fragment.json", ".fragment.xml", ".view.html", ".view.json", ".view.xml"]]
7475
* List of default file types to be included in the bundle
7576
* @property {ModuleBundleDefinitionSection[]} sections List of module bundle definition sections.
7677
*/
78+
/* eslint-enable max-len */
7779

7880
/**
7981
* Module bundle options

lib/tasks/bundlers/generateComponentPreload.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ module.exports = function({
6767
const bundleDefinitions = allNamespaces.map((namespace) => {
6868
const filters = [
6969
`${namespace}/`,
70-
`!${namespace}/test/`,
71-
`!${namespace}/*.html`
70+
`${namespace}/**/manifest.json`,
71+
`${namespace}/changes/changes-bundle.json`,
72+
`${namespace}/changes/flexibility-bundle.json`,
73+
`!${namespace}/test/`
7274
];
7375

7476
// Add configured excludes for namespace
@@ -85,12 +87,25 @@ module.exports = function({
8587
allNamespaces.forEach((ns) => {
8688
if (ns !== namespace && ns.startsWith(`${namespace}/`)) {
8789
filters.push(`!${ns}/`);
90+
// Explicitly exclude manifest.json files of subcomponents since the general exclude above this
91+
// comment only applies to the configured default file types, which do not include ".json"
92+
filters.push(`!${ns}/**/manifest.json`);
8893
}
8994
});
9095

9196
return {
9297
name: `${namespace}/Component-preload.js`,
93-
defaultFileTypes: [".js", ".fragment.xml", ".view.xml", ".properties", ".json"],
98+
defaultFileTypes: [
99+
".js",
100+
".control.xml",
101+
".fragment.html",
102+
".fragment.json",
103+
".fragment.xml",
104+
".view.html",
105+
".view.json",
106+
".view.xml",
107+
".properties"
108+
],
94109
sections: [
95110
{
96111
mode: "preload",

lib/tasks/bundlers/generateLibraryPreload.js

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,14 @@ const moduleBundler = require("../../processors/bundlers/moduleBundler");
33
const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
44
const {negateFilters} = require("../../lbt/resources/ResourceFilterList");
55

6-
const DEFAULT_FILE_TYPES = [
7-
".js",
8-
".control.xml", // XMLComposite
9-
".fragment.html",
10-
".fragment.json",
11-
".fragment.xml",
12-
".view.html",
13-
".view.json",
14-
".view.xml",
15-
".properties",
16-
".json"
17-
];
18-
196
function getDefaultLibraryPreloadFilters(namespace, excludes) {
207
const filters = [
218
`${namespace}/`,
22-
`!${namespace}/.library`,
9+
`${namespace}/**/manifest.json`,
2310
`!${namespace}/*-preload.js`, // exclude all bundles
2411
`!${namespace}/designtime/`,
2512
`!${namespace}/**/*.designtime.js`,
26-
`!${namespace}/**/*.support.js`,
27-
`!${namespace}/themes/`,
28-
`!${namespace}/messagebundle*`
13+
`!${namespace}/**/*.support.js`
2914
];
3015

3116
if (Array.isArray(excludes)) {
@@ -50,7 +35,6 @@ function getBundleDefinition(namespace, excludes) {
5035
if (namespace === "sap/ui/core") {
5136
return {
5237
name: `${namespace}/library-preload.js`,
53-
defaultFileTypes: DEFAULT_FILE_TYPES,
5438
sections: [
5539
{
5640
// exclude the content of sap-ui-core by declaring it as 'provided'
@@ -106,7 +90,6 @@ function getBundleDefinition(namespace, excludes) {
10690
}
10791
return {
10892
name: `${namespace}/library-preload.js`,
109-
defaultFileTypes: DEFAULT_FILE_TYPES,
11093
sections: [
11194
{
11295
mode: "preload",
@@ -122,7 +105,6 @@ function getBundleDefinition(namespace, excludes) {
122105
function getDesigntimeBundleDefinition(namespace) {
123106
return {
124107
name: `${namespace}/designtime/library-preload.designtime.js`,
125-
defaultFileTypes: DEFAULT_FILE_TYPES,
126108
sections: [
127109
{
128110
mode: "preload",
@@ -145,7 +127,6 @@ function getDesigntimeBundleDefinition(namespace) {
145127
function getSupportFilesBundleDefinition(namespace) {
146128
return {
147129
name: `${namespace}/library-preload.support.js`,
148-
defaultFileTypes: DEFAULT_FILE_TYPES,
149130
sections: [
150131
{
151132
mode: "preload",

lib/tasks/bundlers/generateStandaloneAppBundle.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@ const moduleBundler = require("../../processors/bundlers/moduleBundler");
44
function getBundleDefinition(config) {
55
const bundleDefinition = {
66
name: config.name,
7-
defaultFileTypes: [".js", ".fragment.xml", ".view.xml", ".properties", ".json"],
7+
defaultFileTypes: [
8+
".js",
9+
".control.xml",
10+
".fragment.html",
11+
".fragment.json",
12+
".fragment.xml",
13+
".view.html",
14+
".view.json",
15+
".view.xml",
16+
".properties"
17+
],
818
sections: []
919
};
1020

@@ -23,9 +33,11 @@ function getBundleDefinition(config) {
2333
bundleDefinition.sections.push({
2434
mode: "preload",
2535
filters: [
26-
`${config.namespace|| ""}/`,
36+
`${config.namespace || ""}/`,
37+
`${config.namespace || ""}/**/manifest.json`,
38+
`${config.namespace || ""}/changes/changes-bundle.json`,
39+
`${config.namespace || ""}/changes/flexibility-bundle.json`,
2740
`!${config.namespace || ""}/test/`,
28-
`!${config.namespace || ""}/*.html`,
2941
"sap/ui/core/Core.js"
3042
],
3143
resolve: true,

0 commit comments

Comments
 (0)