Skip to content

Commit

Permalink
generateBundle: Filter non-debug files for optimize bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomByte committed Nov 11, 2021
1 parent 583c74e commit 4c148be
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 21 deletions.
20 changes: 13 additions & 7 deletions lib/tasks/bundlers/generateBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@ const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritiz
module.exports = function({
workspace, dependencies, taskUtil, options: {projectName, bundleDefinition, bundleOptions}
}) {
const combo = new ReaderCollectionPrioritized({
let combo = new ReaderCollectionPrioritized({
name: `libraryBundler - prioritize workspace over dependencies: ${projectName}`,
readers: [workspace, dependencies]
}).filter({
resourceTagCollection: taskUtil.getResourceTagCollection(),
filters: [{
tag: taskUtil.STANDARD_TAGS.IsDebugVariant,
value: undefined
}]
});

if (taskUtil) {
combo = combo.filter({
resourceTagCollection: taskUtil.getResourceTagCollection(),
filters: [{
tag: bundleOptions.optimize ? // Omit -dbg files for optimize bundles and vice versa
taskUtil.STANDARD_TAGS.IsDebugVariant : taskUtil.STANDARD_TAGS.HasDebugVariant,
value: true,
matchMode: "none"
}]
});
}

return combo.byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}").then((resources) => {
return moduleBundler({
options: {
Expand Down
19 changes: 12 additions & 7 deletions lib/tasks/bundlers/generateComponentPreload.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,22 @@ const {negateFilters} = require("../../lbt/resources/ResourceFilterList");
module.exports = function({
workspace, dependencies, taskUtil, options: {projectName, paths, namespaces, excludes = []}
}) {
const combo = new ReaderCollectionPrioritized({
let combo = new ReaderCollectionPrioritized({
name: `generateComponentPreload - prioritize workspace over dependencies: ${projectName}`,
readers: [workspace, dependencies]
}).filter({
resourceTagCollection: taskUtil.getResourceTagCollection(), // TODO: taskUtil param is optional
filters: [{
tag: taskUtil.STANDARD_TAGS.IsDebugVariant,
value: undefined
}]
});

if (taskUtil) {
combo = combo.filter({
resourceTagCollection: taskUtil.getResourceTagCollection(), // TODO: taskUtil param is optional
filters: [{
tag: taskUtil.STANDARD_TAGS.IsDebugVariant,
value: true,
matchMode: "none"
}]
});
}

// TODO 3.0: Limit to workspace resources?
return combo.byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}")
.then(async (resources) => {
Expand Down
19 changes: 12 additions & 7 deletions lib/tasks/bundlers/generateLibraryPreload.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,17 +272,22 @@ function getSapUiCoreBunDef(name, filters, preload) {
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
*/
module.exports = function({workspace, dependencies, taskUtil, options: {projectName, excludes = []}}) {
const combo = new ReaderCollectionPrioritized({
let combo = new ReaderCollectionPrioritized({
name: `libraryBundler - prioritize workspace over dependencies: ${projectName}`,
readers: [workspace, dependencies]
}).filter({
resourceTagCollection: taskUtil.getResourceTagCollection(), // TODO: taskUtil param is optional
filters: [{
tag: taskUtil.STANDARD_TAGS.IsDebugVariant,
value: undefined
}]
});

if (taskUtil) {
combo = combo.filter({
resourceTagCollection: taskUtil.getResourceTagCollection(), // TODO: taskUtil param is optional
filters: [{
tag: taskUtil.STANDARD_TAGS.IsDebugVariant,
value: undefined,
matchMode: "true"
}]
});
}

return combo.byGlob("/**/*.{js,json,xml,html,properties,library,js.map}").then((resources) => {
// Find all libraries and create a library-preload.js bundle

Expand Down

0 comments on commit 4c148be

Please sign in to comment.