-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Bundle 'require' section with async flag for specVersion: 4…
….0 (#1042) JIRA: CPOUI5FOUNDATION-835 This change completes #1033 with check for specVersion: 4.0 and enforcing default async flag for require section in 'bundleDefinitions' --------- Co-authored-by: Merlin Beutlberger <[email protected]>
- Loading branch information
1 parent
934956a
commit dfa67fe
Showing
10 changed files
with
465 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
lib/tasks/bundlers/utils/applyDefaultsToBundleDefinition.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Applies default values to bundleDefinitions | ||
* | ||
* @param {module:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundleDefinition} bundleDefinition Module | ||
* bundle definition | ||
* @param {@ui5/project/build/helpers/TaskUtil|object} [taskUtil] TaskUtil | ||
* | ||
* @returns {module:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundleDefinition} | ||
*/ | ||
export function applyDefaultsToBundleDefinition(bundleDefinition, taskUtil) { | ||
bundleDefinition.sections = bundleDefinition?.sections?.map((section) => { | ||
const defaultValues = { | ||
resolve: false, | ||
resolveConditional: false, | ||
renderer: false, | ||
sort: true, | ||
declareRawModules: false, | ||
}; | ||
|
||
// Since specVersion: 4.0 "require" section starts loading asynchronously. | ||
// If specVersion cannot be determined, the latest spec is taken into account. | ||
// This is a breaking change in specVersion: 4.0 | ||
if (section.mode === "require" && (!taskUtil || taskUtil.getProject().getSpecVersion().gte("4.0"))) { | ||
defaultValues.async = true; | ||
} | ||
|
||
return Object.assign(defaultValues, section); | ||
}); | ||
|
||
return bundleDefinition; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.