Skip to content

Commit

Permalink
Do not modify preloads for lib & comp default tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
d3xter666 committed Nov 3, 2023
1 parent 0642eb1 commit 86bca54
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 80 deletions.
7 changes: 0 additions & 7 deletions lib/tasks/bundlers/generateComponentPreload.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,6 @@ export default async function({
resolve: false,
resolveConditional: false,
renderer: false
},
{
mode: "depCache",
filters: filters,
resolve: false,
resolveConditional: false,
renderer: false
}
]
};
Expand Down
126 changes: 53 additions & 73 deletions lib/tasks/bundlers/generateLibraryPreload.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,63 +31,11 @@ function getDefaultLibraryPreloadFilters(namespace, excludes) {
return filters;
}

function getBundleDefinition(namespace, excludes, preloadMode = "preload") {
const preloadBundleSuffix = preloadMode === "preload" ? "preload" : "depcache-preload";
let preloadDef;
let depCachePreloadDef;
function getBundleDefinition(namespace, excludes) {
// TODO: move to config of actual core project
if (namespace === "sap/ui/core") {
preloadDef = {
mode: "preload",
filters: [
// Note: Don't pass configured preload excludes for sap.ui.core
// as they are already hardcoded below.
// In future the sap/ui/core/library-preload should be configured
// as a custom bundle in the ui5.yaml.
...getDefaultLibraryPreloadFilters(namespace),

`!${namespace}/cldr/`,
"*.js",
"sap/base/",
"sap/ui/base/",
"sap/ui/dom/",
"sap/ui/events/",
"sap/ui/model/",
"sap/ui/security/",
"sap/ui/util/",
"sap/ui/Global.js",

// include only thirdparty that is very likely to be used
"sap/ui/thirdparty/crossroads.js",
"sap/ui/thirdparty/caja-html-sanitizer.js",
"sap/ui/thirdparty/hasher.js",
"sap/ui/thirdparty/signals.js",
"sap/ui/thirdparty/jquery-mobile-custom.js",
"sap/ui/thirdparty/jqueryui/jquery-ui-core.js",
"sap/ui/thirdparty/jqueryui/jquery-ui-position.js",

// other excludes (not required for productive scenarios)
"!sap-ui-*.js",
"!sap/ui/core/support/",
"!sap/ui/core/plugin/DeclarativeSupport.js",
"!sap/ui/core/plugin/LessSupport.js"

],
resolve: false,
resolveConditional: false,
renderer: true
};

// TODO: Adjust filters
if (preloadMode === "depCache") {
depCachePreloadDef = {
...preloadDef,
...{mode: "depCache"}
};
}

return {
name: `${namespace}/library-${preloadBundleSuffix}.js`,
name: `${namespace}/library-preload.js`,
sections: [
{
// exclude the content of sap-ui-core by declaring it as 'provided'
Expand All @@ -98,28 +46,60 @@ function getBundleDefinition(namespace, excludes, preloadMode = "preload") {
],
resolve: true
},
preloadDef,
...[depCachePreloadDef]
{
mode: "preload",
filters: [
// Note: Don't pass configured preload excludes for sap.ui.core
// as they are already hardcoded below.
// In future the sap/ui/core/library-preload should be configured
// as a custom bundle in the ui5.yaml.
...getDefaultLibraryPreloadFilters(namespace),

`!${namespace}/cldr/`,
"*.js",
"sap/base/",
"sap/ui/base/",
"sap/ui/dom/",
"sap/ui/events/",
"sap/ui/model/",
"sap/ui/security/",
"sap/ui/util/",
"sap/ui/Global.js",

// include only thirdparty that is very likely to be used
"sap/ui/thirdparty/crossroads.js",
"sap/ui/thirdparty/caja-html-sanitizer.js",
"sap/ui/thirdparty/hasher.js",
"sap/ui/thirdparty/signals.js",
"sap/ui/thirdparty/jquery-mobile-custom.js",
"sap/ui/thirdparty/jqueryui/jquery-ui-core.js",
"sap/ui/thirdparty/jqueryui/jquery-ui-position.js",

// other excludes (not required for productive scenarios)
"!sap-ui-*.js",
"!sap/ui/core/support/",
"!sap/ui/core/plugin/DeclarativeSupport.js",
"!sap/ui/core/plugin/LessSupport.js"

],
resolve: false,
resolveConditional: false,
renderer: true
}
]
};
}

preloadDef = {
mode: "preload",
filters: getDefaultLibraryPreloadFilters(namespace, excludes),
resolve: false,
resolveConditional: false,
renderer: true
};

// TODO: Adjust filters
if (preloadMode === "depCache") {
depCachePreloadDef = {...preloadDef, ...{mode: "depCache"}};
}

return {
name: `${namespace}/library-${preloadBundleSuffix}.js`,
sections: [preloadDef, ...[depCachePreloadDef]],
name: `${namespace}/library-preload.js`,
sections: [
{
mode: "preload",
filters: getDefaultLibraryPreloadFilters(namespace, excludes),
resolve: false,
resolveConditional: false,
renderer: true
}
]
};
}

Expand Down Expand Up @@ -405,7 +385,7 @@ export default async function({workspace, taskUtil, options: {skipBundles = [],
const results = await Promise.all([
execModuleBundlerIfNeeded({
options: {
bundleDefinition: getBundleDefinition(libraryNamespace, excludes, "depCache"),
bundleDefinition: getBundleDefinition(libraryNamespace, excludes),
bundleOptions: {
optimize: true,
usePredefineCalls: true,
Expand Down

0 comments on commit 86bca54

Please sign in to comment.