Skip to content

@ui5/builder/processors/bundlers/moduleBundler

Methods

(static) default(parameters) → {Promise<Array<module:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundlerResult>>}

Description: Legacy module bundler.

Source: builder/lib/processors/bundlers/moduleBundler.js, line 128

Parameters:
NameTypeDescription
parametersobjectParameters
Properties:
NameTypeDescription
resourcesArray<@ui5/fs/Resource>Resources
optionsobjectOptions
Properties
NameTypeAttributesDefaultDescription
moduleNameMappingobjectoptionalOptional mapping of resource paths to module name in order to overwrite the default determination
bundleDefinitionmodule:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundleDefinitionModule
bundle definition
bundleOptionsmodule:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundleOptionsoptionalModule
bundle options
targetUi5CoreVersionstringoptionalOptional semver compliant sap.ui.core project version, e.g '2.0.0'.
This allows the bundler to make assumptions on available runtime APIs.
Omit if the ultimate UI5 version at runtime is unknown or can't be determined.
allowStringBundlingbooleanoptionalfalseOptional flag to allow bundling of modules as a string.
Returns:

Promise resolving with module bundle resources

Type: Promise<Array<module:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundlerResult>>

Type Definitions

ModuleBundleDefinition

Description: Module bundle definition

Source: builder/lib/processors/bundlers/moduleBundler.js, line 90

Properties:
NameTypeAttributesDefaultDescription
namestringThe module bundle name
defaultFileTypesArray<string>optional[".js", ".control.xml", ".fragment.html", ".fragment.json", ".fragment.xml", ".view.html", ".view.json", ".view.xml"]List of default file types to be included in the bundle
sectionsArray<module:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundleDefinitionSection>List of module bundle definition sections.

Module bundle definition

Type:
  • object

ModuleBundleDefinitionSection

Description: A ModuleBundleDefinitionSection specifies the embedding mode (either 'provided', 'raw', 'preload', 'require' or 'bundleInfo') and lists the resources that should be in- or excluded from the section.

Module bundle section modes

  • provided: A section of mode 'provided' defines a set of modules that should not be included in the bundle file itself, but which should be assumed to be already loaded (or 'provided') by the environment into which the bundle module is loaded.
  • raw: A 'raw' section determines the set of modules that should be embedded, sorts them according to their dependencies and writes them out 1:1 without any transformation or wrapping (raw). Only JavaScript sources can be embedded in a raw section.
  • preload: A 'preload' section packages resources that should be stored in the preload cache in the client. They can embed any textual resource type (JavaScript, XML, JSON and .properties files) that the bundling supports. UI5 modules are wrapped into a 'sap.ui.predefine' call. Other JavaScript modules will be embedded into a 'jQuery.sap.registerPreload' call, or in a "sap.ui.require.preload" call when the ui5loader is available.
  • require: A `require` section is transformed into a `sap.ui.require` call with all the dependencies resolved. This module comes with an `async` flag. When set to false, the modules are loaded using `sap.ui.requireSync` instead of `sap.ui.require`. **Note:** The `sap.ui.requireSync` API is not available in UI5 version 2.x.
  • bundleInfo: A 'bundleInfo' section describes the content of another named bundle. This information is transformed into a ui5loader-"bundlesUI5" configuration. At runtime, if a module is known to be contained in a bundle, the loader will require that bundle before the module itself. This requires the ui5loader to be available at build time and UI5 version 1.74.0 or higher at runtime.

Source: builder/lib/processors/bundlers/moduleBundler.js, line 12

Properties:



// Includes everything from "some/path/to/module/",
// but excludes the subfolder "some/path/to/module/to/be/excluded/"
const section = {
"filters": [
"some/path/to/module/",
"!some/path/to/module/to/be/excluded/"
]
};
NameTypeAttributesDefaultDescription
modestringThe embedding mode. Either 'provided', 'raw', 'preload', 'require' or 'bundleInfo'
filtersArray<string>List of modules declared as glob patterns (resource name patterns) that should be
in- or excluded.
A pattern ending with a slash '/' will, similarly to the use of a single '*' or double '**' asterisk,
denote an arbitrary number of characters or folder names.
Excludes should be marked with a leading exclamation mark '!'. The order of filters is relevant; a later
exclusion overrides an earlier inclusion, and vice versa.

