Skip to content

Commit 44d2548

Browse files
committed
[INTERNAL] generateLibraryPreload: Also apply default filters to experimental library-preload
1 parent 476e3bb commit 44d2548

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

lib/tasks/bundlers/generateLibraryPreload.js

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,32 @@ function getDefaultLibraryPreloadFilters(namespace, excludes) {
3333
return filters;
3434
}
3535

36+
function getExperimentalDefaultLibraryPreloadFilters(namespace, excludes) {
37+
const filters = [
38+
`${namespace}/library.js`,
39+
`!${namespace}/**/*-preload.js`, // exclude all bundles
40+
`!${namespace}/designtime/`,
41+
`!${namespace}/**/*.designtime.js`,
42+
`!${namespace}/**/*.support.js`
43+
];
44+
45+
if (Array.isArray(excludes)) {
46+
const allFilterExcludes = negateFilters(excludes);
47+
// Add configured excludes at the end of filter list
48+
allFilterExcludes.forEach((filterExclude) => {
49+
// Allow all excludes (!) and limit re-includes (+) to the library namespace
50+
if (filterExclude.startsWith("!") || filterExclude.startsWith(`+${namespace}/`)) {
51+
filters.push(filterExclude);
52+
} else {
53+
log.warn(`Configured preload exclude contains invalid re-include: !${filterExclude.substr(1)}. ` +
54+
`Re-includes must start with the library's namespace ${namespace}`);
55+
}
56+
});
57+
}
58+
59+
return filters;
60+
}
61+
3662
function getBundleDefinition(namespace, excludes) {
3763
// Note: This configuration is only used when no bundle definition in ui5.yaml exists (see "skipBundles" parameter)
3864

@@ -110,9 +136,7 @@ function getBundleDefinition(namespace, excludes) {
110136
function getBundleInfoPreloadDefinition(namespace, excludes, coreVersion) {
111137
const sections = [{
112138
mode: "preload",
113-
filters: [
114-
`${namespace}/library.js`,
115-
],
139+
filters: getExperimentalDefaultLibraryPreloadFilters(namespace, excludes),
116140
resolve: true
117141
},
118142
{
@@ -160,9 +184,7 @@ function getContentBundleDefinition(namespace, excludes) {
160184
name: `${namespace}/library-content.js`,
161185
sections: [{
162186
mode: "provided",
163-
filters: [
164-
`${namespace}/library.js`,
165-
],
187+
filters: getExperimentalDefaultLibraryPreloadFilters(namespace, excludes),
166188
resolve: true
167189
}, {
168190
mode: "preload",
@@ -501,7 +523,8 @@ export default async function({workspace, taskUtil, options: {skipBundles = [],
501523
} else {
502524
log.info(
503525
`Using experimental bundling with bundle info preload ` +
504-
`for library ${libraryNamespace} in project ${projectName}.`);
526+
`for library ${libraryNamespace} in project ${projectName}`);
527+
log.info(`Detected sap.ui.core version is ${coreVersion || "unknown"}`);
505528
// Experimental bundling with bundle info preload
506529
results = await Promise.all([
507530
execModuleBundlerIfNeeded({

0 commit comments

Comments
 (0)