@ui5/builder 3.0.0-alpha.1 → 3.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +867 -0
  2. package/index.js +0 -43
  3. package/lib/lbt/analyzer/FioriElementsAnalyzer.js +23 -12
  4. package/lib/lbt/analyzer/JSModuleAnalyzer.js +115 -61
  5. package/lib/lbt/analyzer/SmartTemplateAnalyzer.js +23 -12
  6. package/lib/lbt/analyzer/XMLCompositeAnalyzer.js +29 -19
  7. package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +2 -1
  8. package/lib/lbt/analyzer/analyzeLibraryJS.js +15 -0
  9. package/lib/lbt/bundle/Builder.js +365 -138
  10. package/lib/lbt/bundle/BundleWriter.js +17 -0
  11. package/lib/lbt/bundle/Resolver.js +2 -2
  12. package/lib/lbt/calls/SapUiDefine.js +13 -7
  13. package/lib/lbt/resources/LocatorResource.js +7 -7
  14. package/lib/lbt/resources/LocatorResourcePool.js +8 -4
  15. package/lib/lbt/resources/ResourceCollector.js +22 -15
  16. package/lib/lbt/resources/ResourceInfoList.js +0 -1
  17. package/lib/lbt/resources/ResourcePool.js +7 -6
  18. package/lib/lbt/utils/ASTUtils.js +45 -18
  19. package/lib/lbt/utils/escapePropertiesFile.js +3 -6
  20. package/lib/lbt/utils/parseUtils.js +1 -1
  21. package/lib/processors/bundlers/moduleBundler.js +31 -10
  22. package/lib/processors/jsdoc/lib/createIndexFiles.js +1 -1
  23. package/lib/processors/jsdoc/lib/transformApiJson.js +78 -22
  24. package/lib/processors/jsdoc/lib/ui5/plugin.js +414 -122
  25. package/lib/processors/jsdoc/lib/ui5/template/publish.js +112 -91
  26. package/lib/processors/jsdoc/lib/ui5/template/utils/versionUtil.js +1 -1
  27. package/lib/processors/manifestCreator.js +8 -45
  28. package/lib/processors/minifier.js +11 -5
  29. package/lib/tasks/buildThemes.js +1 -1
  30. package/lib/tasks/bundlers/generateBundle.js +70 -30
  31. package/lib/tasks/bundlers/generateComponentPreload.js +26 -19
  32. package/lib/tasks/bundlers/generateFlexChangesBundle.js +10 -5
  33. package/lib/tasks/bundlers/generateLibraryPreload.js +113 -94
  34. package/lib/tasks/bundlers/generateManifestBundle.js +8 -10
  35. package/lib/tasks/bundlers/generateStandaloneAppBundle.js +42 -10
  36. package/lib/tasks/bundlers/utils/createModuleNameMapping.js +31 -0
  37. package/lib/tasks/generateCachebusterInfo.js +7 -3
  38. package/lib/tasks/generateLibraryManifest.js +6 -8
  39. package/lib/tasks/generateResourcesJson.js +3 -3
  40. package/lib/tasks/generateThemeDesignerResources.js +118 -2
  41. package/lib/tasks/generateVersionInfo.js +5 -5
  42. package/lib/tasks/jsdoc/generateJsdoc.js +1 -1
  43. package/lib/tasks/minify.js +14 -4
  44. package/lib/tasks/taskRepository.js +1 -13
  45. package/lib/tasks/transformBootstrapHtml.js +6 -1
  46. package/package.json +13 -11
  47. package/lib/builder/BuildContext.js +0 -56
  48. package/lib/builder/ProjectBuildContext.js +0 -57
  49. package/lib/builder/builder.js +0 -419
  50. package/lib/tasks/TaskUtil.js +0 -160
  51. package/lib/types/AbstractBuilder.js +0 -270
  52. package/lib/types/AbstractFormatter.js +0 -66
  53. package/lib/types/AbstractUi5Formatter.js +0 -95
  54. package/lib/types/application/ApplicationBuilder.js +0 -211
  55. package/lib/types/application/ApplicationFormatter.js +0 -227
  56. package/lib/types/application/applicationType.js +0 -15
  57. package/lib/types/library/LibraryBuilder.js +0 -231
  58. package/lib/types/library/LibraryFormatter.js +0 -519
  59. package/lib/types/library/libraryType.js +0 -15
  60. package/lib/types/module/ModuleBuilder.js +0 -7
  61. package/lib/types/module/ModuleFormatter.js +0 -54
  62. package/lib/types/module/moduleType.js +0 -15
  63. package/lib/types/themeLibrary/ThemeLibraryBuilder.js +0 -63
  64. package/lib/types/themeLibrary/ThemeLibraryFormatter.js +0 -90
  65. package/lib/types/themeLibrary/themeLibraryType.js +0 -15
  66. package/lib/types/typeRepository.js +0 -46
