Skip to content

Commit

Permalink
[BREAKING] moduleBundler: Always default to optimize: true
Browse files Browse the repository at this point in the history
bundleOptions are often omitted. So document them as optional and always
default optimize to true, even if bundleOptions are specified.
  • Loading branch information
matz3 authored and RandomByte committed Jan 18, 2022
1 parent 04072a2 commit 3174d3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions lib/processors/bundlers/moduleBundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const log = require("@ui5/logger").getLogger("builder:processors:bundlers:module
*
* @public
* @typedef {object} ModuleBundleOptions
* @property {boolean} [optimize=false] If set to 'true' the module bundle gets minified
* @property {boolean} [optimize=true] Whether the module bundle gets minified
* @property {boolean} [decorateBootstrapModule=false] If set to 'false', the module won't be decorated
* with an optimization marker
* @property {boolean} [addTryCatchRestartWrapper=false] Whether to wrap bootable module bundles with
Expand All @@ -109,15 +109,17 @@ const log = require("@ui5/logger").getLogger("builder:processors:bundlers:module
* @param {module:@ui5/fs.Resource[]} parameters.resources Resources
* @param {object} parameters.options Options
* @param {ModuleBundleDefinition} parameters.options.bundleDefinition Module bundle definition
* @param {ModuleBundleOptions} parameters.options.bundleOptions Module bundle options
* @param {ModuleBundleOptions} [parameters.options.bundleOptions] Module bundle options
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving with module bundle resources
*/
module.exports = function({resources, options: {bundleDefinition, bundleOptions}}) {
// console.log("preloadBundler bundleDefinition:");
// console.log(JSON.stringify(options.bundleDefinition, null, 4));

// TODO 3.0: Fix defaulting behavior, align with JSDoc
bundleOptions = bundleOptions || {optimize: true};
if (bundleOptions.optimize === undefined) {
bundleOptions.optimize = true;
}

const pool = new LocatorResourcePool({
ignoreMissingModules: bundleOptions.ignoreMissingModules
Expand Down
8 changes: 5 additions & 3 deletions lib/tasks/bundlers/generateBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritiz
* @param {object} parameters.options Options
* @param {string} parameters.options.projectName Project name
* @param {ModuleBundleDefinition} parameters.options.bundleDefinition Module bundle definition
* @param {ModuleBundleOptions} parameters.options.bundleOptions Module bundle options
* @param {ModuleBundleOptions} [parameters.options.bundleOptions] Module bundle options
* @returns {Promise} Promise resolving with <code>undefined</code> once data has been written
*/
module.exports = function({
Expand All @@ -26,14 +26,16 @@ module.exports = function({
});

if (taskUtil) {
const optimize = !bundleOptions || bundleOptions.optimize;

// Omit -dbg files for optimize bundles and vice versa
const filterTag = bundleOptions.optimize ?
const filterTag = optimize ?
taskUtil.STANDARD_TAGS.IsDebugVariant : taskUtil.STANDARD_TAGS.HasDebugVariant;
combo = combo.filter(function(resource) {
return !taskUtil.getTag(resource, filterTag);
});

if (!bundleOptions.optimize) {
if (!optimize) {
// For "unoptimized" bundles, the non-debug files have already been filtered out
// Now rename the debug variants to the same name so that they appear like the original
// resource to the bundler
Expand Down

0 comments on commit 3174d3c

Please sign in to comment.