List of modules as glob patterns that should be in- or excluded
resolvebooleanoptionalfalseWhether (transitive) dependencies of modules that match the given filters
should be resolved and added to the module set
resolveConditionalbooleanoptionalfalseWhether conditional dependencies of modules should be resolved
and added to the module set for this section
rendererbooleanoptionalfalseWhether renderers for controls should be added to the module set
declareRawModulesbooleanoptionalfalseWhether raw modules should be declared after jQuery.sap.global
became available. With the usage of the ui5loader, this flag should be set to 'false'
sortbooleanoptionaltrueWhether the modules should be sorted by their dependencies
asyncbooleanoptionaltrueWhether the `require` section of the module should be loaded asynchronously.
When set to true, the modules are loaded using a single `sap.ui.require` call instead of multiple
`sap.ui.requireSync` calls.
The latter API is not available in UI5 version 2.x.
**Note:** This property is available only for `mode=require`.

A ModuleBundleDefinitionSection specifies the embedding mode (either 'provided', 'raw', 'preload', 'require' or 'bundleInfo') and lists the resources that should be in- or excluded from the section.

Module bundle section modes

  • provided: A section of mode 'provided' defines a set of modules that should not be included in the bundle file itself, but which should be assumed to be already loaded (or 'provided') by the environment into which the bundle module is loaded.
  • raw: A 'raw' section determines the set of modules that should be embedded, sorts them according to their dependencies and writes them out 1:1 without any transformation or wrapping (raw). Only JavaScript sources can be embedded in a raw section.
  • preload: A 'preload' section packages resources that should be stored in the preload cache in the client. They can embed any textual resource type (JavaScript, XML, JSON and .properties files) that the bundling supports. UI5 modules are wrapped into a 'sap.ui.predefine' call. Other JavaScript modules will be embedded into a 'jQuery.sap.registerPreload' call, or in a "sap.ui.require.preload" call when the ui5loader is available.
  • require: A `require` section is transformed into a `sap.ui.require` call with all the dependencies resolved. This module comes with an `async` flag. When set to false, the modules are loaded using `sap.ui.requireSync` instead of `sap.ui.require`. **Note:** The `sap.ui.requireSync` API is not available in UI5 version 2.x.
  • bundleInfo: A 'bundleInfo' section describes the content of another named bundle. This information is transformed into a ui5loader-"bundlesUI5" configuration. At runtime, if a module is known to be contained in a bundle, the loader will require that bundle before the module itself. This requires the ui5loader to be available at build time and UI5 version 1.74.0 or higher at runtime.

Type:
  • object

ModuleBundleOptions

Description: Module bundle options

Source: builder/lib/processors/bundlers/moduleBundler.js, line 102

Properties:
NameTypeAttributesDefaultDescription
optimizebooleanoptionaltrueWhether the module bundle gets minified
sourceMapbooleanoptionaltrueWhether to generate a source map file for the bundle
decorateBootstrapModulebooleanoptionalfalseIf set to 'false', bootable bundles won't be decorated
with an optimization marker
addTryCatchRestartWrapperbooleanoptionalfalseWhether to wrap bootable bundles with
a try/catch to filter out "Restart" errors
numberOfPartsnumberoptional1The number of parts the module bundle should be splitted
ignoreMissingModulesbooleanoptionalfalseWhen searching for modules which are optional for further
processing, do not throw in case they are missing

Module bundle options

Type:
  • object

ModuleBundlerResult

Description: Result set

Source: builder/lib/processors/bundlers/moduleBundler.js, line 118

Properties:
NameTypeDescription
bundle@ui5/fs/ResourceBundle resource
sourceMap@ui5/fs/ResourceSource Map

Result set

Type:
  • object