@@ -11,6 +11,8 @@ const SPACES_OR_TABS_ONLY = /^[ \t]+$/;
11
11
  *
12
12
  * Most methods have been extracted from JSMergeWriter.
13
13
  *
14
+ * columnOffset and lineOffset are used for sourcemap merging as reference to where we are at a given point in time
15
+ *
14
16
  * @author Frank Weigel
15
17
  * @since 1.27.0
16
18
  * @private
@@ -18,6 +20,8 @@ const SPACES_OR_TABS_ONLY = /^[ \t]+$/;
18
20
  class BundleWriter {
19
21
  constructor() {
20
22
  this.buf = "";
23
+ this.lineOffset = 0;
24
+ this.columnOffset = 0;
21
25
  this.segments = [];
22
26
  this.currentSegment = null;
23
27
  this.currentSourceIndex = 0;
@@ -28,6 +32,11 @@ class BundleWriter {
28
32
  let writeBuf = "";
29
33
  for ( let i = 0; i < str.length; i++ ) {
30
34
  writeBuf += str[i];
35
+ if (str[i] != null && str[i].split) {
36
+ const strSplit = str[i].split(NL);
37
+ this.lineOffset += strSplit.length - 1;
38
+ this.columnOffset += strSplit[strSplit.length - 1].length;
39
+ }
31
40
  }
32
41
  if ( writeBuf.length >= 1 ) {
33
42
  this.buf += writeBuf;
@@ -40,15 +49,23 @@ class BundleWriter {
40
49
  writeln(...str) {
41
50
  for ( let i = 0; i < str.length; i++ ) {
42
51
  this.buf += str[i];
52
+ if (str[i] != null && str[i].split) {
53
+ const strSplit = str[i].split(NL);
54
+ this.lineOffset += strSplit.length - 1;
55
+ }
43
56
  }
44
57
  this.buf += NL;
45
58
  this.endsWithNewLine = true;
59
+ this.lineOffset += 1;
60
+ this.columnOffset = 0;
46
61
  }
47
62
 
48
63
  ensureNewLine() {
49
64
  if ( !this.endsWithNewLine ) {
50
65
  this.buf += NL;
51
66
  this.endsWithNewLine = true;
67
+ this.lineOffset += 1;
68
+ this.columnOffset = 0;
52
69
  }
53
70
  }
54
71
 
@@ -292,12 +292,12 @@ class BundleResolver {
292
292
  if ( section.mode == SectionType.Raw && section.sort !== false ) {
293
293
  // sort the modules in topological order
294
294
  return topologicalSort(pool, modules).then( (modules) => {
295
- log.verbose(" resolved modules (sorted): %s", modules);
295
+ log.silly(" resolved modules (sorted): %s", modules);
296
296
  return modules;
297
297
  });
298
298
  }
299
299
 
300
- log.verbose(" resolved modules: %s", modules);
300
+ log.silly(" resolved modules: %s", modules);
301
301
  return modules;
302
302
  }).then( function(modules) {
303
303
  resolvedSection.modules = modules;
@@ -2,7 +2,7 @@
2
2
 
3
3
  const {Syntax} = require("../utils/parseUtils");
4
4
  const ModuleName = require("../utils/ModuleName");
5
- const {isString, isBoolean} = require("../utils/ASTUtils");
5
+ const {isBoolean, getStringValue} = require("../utils/ASTUtils");
6
6
 
7
7
  class SapUiDefineCall {
8
8
  constructor(node, moduleName) {
@@ -11,6 +11,7 @@ class SapUiDefineCall {
11
11
  this.dependencyArray = null;
12
12
  this.factory = null;
13
13
  this.exportAsGlobal = false;
14
+ this.paramNames = null;
14
15
 
15
16
  const args = node.arguments;
16
17
  if ( args == null ) {
@@ -27,28 +28,33 @@ class SapUiDefineCall {
27
28
  let i = 0;
28
29
  let params;
29
30
 
30
- if ( i < args.length && isString(args[i]) ) {
31
+ const name = getStringValue(args[i]);
32
+ if ( i < args.length && name ) {
31
33
  // assert(String)
32
- this.name = args[i++].value;
34
+ this.name = name;
35
+ i++;
33
36
  }
34
37
 
35
38
  if ( i < args.length && args[i].type === Syntax.ArrayExpression ) {
36
39
  this.dependencyArray = args[i++];
37
40
  this.dependencies = this.dependencyArray.elements.map( (elem) => {
38
- if ( !isString(elem) ) {
41
+ const value = getStringValue(elem);
42
+ if ( !value ) {
39
43
  throw new TypeError();
40
44
  }
41
- return ModuleName.resolveRelativeRequireJSName(this.name, elem.value);
45
+ return ModuleName.resolveRelativeRequireJSName(this.name, value);
42
46
  });
43
47
  this.dependencyInsertionIdx = this.dependencyArray.elements.length;
44
48
  }
45
49
 
46
- if ( i < args.length && args[i].type === Syntax.FunctionExpression ) {
50
+ if ( i < args.length && (
51
+ args[i].type === Syntax.FunctionExpression || args[i].type === Syntax.ArrowFunctionExpression)
52
+ ) {
47
53
  this.factory = args[i++];
48
54
  params = this.factory.params;
49
55
  this.paramNames = params.map( (param) => {
50
56
  if ( param.type !== Syntax.Identifier ) {
51
- throw new TypeError();
57
+ return null;
52
58
  }
53
59
  return param.name;
54
60
  });
@@ -1,12 +1,8 @@
1
1
  const Resource = require("./Resource");
2
2
 
3
- function extractName(path) {
4
- return path.slice( "/resources/".length);
5
- }
6
-
7
3
  class LocatorResource extends Resource {
8
- constructor(pool, resource) {
9
- super(pool, extractName(resource.getPath()), null, resource.getStatInfo());
4
+ constructor(pool, resource, moduleName) {
5
+ super(pool, moduleName, null, resource.getStatInfo());
10
6
  this.resource = resource;
11
7
  }
12
8
 
@@ -15,7 +11,11 @@ class LocatorResource extends Resource {
15
11
  }
16
12
 
17
13
  getProject() {
18
- return this.resource._project;
14
+ return this.resource.getProject();
15
+ }
16
+
17
+ getPath() {
18
+ return this.resource.getPath();
19
19
  }
20
20
  }
21
21
 
@@ -2,12 +2,16 @@ const ResourcePool = require("./ResourcePool");
2
2
  const LocatorResource = require("./LocatorResource");
3
3
 
4
4
  class LocatorResourcePool extends ResourcePool {
5
- prepare(resources) {
5
+ prepare(resources, moduleNameMapping) {
6
6
  resources = resources.filter( (res) => !res.getStatInfo().isDirectory() );
7
7
  return Promise.all(
8
- resources.map(
9
- (resource) => this.addResource( new LocatorResource(this, resource) )
10
- ).filter(Boolean)
8
+ resources.map((resource) => {
9
+ let moduleName = moduleNameMapping && moduleNameMapping[resource.getPath()];
10
+ if (!moduleName) {
11
+ moduleName = resource.getPath().slice("/resources/".length);
12
+ }
13
+ return this.addResource(new LocatorResource(this, resource, moduleName));
14
+ }).filter(Boolean)
11
15
  );
12
16
  }
13
17
  }
@@ -110,10 +110,11 @@ class ResourceCollector {
110
110
  }
111
111
 
112
112
  async enrichWithDependencyInfo(resourceInfo) {
113
- return this._pool.getModuleInfo(resourceInfo.name).then(async (moduleInfo) => {
114
- if ( moduleInfo.name ) {
113
+ return this._pool.getModuleInfo(resourceInfo.name, resourceInfo.module).then(async (moduleInfo) => {
114
+ if ( !resourceInfo.module && moduleInfo.name ) {
115
115
  resourceInfo.module = moduleInfo.name;
116
116
  }
117
+
117
118
  if ( moduleInfo.dynamicDependencies ) {
118
119
  resourceInfo.dynRequired = true;
119
120
  }
@@ -279,37 +280,43 @@ class ResourceCollector {
279
280
 
280
281
  await Promise.all(promises);
281
282
 
282
- const debugBundlePromises = [];
283
-
284
- for (let i = debugResourcesInfo.length - 1; i >= 0; i--) {
285
- const dbgInfo = debugResourcesInfo[i];
286
- const nonDebugName = ResourceInfoList.getNonDebugName(dbgInfo.name);
283
+ await Promise.all(debugResourcesInfo.map(async (dbgInfo) => {
284
+ const debugName = dbgInfo.name;
285
+ const nonDebugName = ResourceInfoList.getNonDebugName(debugName);
287
286
  const nonDbgInfo = this._resources.get(nonDebugName);
288
287
 
289
288
  // FIXME: "merged" property is only calculated in ResourceInfo#copyFrom
290
289
  // Therefore using the same logic here to compute it.
290
+
291
+ // TODO: Idea: Use IsDebugVariant tag to decide whether to analyze the resource
292
+ // If the tag is set, we don't expect different analysis results so we can copy the info (else-path)
293
+ // Only when the tag is not set, we analyze the resource with its name (incl. -dbg)
294
+
291
295
  if (!nonDbgInfo || (nonDbgInfo.included != null && nonDbgInfo.included.size > 0)) {
292
296
  // We need to analyze the dbg resource if there is no non-dbg variant or
293
297
  // it is a bundle because we will (usually) have different content.
294
- debugBundlePromises.push(
295
- this.enrichWithDependencyInfo(dbgInfo)
296
- );
298
+
299
+ if (nonDbgInfo) {
300
+ // Always use the non-debug module name, if available
301
+ dbgInfo.module = nonDbgInfo.module;
302
+ }
303
+ await this.enrichWithDependencyInfo(dbgInfo);
297
304
  } else {
298
305
  // If the non-dbg resource is not a bundle, we can just copy over the info and skip
299
306
  // analyzing the dbg variant as both should have the same info.
300
307
 
301
- const newDbgInfo = new ResourceInfo(dbgInfo.name);
308
+ const newDbgInfo = new ResourceInfo(debugName);
302
309
 
303
310
  // First copy info of analysis from non-dbg file (included, required, condRequired, ...)
304
311
  newDbgInfo.copyFrom(null, nonDbgInfo);
305
312
  // Then copy over info from dbg file to properly set name, isDebug, etc.
306
313
  newDbgInfo.copyFrom(null, dbgInfo);
314
+ // Finally, set the module name to the non-dbg name
315
+ newDbgInfo.module = nonDbgInfo.module;
307
316
 
308
- this._resources.set(dbgInfo.name, newDbgInfo);
317
+ this._resources.set(debugName, newDbgInfo);
309
318
  }
310
- }
311
-
312
- await Promise.all(debugBundlePromises);
319
+ }));
313
320
  }
314
321
 
315
322
  createOrphanFilters() {
@@ -48,7 +48,6 @@ class ResourceInfoList {
48
48
  if ( myInfo == null ) {
49
49
  myInfo = new ResourceInfo(relativeName);
50
50
  myInfo.size = info.size;
51
- myInfo.module = ResourceInfoList.getNonDebugName(info.name);
52
51
  this.resources.push(myInfo);
53
52
  this.resourcesByName.set(relativeName, myInfo);
54
53
  }
@@ -176,17 +176,18 @@ class ResourcePool {
176
176
  /**
177
177
  * Retrieves the module info
178
178
  *
179
- * @param {string} name module name
179
+ * @param {string} resourceName resource/module name
180
+ * @param {string} [moduleName] module name, in case it differs from the resource name (e.g. for -dbg resources)
180
181
  * @returns {Promise<ModuleInfo>}
181
182
  */
182
- async getModuleInfo(name) {
183
- let info = this._dependencyInfos.get(name);
183
+ async getModuleInfo(resourceName, moduleName) {
184
+ let info = this._dependencyInfos.get(resourceName);
184
185
  if ( info == null ) {
185
186
  info = Promise.resolve().then(async () => {
186
- const resource = await this.findResource(name);
187
- return determineDependencyInfo( resource, this._rawModuleInfos.get(name), this );
187
+ const resource = await this.findResource(resourceName);
188
+ return determineDependencyInfo( resource, this._rawModuleInfos.get(moduleName || resourceName), this );
188
189
  });
189
- this._dependencyInfos.set(name, info);
190
+ this._dependencyInfos.set(resourceName, info);
190
191
  }
191
192
  return info;
192
193
  }
@@ -13,10 +13,31 @@ const {Syntax} = require("../utils/parseUtils");
13
13
  * @returns {boolean} Whether the node is a literal and whether its value matches the given string
14
14
  */
15
15
  function isString(node, literal) {
16
- if ( node == null || node.type !== Syntax.Literal || typeof node.value !== "string" ) {
16
+ const value = getStringValue(node);
17
+ if (value === undefined) {
17
18
  return false;
18
19
  }
19
- return literal == null ? true : node.value === literal;
20
+ return literal == null ? true: value === literal;
21
+ }
22
+
23
+ function getStringValue(node) {
24
+ if (isLiteral(node)) {
25
+ return node.value;
26
+ } else if (isTemplateLiteralWithoutExpression(node)) {
27
+ return node?.quasis?.[0]?.value?.cooked;
28
+ } else {
29
+ return undefined;
30
+ }
31
+ }
32
+
33
+ function isLiteral(node) {
34
+ return node && node.type === Syntax.Literal && typeof node.value === "string";
35
+ }
36
+
37
+ function isTemplateLiteralWithoutExpression(node) {
38
+ return node?.type === Syntax.TemplateLiteral &&
39
+ node?.expressions?.length === 0 &&
40
+ node?.quasis?.length === 1;
20
41
  }
21
42
 
22
43
  function isBoolean(node, literal) {
@@ -47,27 +68,27 @@ function isNamedObject(node, objectPath, length) {
47
68
  }
48
69
 
49
70
  function isIdentifier(node, name) {
50
- if ( node.type != Syntax.Identifier ) {
51
- return false;
52
- }
53
- if ( typeof name == "string" ) {
71
+ if ( node.type === Syntax.Identifier && typeof name == "string" ) {
54
72
  return name === node.name;
73
+ } else if ( node.type === Syntax.Identifier && Array.isArray(name) ) {
74
+ return name.find((name) => name === node.name || name === "*") !== undefined;
75
+ } else if ( node.type === Syntax.ObjectPattern ) {
76
+ return node.properties.filter((childnode) => isIdentifier(childnode.key, name)).length > 0;
77
+ } else if ( node.type === Syntax.ArrayPattern ) {
78
+ return node.elements.filter((childnode) => isIdentifier(childnode, name)).length > 0;
79
+ } else {
80
+ return false;
55
81
  }
56
- for (let i = 0; i < name.length; i++) {
57
- if ( name[i] === node.name || name[i] === "*" ) {
58
- return true;
59
- }
60
- }
61
- return false;
62
82
  }
63
83
 
64
84
  function getPropertyKey(property) {
65
- if ( property.key.type === Syntax.Identifier ) {
85
+ if ( property.type === Syntax.SpreadElement ) {
86
+ // TODO: Support interpreting SpreadElements
87
+ return;
88
+ } else if ( property.key.type === Syntax.Identifier && property.computed !== true ) {
66
89
  return property.key.name;
67
90
  } else if ( property.key.type === Syntax.Literal ) {
68
91
  return String(property.key.value);
69
- } else {
70
- throw new Error();
71
92
  }
72
93
  }
73
94
 
@@ -102,10 +123,15 @@ function getValue(obj, names) {
102
123
  */
103
124
  function getStringArray(array, skipNonStringLiterals) {
104
125
  return array.elements.reduce( (result, item) => {
105
- if ( isString(item) ) {
106
- result.push(item.value);
126
+ const value = getStringValue(item);
127
+ if ( value !== undefined ) {
128
+ result.push(value);
107
129
  } else if ( !skipNonStringLiterals ) {
108
- throw new TypeError("array element is not a string literal:" + item.type);
130
+ if (item.type === Syntax.TemplateLiteral) {
131
+ throw new TypeError("array element is a template literal with expressions");
132
+ } else {
133
+ throw new TypeError("array element is not a string literal: " + item.type);
134
+ }
109
135
  }
110
136
  return result;
111
137
  }, []);
@@ -113,6 +139,7 @@ function getStringArray(array, skipNonStringLiterals) {
113
139
 
114
140
  module.exports = {
115
141
  isString,
142
+ getStringValue,
116
143
  isBoolean,
117
144
  isMethodCall,
118
145
  isNamedObject,
@@ -4,7 +4,7 @@ const nonAsciiEscaper = require("../../processors/nonAsciiEscaper");
4
4
  * Can be used to escape *.properties files.
5
5
  *
6
6
  * Input encoding is read from project configuration.
7
- * In case the resource belongs to no project (e.g. bundler is used standalone) the default is "ISO-8859-1".
7
+ * In case the resource belongs to no project (e.g. bundler is used standalone) the default is "UTF-8".
8
8
  *
9
9
  * @private
10
10
  * @param {Resource} resource the resource for which the content will be escaped
@@ -12,13 +12,10 @@ const nonAsciiEscaper = require("../../processors/nonAsciiEscaper");
12
12
  */
13
13
  module.exports = async function(resource) {
14
14
  const project = resource.getProject();
15
- let propertiesFileSourceEncoding = project &&
16
- project.resources &&
17
- project.resources.configuration &&
18
- project.resources.configuration.propertiesFileSourceEncoding;
15
+ let propertiesFileSourceEncoding = project && project.getPropertiesFileSourceEncoding();
19
16
 
20
17
  if (!propertiesFileSourceEncoding) {
21
- if (project && ["0.1", "1.0", "1.1"].includes(project.specVersion)) {
18
+ if (project && ["0.1", "1.0", "1.1"].includes(project.getSpecVersion())) {
22
19
  // default encoding to "ISO-8859-1" for old specVersions
23
20
  propertiesFileSourceEncoding = "ISO-8859-1";
24
21
  } else {
@@ -9,7 +9,7 @@ function parseJS(code, userOptions = {}) {
9
9
  // allowed options and their defaults
10
10
  const options = {
11
11
  comment: false,
12
- ecmaVersion: 2021,
12
+ ecmaVersion: 2021, // NOTE: Adopt JSModuleAnalyzer.js to allow new Syntax when upgrading to newer ECMA versions
13
13
  range: false,
14
14
  sourceType: "script",
15
15
  };
@@ -90,9 +90,10 @@ const log = require("@ui5/logger").getLogger("builder:processors:bundlers:module
90
90
  * @public
91
91
  * @typedef {object} ModuleBundleOptions
92
92
  * @property {boolean} [optimize=true] Whether the module bundle gets minified
93
- * @property {boolean} [decorateBootstrapModule=false] If set to 'false', the module won't be decorated
93
+ * @property {boolean} [sourceMap=true] Whether to generate a source map file for the bundle
94
+ * @property {boolean} [decorateBootstrapModule=false] If set to 'false', bootable bundles won't be decorated
94
95
  * with an optimization marker
95
- * @property {boolean} [addTryCatchRestartWrapper=false] Whether to wrap bootable module bundles with
96
+ * @property {boolean} [addTryCatchRestartWrapper=false] Whether to wrap bootable bundles with
96
97
  * a try/catch to filter out "Restart" errors
97
98
  * @property {boolean} [usePredefineCalls=false] If set to 'true', sap.ui.predefine is used for UI5 modules
98
99
  * @property {number} [numberOfParts=1] The number of parts the module bundle should be splitted
@@ -101,21 +102,35 @@ const log = require("@ui5/logger").getLogger("builder:processors:bundlers:module
101
102
  */
102
103
 
103
104
  /**
104
- * Legacy preload bundler.
105
+ * Result set
106
+ *
107
+ * @public
108
+ * @typedef {object} ModuleBundlerResult
109
+ * @property {module:@ui5/fs.Resource} bundle Bundle resource
110
+ * @property {module:@ui5/fs.Resource} sourceMap Source Map
111
+ * @memberof module:@ui5/builder.processors
112
+ */
113
+
114
+ /**
115
+ * Legacy module bundler.
105
116
  *
106
117
  * @public
107
118
  * @alias module:@ui5/builder.processors.moduleBundler
108
119
  * @param {object} parameters Parameters
109
120
  * @param {module:@ui5/fs.Resource[]} parameters.resources Resources
110
121
  * @param {object} parameters.options Options
122
+ * @param {object} [parameters.options.moduleNameMapping]
123
+ Optional mapping of resource paths to module name in order to overwrite the default determination
111
124
  * @param {ModuleBundleDefinition} parameters.options.bundleDefinition Module bundle definition
112
125
  * @param {ModuleBundleOptions} [parameters.options.bundleOptions] Module bundle options
113
- * @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving with module bundle resources
126
+ * @returns {Promise<module:@ui5/builder.processors.ModuleBundlerResult[]>}
127
+ * Promise resolving with module bundle resources
114
128
  */
115
- module.exports = function({resources, options: {bundleDefinition, bundleOptions}}) {
129
+ module.exports = function({resources, options: {bundleDefinition, bundleOptions, moduleNameMapping}}) {
116
130
  // Apply defaults without modifying the passed object
117
131
  bundleOptions = Object.assign({}, {
118
132
  optimize: true,
133
+ sourceMap: true,
119
134
  decorateBootstrapModule: false,
120
135
  addTryCatchRestartWrapper: false,
121
136
  usePredefineCalls: false,
@@ -133,8 +148,7 @@ module.exports = function({resources, options: {bundleDefinition, bundleOptions}
133
148
  log.verbose(`bundleDefinition: ${JSON.stringify(bundleDefinition, null, 2)}`);
134
149
  log.verbose(`bundleOptions: ${JSON.stringify(bundleOptions, null, 2)}`);
135
150
  }
136
-
137
- return pool.prepare( resources ).
151
+ return pool.prepare( resources, moduleNameMapping ).
138
152
  then( () => builder.createBundle(bundleDefinition, bundleOptions) ).
139
153
  then( (results) => {
140
154
  let bundles;
@@ -146,13 +160,20 @@ module.exports = function({resources, options: {bundleDefinition, bundleOptions}
146
160
 
147
161
  return Promise.all(bundles.map((bundleObj) => {
148
162
  if ( bundleObj ) {
149
- const {name, content} = bundleObj;
163
+ const {name, content, sourceMap} = bundleObj;
150
164
  // console.log("creating bundle as '%s'", "/resources/" + name);
151
- const resource = new EvoResource({
165
+ const res = {};
166
+ res.bundle = new EvoResource({
152
167
  path: "/resources/" + name,
153
168
  string: content
154
169
  });
155
- return resource;
170
+ if (sourceMap) {
171
+ res.sourceMap = new EvoResource({
172
+ path: "/resources/" + name + ".map",
173
+ string: sourceMap
174
+ });
175
+ }
176
+ return res;
156
177
  }
157
178
  }));
158
179
  });
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Node script to create cross-library API index files for use in the UI5 SDKs.
3
3
  *
4
- * (c) Copyright 2009-2021 SAP SE or an SAP affiliate company.
4
+ * (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
5
5
  * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
6
6
  */
7
7