@ui5/builder 3.0.0-alpha.9 → 3.0.0-beta.1

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 (83) hide show
  1. package/.reuse/dep5 +2 -2
  2. package/CHANGELOG.md +42 -1
  3. package/CONTRIBUTING.md +1 -1
  4. package/README.md +4 -4
  5. package/jsdoc.json +2 -2
  6. package/lib/lbt/UI5ClientConstants.js +7 -8
  7. package/lib/lbt/analyzer/ComponentAnalyzer.js +60 -22
  8. package/lib/lbt/analyzer/FioriElementsAnalyzer.js +31 -20
  9. package/lib/lbt/analyzer/JSModuleAnalyzer.js +107 -65
  10. package/lib/lbt/analyzer/SmartTemplateAnalyzer.js +31 -20
  11. package/lib/lbt/analyzer/XMLCompositeAnalyzer.js +35 -25
  12. package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +71 -18
  13. package/lib/lbt/analyzer/analyzeLibraryJS.js +22 -6
  14. package/lib/lbt/bundle/AutoSplitter.js +10 -11
  15. package/lib/lbt/bundle/Builder.js +33 -36
  16. package/lib/lbt/bundle/BundleDefinition.js +1 -5
  17. package/lib/lbt/bundle/BundleWriter.js +1 -2
  18. package/lib/lbt/bundle/ResolvedBundleDefinition.js +6 -7
  19. package/lib/lbt/bundle/Resolver.js +11 -12
  20. package/lib/lbt/calls/SapUiDefine.js +16 -11
  21. package/lib/lbt/graph/dependencyGraph.js +3 -4
  22. package/lib/lbt/graph/dominatorTree.js +3 -3
  23. package/lib/lbt/graph/topologicalSort.js +3 -3
  24. package/lib/lbt/resources/LibraryFileAnalyzer.js +5 -8
  25. package/lib/lbt/resources/LocatorResource.js +2 -2
  26. package/lib/lbt/resources/LocatorResourcePool.js +3 -3
  27. package/lib/lbt/resources/ModuleInfo.js +1 -2
  28. package/lib/lbt/resources/Resource.js +3 -4
  29. package/lib/lbt/resources/ResourceCollector.js +7 -8
  30. package/lib/lbt/resources/ResourceFilterList.js +38 -40
  31. package/lib/lbt/resources/ResourceInfo.js +1 -1
  32. package/lib/lbt/resources/ResourceInfoList.js +5 -3
  33. package/lib/lbt/resources/ResourcePool.js +15 -21
  34. package/lib/lbt/utils/ASTUtils.js +58 -44
  35. package/lib/lbt/utils/JSTokenizer.js +4 -4
  36. package/lib/lbt/utils/ModuleName.js +10 -20
  37. package/lib/lbt/utils/escapePropertiesFile.js +3 -3
  38. package/lib/lbt/utils/parseUtils.js +4 -10
  39. package/lib/processors/bootstrapHtmlTransformer.js +15 -7
  40. package/lib/processors/bundlers/flexChangesBundler.js +16 -8
  41. package/lib/processors/bundlers/manifestBundler.js +19 -10
  42. package/lib/processors/bundlers/moduleBundler.js +26 -15
  43. package/lib/processors/jsdoc/apiIndexGenerator.js +16 -9
  44. package/lib/processors/jsdoc/jsdocGenerator.js +31 -17
  45. package/lib/processors/jsdoc/lib/{createIndexFiles.js → createIndexFiles.cjs} +0 -0
  46. package/lib/processors/jsdoc/lib/{transformApiJson.js → transformApiJson.cjs} +58 -2
  47. package/lib/processors/jsdoc/lib/ui5/{plugin.js → plugin.cjs} +306 -119
  48. package/lib/processors/jsdoc/lib/ui5/template/{publish.js → publish.cjs} +1 -1
  49. package/lib/processors/jsdoc/lib/ui5/template/utils/{versionUtil.js → versionUtil.cjs} +0 -0
  50. package/lib/processors/jsdoc/sdkTransformer.js +18 -11
  51. package/lib/processors/libraryLessGenerator.js +28 -16
  52. package/lib/processors/manifestCreator.js +14 -13
  53. package/lib/processors/minifier.js +22 -16
  54. package/lib/processors/nonAsciiEscaper.js +16 -6
  55. package/lib/processors/resourceListCreator.js +13 -13
  56. package/lib/processors/stringReplacer.js +13 -6
  57. package/lib/processors/themeBuilder.js +33 -24
  58. package/lib/processors/versionInfoGenerator.js +33 -23
  59. package/lib/tasks/buildThemes.js +18 -11
  60. package/lib/tasks/bundlers/generateBundle.js +23 -12
  61. package/lib/tasks/bundlers/generateComponentPreload.js +18 -10
  62. package/lib/tasks/bundlers/generateFlexChangesBundle.js +16 -8
  63. package/lib/tasks/bundlers/generateLibraryPreload.js +22 -12
  64. package/lib/tasks/bundlers/generateManifestBundle.js +15 -6
  65. package/lib/tasks/bundlers/generateStandaloneAppBundle.js +21 -13
  66. package/lib/tasks/bundlers/utils/createModuleNameMapping.js +6 -6
  67. package/lib/tasks/escapeNonAsciiCharacters.js +12 -5
  68. package/lib/tasks/generateCachebusterInfo.js +16 -8
  69. package/lib/tasks/generateLibraryManifest.js +14 -8
  70. package/lib/tasks/generateResourcesJson.js +15 -9
  71. package/lib/tasks/generateThemeDesignerResources.js +19 -9
  72. package/lib/tasks/generateVersionInfo.js +12 -5
  73. package/lib/tasks/jsdoc/executeJsdocSdkTransformation.js +17 -9
  74. package/lib/tasks/jsdoc/generateApiIndex.js +16 -10
  75. package/lib/tasks/jsdoc/generateJsdoc.js +131 -119
  76. package/lib/tasks/minify.js +13 -6
  77. package/lib/tasks/replaceBuildtime.js +12 -5
  78. package/lib/tasks/replaceCopyright.js +12 -5
  79. package/lib/tasks/replaceVersion.js +12 -5
  80. package/lib/tasks/taskRepository.js +24 -29
  81. package/lib/tasks/transformBootstrapHtml.js +6 -5
  82. package/package.json +33 -18
  83. package/index.js +0 -173
@@ -23,13 +23,13 @@
23
23
  * This class can handle multiple concurrent analysis calls, it has no instance state other than the pool
24
24
  * (which is readonly).
25
25
  */
26
- "use strict";
27
26
 
28
- const ModuleName = require("../utils/ModuleName");
29
- const SapUiDefine = require("../calls/SapUiDefine");
30
- const {parseJS, Syntax} = require("../utils/parseUtils");
31
- const {getValue, isMethodCall, isString} = require("../utils/ASTUtils");
32
- const log = require("@ui5/logger").getLogger("lbt:analyzer:SmartTemplateAnalyzer");
27
+ import {fromUI5LegacyName} from "../utils/ModuleName.js";
28
+ import SapUiDefine from "../calls/SapUiDefine.js";
29
+ import {parseJS, Syntax} from "../utils/parseUtils.js";
30
+ import {getValue, isMethodCall, getStringValue} from "../utils/ASTUtils.js";
31
+ import logger from "@ui5/logger";
32
+ const log = logger.getLogger("lbt:analyzer:SmartTemplateAnalyzer");
33
33
 
34
34
  // ---------------------------------------------------------------------------------------------------------
35
35
 
@@ -84,7 +84,7 @@ class TemplateComponentAnalyzer {
84
84
  const st = (manifest && manifest["sap.ui.generic.app"]) || {};
85
85
  function recursePage(page) {
86
86
  if ( page.component && page.component.name ) {
87
- const module = ModuleName.fromUI5LegacyName( page.component.name + ".Component" );
87
+ const module = fromUI5LegacyName( page.component.name + ".Component" );
88
88
  log.verbose("template app: add dependency to template component %s", module);
89
89
  info.addDependency(module);
90
90
  promises.push( that._analyzeTemplateComponent(module, page, info) );
@@ -113,7 +113,7 @@ class TemplateComponentAnalyzer {
113
113
  const templateName = (pageConfig.component && pageConfig.component.settings &&
114
114
  pageConfig.component.settings.templateName) || defaultTemplateName;
115
115
  if ( templateName ) {
116
- const templateModuleName = ModuleName.fromUI5LegacyName( templateName, ".view.xml" );
116
+ const templateModuleName = fromUI5LegacyName( templateName, ".view.xml" );
117
117
  log.verbose("template app: add dependency to template view %s", templateModuleName);
118
118
  appInfo.addDependency(templateModuleName);
119
119
  }
@@ -134,25 +134,36 @@ class TemplateComponentAnalyzer {
134
134
  const TA = defineCall.findImportName("sap/suite/ui/generic/template/lib/TemplateAssembler.js");
135
135
  // console.log("local name for TemplateAssembler: %s", TA);
136
136
  if ( TA && defineCall.factory ) {
137
- defineCall.factory.body.body.forEach( (stmt) => {
138
- if ( stmt.type === Syntax.ReturnStatement &&
139
- isMethodCall(stmt.argument, [TA, "getTemplateComponent"]) &&
140
- stmt.argument.arguments.length > 2 &&
141
- stmt.argument.arguments[2].type === "ObjectExpression" ) {
142
- templateName = this._analyzeTemplateClassDefinition(stmt.argument.arguments[2]) || templateName;
137
+ if (defineCall.factory.type === Syntax.ArrowFunctionExpression &&
138
+ defineCall.factory.expression === true) {
139
+ if ( this._isTemplateClassDefinition(TA, defineCall.factory.body) ) {
140
+ templateName =
141
+ this._analyzeTemplateClassDefinition(defineCall.factory.body.arguments[2]) || templateName;
143
142
  }
144
- });
143
+ } else {
144
+ defineCall.factory.body.body.forEach( (stmt) => {
145
+ if ( stmt.type === Syntax.ReturnStatement &&
146
+ this._isTemplateClassDefinition(TA, stmt.argument)
147
+ ) {
148
+ templateName =
149
+ this._analyzeTemplateClassDefinition(stmt.argument.arguments[2]) || templateName;
150
+ }
151
+ });
152
+ }
145
153
  }
146
154
  }
147
155
  return templateName;
148
156
  }
149
157
 
158
+ _isTemplateClassDefinition(TA, node) {
159
+ return isMethodCall(node, [TA, "getTemplateComponent"]) &&
160
+ node.arguments.length > 2 &&
161
+ node.arguments[2].type === "ObjectExpression";
162
+ }
163
+
150
164
  _analyzeTemplateClassDefinition(clazz) {
151
- const defaultValue = getValue(clazz, ["metadata", "properties", "templateName", "defaultValue"]);
152
- if ( isString(defaultValue) ) {
153
- return defaultValue.value;
154
- }
165
+ return getStringValue(getValue(clazz, ["metadata", "properties", "templateName", "defaultValue"]));
155
166
  }
156
167
  }
157
168
 
158
- module.exports = TemplateComponentAnalyzer;
169
+ export default TemplateComponentAnalyzer;
@@ -1,10 +1,10 @@
1
- "use strict";
2
1
 
3
- const {Syntax} = require("../utils/parseUtils");
4
- const SapUiDefine = require("../calls/SapUiDefine");
5
- const {getValue, isMethodCall, isString} = require("../utils/ASTUtils");
6
- const ModuleName = require("../utils/ModuleName");
7
- const log = require("@ui5/logger").getLogger("lbt:analyzer:XMLCompositeAnalyzer");
2
+ import {Syntax} from "../utils/parseUtils.js";
3
+ import SapUiDefine from "../calls/SapUiDefine.js";
4
+ import {getValue, isMethodCall, getStringValue} from "../utils/ASTUtils.js";
5
+ import {fromUI5LegacyName} from "../utils/ModuleName.js";
6
+ import logger from "@ui5/logger";
7
+ const log = logger.getLogger("lbt:analyzer:XMLCompositeAnalyzer");
8
8
 
9
9
  const CALL_DEFINE = ["define"];
10
10
  const CALL_SAP_UI_DEFINE = ["sap", "ui", "define"];
@@ -19,18 +19,30 @@ class XMLCompositeAnalyzer {
19
19
  const XMLC = defineCall.findImportName("sap/ui/core/XMLComposite.js");
20
20
  // console.log("local name for XMLComposite: %s", XMLC);
21
21
  if ( XMLC && defineCall.factory ) {
22
- defineCall.factory.body.body.forEach( (stmt) => {
23
- if ( stmt.type === Syntax.VariableDeclaration ) {
24
- stmt.declarations.forEach( (decl) => {
25
- fragmentName = this._checkForXMLCClassDefinition( XMLC, decl.init ) || fragmentName;
26
- });
27
- } else if ( stmt.type === Syntax.ExpressionStatement &&
28
- stmt.expression.type === Syntax.AssignmentExpression ) {
29
- fragmentName = this._checkForXMLCClassDefinition( XMLC, stmt.expression.right ) || fragmentName;
30
- }
31
- });
32
- if ( fragmentName ) {
33
- const fragmentModule = ModuleName.fromUI5LegacyName( fragmentName, ".control.xml" );
22
+ if (defineCall.factory.type === Syntax.ArrowFunctionExpression &&
23
+ defineCall.factory.expression === true) {
24
+ fragmentName = this._checkForXMLCClassDefinition(XMLC, defineCall.factory.body);
25
+ } else {
26
+ defineCall.factory.body.body.forEach((stmt) => {
27
+ if (stmt.type === Syntax.VariableDeclaration) {
28
+ stmt.declarations.forEach((decl) => {
29
+ fragmentName = this._checkForXMLCClassDefinition(XMLC, decl.init) || fragmentName;
30
+ });
31
+ } else if (
32
+ stmt.type === Syntax.ReturnStatement &&
33
+ ( stmt?.argument?.type === Syntax.CallExpression && stmt.argument.arguments?.length > 1 &&
34
+ stmt.argument.arguments[1].type === Syntax.ObjectExpression)) {
35
+ fragmentName =
36
+ this._checkForXMLCClassDefinition(XMLC, stmt.argument) || fragmentName;
37
+ } else if (stmt.type === Syntax.ExpressionStatement &&
38
+ stmt.expression.type === Syntax.AssignmentExpression) {
39
+ fragmentName =
40
+ this._checkForXMLCClassDefinition(XMLC, stmt.expression.right) || fragmentName;
41
+ }
42
+ });
43
+ }
44
+ if (fragmentName) {
45
+ const fragmentModule = fromUI5LegacyName(fragmentName, ".control.xml");
34
46
  log.verbose("fragment control: add dependency to template fragment %s", fragmentModule);
35
47
  info.addDependency(fragmentModule);
36
48
  }
@@ -42,8 +54,9 @@ class XMLCompositeAnalyzer {
42
54
  let fragmentName;
43
55
  if ( isMethodCall(stmt, [XMLC, "extend"]) ) {
44
56
  // log.verbose(stmt);
45
- if ( stmt.arguments.length > 0 && isString(stmt.arguments[0]) ) {
46
- fragmentName = stmt.arguments[0].value;
57
+ const value = getStringValue(stmt.arguments[0]);
58
+ if ( stmt.arguments.length > 0 && value ) {
59
+ fragmentName = value;
47
60
  }
48
61
  if ( stmt.arguments.length > 1 && stmt.arguments[1].type === Syntax.ObjectExpression ) {
49
62
  fragmentName = this._analyzeXMLCClassDefinition(stmt.arguments[1]) || fragmentName;
@@ -54,12 +67,9 @@ class XMLCompositeAnalyzer {
54
67
 
55
68
  _analyzeXMLCClassDefinition(clazz) {
56
69
  // log.verbose(clazz);
57
- const fragmentName = getValue(clazz, ["fragment"]);
58
- if ( isString(fragmentName) ) {
59
- return fragmentName.value;
60
- }
70
+ return getStringValue(getValue(clazz, ["fragment"]));
61
71
  }
62
72
  }
63
73
 
64
74
 
65
- module.exports = XMLCompositeAnalyzer;
75
+ export default XMLCompositeAnalyzer;
@@ -1,4 +1,11 @@
1
- "use strict";
1
+
2
+ import xml2js from "xml2js";
3
+ import {fromUI5LegacyName, fromRequireJSName} from "../utils/ModuleName.js";
4
+ import JSTokenizer from "../utils/JSTokenizer.js";
5
+ import logger from "@ui5/logger";
6
+ const log = logger.getLogger("lbt:analyzer:XMLTemplateAnalyzer");
7
+
8
+ // ---------------------------------------------------------------------------------------------------------
2
9
 
3
10
  /*
4
11
  * TODOS
@@ -10,11 +17,6 @@
10
17
  * - move UI5 specific constants to UI5ClientConstants?
11
18
  */
12
19
 
13
- const xml2js = require("xml2js");
14
- const ModuleName = require("../utils/ModuleName");
15
- const JSTokenizer = require("../utils/JSTokenizer");
16
- const log = require("@ui5/logger").getLogger("lbt:analyzer:XMLTemplateAnalyzer");
17
-
18
20
  // ---------------------------------------------------------------------------------------------------------
19
21
 
20
22
  const XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
@@ -22,7 +24,7 @@ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
22
24
  const TEMPLATING_NAMESPACE = "http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1";
23
25
  const TEMPLATING_CONDITONAL_TAGS = /^(?:if|repeat)$/;
24
26
 
25
- const PATTERN_LIBRARY_NAMESPACES = /^([a-zA-Z_$][a-zA-z0-9_$]*(\.[a-zA-Z_$][a-zA-z0-9_$]*)*)$/;
27
+ const PATTERN_LIBRARY_NAMESPACES = /^([a-zA-Z_$][a-zA-Z0-9_$]*(\.[a-zA-Z_$][a-zA-Z0-9_$]*)*)$/;
26
28
 
27
29
  // component container
28
30
  const COMPONENTCONTAINER_MODULE = "sap/ui/core/ComponentContainer.js";
@@ -37,10 +39,12 @@ const FRAGMENT_FRAGMENTNAME_ATTRIBUTE = "fragmentName";
37
39
  const FRAGMENT_TYPE_ATTRIBUTE = "type";
38
40
 
39
41
  // different view types
42
+ const VIEW_MODULE = "sap/ui/core/mvc/View.js";
40
43
  const HTMLVIEW_MODULE = "sap/ui/core/mvc/HTMLView.js";
41
44
  const JSVIEW_MODULE = "sap/ui/core/mvc/JSView.js";
42
45
  const JSONVIEW_MODULE = "sap/ui/core/mvc/JSONView.js";
43
46
  const XMLVIEW_MODULE = "sap/ui/core/mvc/XMLView.js";
47
+ const TEMPLATEVIEW_MODULE = "sap/ui/core/mvc/TemplateView.js";
44
48
  const ANYVIEW_VIEWNAME_ATTRIBUTE = "viewName";
45
49
  const XMLVIEW_CONTROLLERNAME_ATTRIBUTE = "controllerName";
46
50
  const XMLVIEW_RESBUNDLENAME_ATTRIBUTE = "resourceBundleName";
@@ -48,6 +52,7 @@ const XMLVIEW_CORE_REQUIRE_ATTRIBUTE_NS = {
48
52
  uri: "sap.ui.core",
49
53
  local: "require"
50
54
  };
55
+ const VIEW_TYPE_ATTRIBUTE = "type";
51
56
 
52
57
  /*
53
58
  * Helper to simplify access to node attributes.
@@ -195,12 +200,12 @@ class XMLTemplateAnalyzer {
195
200
 
196
201
  const controllerName = getAttribute(node, XMLVIEW_CONTROLLERNAME_ATTRIBUTE);
197
202
  if ( controllerName ) {
198
- this._addDependency( ModuleName.fromUI5LegacyName(controllerName, ".controller.js"), this.conditional );
203
+ this._addDependency( fromUI5LegacyName(controllerName, ".controller.js"), this.conditional );
199
204
  }
200
205
 
201
206
  const resourceBundleName = getAttribute(node, XMLVIEW_RESBUNDLENAME_ATTRIBUTE);
202
207
  if ( resourceBundleName ) {
203
- const resourceBundleModuleName = ModuleName.fromUI5LegacyName(resourceBundleName, ".properties");
208
+ const resourceBundleModuleName = fromUI5LegacyName(resourceBundleName, ".properties");
204
209
  log.verbose("found dependency to resource bundle %s", resourceBundleModuleName);
205
210
  // TODO locale dependent dependencies: this._addDependency(resourceBundleModuleName);
206
211
  this._addDependency( resourceBundleModuleName, this.conditional );
@@ -229,7 +234,7 @@ class XMLTemplateAnalyzer {
229
234
 
230
235
  } else if ( PATTERN_LIBRARY_NAMESPACES.test(namespace) ) {
231
236
  // looks like a UI5 library or package name
232
- const moduleName = ModuleName.fromUI5LegacyName( (namespace ? namespace + "." : "") + localName );
237
+ const moduleName = fromUI5LegacyName( (namespace ? namespace + "." : "") + localName );
233
238
 
234
239
  this._analyzeCoreRequire(node);
235
240
 
@@ -283,7 +288,7 @@ class XMLTemplateAnalyzer {
283
288
  Object.keys(requireContext).forEach((key) => {
284
289
  const requireJsName = requireContext[key];
285
290
  if ( requireJsName && typeof requireJsName === "string" ) {
286
- this._addDependency(ModuleName.fromRequireJSName(requireJsName), this.conditional);
291
+ this._addDependency(fromRequireJSName(requireJsName), this.conditional);
287
292
  } else {
288
293
  log.error(`Ignoring core:require: '${key}' refers to invalid module name '${requireJsName}'`);
289
294
  }
@@ -307,7 +312,7 @@ class XMLTemplateAnalyzer {
307
312
  const componentName = getAttribute(node, COMPONENTCONTAINER_COMPONENTNAME_ATTRIBUTE);
308
313
  if ( componentName ) {
309
314
  const componentModuleName =
310
- ModuleName.fromUI5LegacyName( componentName, "/Component.js" );
315
+ fromUI5LegacyName( componentName, "/Component.js" );
311
316
  this._addDependency(componentModuleName, conditional);
312
317
  }
313
318
  // TODO what about component.json? handle it transitively via Component.js?
@@ -316,38 +321,86 @@ class XMLTemplateAnalyzer {
316
321
  const type = getAttribute(node, FRAGMENT_TYPE_ATTRIBUTE);
317
322
  if ( fragmentName && type ) {
318
323
  const fragmentModuleName =
319
- ModuleName.fromUI5LegacyName( fragmentName, this._getFragmentExtension(type) );
324
+ fromUI5LegacyName( fragmentName, this._getFragmentExtension(type) );
320
325
  // console.log("child fragment detected %s", fragmentModuleName);
321
326
  this._addDependency(fragmentModuleName, conditional);
322
327
  }
323
328
  } else if ( moduleName === HTMLVIEW_MODULE ) {
324
329
  const viewName = getAttribute(node, ANYVIEW_VIEWNAME_ATTRIBUTE);
325
330
  if ( viewName ) {
326
- const childViewModuleName = ModuleName.fromUI5LegacyName( viewName, ".view.html" );
331
+ const childViewModuleName = fromUI5LegacyName( viewName, ".view.html" );
327
332
  // console.log("child view detected %s", childViewModuleName);
328
333
  this._addDependency(childViewModuleName, conditional);
329
334
  }
330
335
  } else if ( moduleName === JSVIEW_MODULE ) {
331
336
  const viewName = getAttribute(node, ANYVIEW_VIEWNAME_ATTRIBUTE);
332
337
  if ( viewName ) {
333
- const childViewModuleName = ModuleName.fromUI5LegacyName( viewName, ".view.js" );
338
+ const childViewModuleName = fromUI5LegacyName( viewName, ".view.js" );
334
339
  // console.log("child view detected %s", childViewModuleName);
335
340
  this._addDependency(childViewModuleName, conditional);
336
341
  }
337
342
  } else if ( moduleName === JSONVIEW_MODULE ) {
338
343
  const viewName = getAttribute(node, ANYVIEW_VIEWNAME_ATTRIBUTE);
339
344
  if ( viewName ) {
340
- const childViewModuleName = ModuleName.fromUI5LegacyName( viewName, ".view.json" );
345
+ const childViewModuleName = fromUI5LegacyName( viewName, ".view.json" );
341
346
  // console.log("child view detected %s", childViewModuleName);
342
347
  this._addDependency(childViewModuleName, conditional);
343
348
  }
344
349
  } else if ( moduleName === XMLVIEW_MODULE ) {
345
350
  const viewName = getAttribute(node, ANYVIEW_VIEWNAME_ATTRIBUTE);
346
351
  if ( viewName ) {
347
- const childViewModuleName = ModuleName.fromUI5LegacyName( viewName, ".view.xml" );
352
+ const childViewModuleName = fromUI5LegacyName( viewName, ".view.xml" );
353
+ // console.log("child view detected %s", childViewModuleName);
354
+ this._addDependency(childViewModuleName, conditional);
355
+ }
356
+ } else if ( moduleName === TEMPLATEVIEW_MODULE ) {
357
+ const viewName = getAttribute(node, ANYVIEW_VIEWNAME_ATTRIBUTE);
358
+ if ( viewName ) {
359
+ const childViewModuleName = fromUI5LegacyName( viewName, ".view.tmpl" );
348
360
  // console.log("child view detected %s", childViewModuleName);
349
361
  this._addDependency(childViewModuleName, conditional);
350
362
  }
363
+ } else if ( moduleName === VIEW_MODULE ) {
364
+ const viewName = getAttribute(node, ANYVIEW_VIEWNAME_ATTRIBUTE);
365
+ if ( viewName ) {
366
+ let childViewModuleName;
367
+
368
+ if (viewName.startsWith("module:")) {
369
+ childViewModuleName = viewName.slice("module:".length) + ".js";
370
+ } else {
371
+ const viewType = getAttribute(node, VIEW_TYPE_ATTRIBUTE);
372
+
373
+ let viewTypeExtension;
374
+
375
+ switch (viewType) {
376
+ case "JS":
377
+ viewTypeExtension = ".view.js";
378
+ break;
379
+ case "JSON":
380
+ viewTypeExtension = ".view.json";
381
+ break;
382
+ case "Template":
383
+ viewTypeExtension = ".view.tmpl";
384
+ break;
385
+ case "XML":
386
+ viewTypeExtension = ".view.xml";
387
+ break;
388
+ case "HTML":
389
+ viewTypeExtension = ".view.html";
390
+ break;
391
+ default:
392
+ log.warn(`Unable to analyze sap.ui5/rootView: Unknown type '${viewType}'`);
393
+ }
394
+
395
+ if (viewTypeExtension) {
396
+ childViewModuleName = fromUI5LegacyName(viewName, viewTypeExtension);
397
+ }
398
+ }
399
+ if (childViewModuleName) {
400
+ // console.log("child view detected %s", childViewModuleName);
401
+ this._addDependency(childViewModuleName, conditional);
402
+ }
403
+ }
351
404
  }
352
405
  } catch (err) {
353
406
  // ignore missing resources
@@ -361,4 +414,4 @@ class XMLTemplateAnalyzer {
361
414
  }
362
415
 
363
416
 
364
- module.exports = XMLTemplateAnalyzer;
417
+ export default XMLTemplateAnalyzer;
@@ -1,6 +1,8 @@
1
- "use strict";
2
- const {parseJS, Syntax, VisitorKeys} = require("../utils/parseUtils");
3
- const {getPropertyKey, isMethodCall, isIdentifier, getStringArray} = require("../utils/ASTUtils");
1
+
2
+ import {parseJS, Syntax, VisitorKeys} from "../utils/parseUtils.js";
3
+ import {getPropertyKey, isMethodCall, isIdentifier, getStringArray} from "../utils/ASTUtils.js";
4
+ import logger from "@ui5/logger";
5
+ const log = logger.getLogger("lbt:analyzer:LibraryJS");
4
6
 
5
7
  const CALL__SAP_UI_GETCORE = ["sap", "ui", "getCore"];
6
8
 
@@ -25,8 +27,14 @@ async function analyze(resource) {
25
27
  node.arguments.length === 1 &&
26
28
  node.arguments[0].type === Syntax.ObjectExpression ) {
27
29
  node.arguments[0].properties.forEach( (prop) => {
30
+ if (prop.type === Syntax.SpreadElement) {
31
+ // SpreadElements are currently not supported
32
+ return;
33
+ }
34
+
28
35
  const key = getPropertyKey(prop);
29
36
  const value = prop.value;
37
+
30
38
  if ( key === "noLibraryCSS" &&
31
39
  (value.type === Syntax.Literal && typeof value.value === "boolean") ) {
32
40
  libInfo.noLibraryCSS = value.value;
@@ -38,6 +46,14 @@ async function analyze(resource) {
38
46
  libInfo.controls = getStringArray(value, true);
39
47
  } else if ( key === "elements" && value.type == Syntax.ArrayExpression ) {
40
48
  libInfo.elements = getStringArray(value, true);
49
+ } else if ( ["designtime", "dependencies", "extensions", "name", "version"].includes(key) ) {
50
+ // do nothing, for all other supported properties
51
+ } else {
52
+ log.error(
53
+ "Unexpected property '" + key +
54
+ "' or wrong type for '" + key +
55
+ "' in sap.ui.getCore().initLibrary call in '" + resource.getPath() + "'"
56
+ );
41
57
  }
42
58
  });
43
59
 
@@ -81,12 +97,12 @@ async function analyze(resource) {
81
97
  *
82
98
  * Note: only the first initLibrary() call that is found with a DFS on the AST, will be evaluated.
83
99
  *
84
- * @param {module:@ui5/fs.Resource} resource library.js resource whose content should be analyzed
100
+ * @param {@ui5/fs/Resource} resource library.js resource whose content should be analyzed
85
101
  * @returns {Promise<object>} A Promise on the extract info object
86
102
  */
87
- module.exports = function(resource) {
103
+ export default function(resource) {
88
104
  if ( resource == null ) {
89
105
  return Promise.resolve({});
90
106
  }
91
107
  return analyze(resource);
92
- };
108
+ }
@@ -1,11 +1,10 @@
1
- "use strict";
2
1
 
3
- const {pd} = require("pretty-data");
4
-
5
- const ModuleName = require("../utils/ModuleName");
6
- const {SectionType} = require("./BundleDefinition");
7
- const escapePropertiesFile = require("../utils/escapePropertiesFile");
8
- const log = require("@ui5/logger").getLogger("lbt:bundle:AutoSplitter");
2
+ import {pd} from "pretty-data";
3
+ import {toRequireJSName} from "../utils/ModuleName.js";
4
+ import {SectionType} from "./BundleDefinition.js";
5
+ import escapePropertiesFile from "../utils/escapePropertiesFile.js";
6
+ import logger from "@ui5/logger";
7
+ const log = logger.getLogger("lbt:bundle:AutoSplitter");
9
8
 
10
9
  const xmlHtmlPrePattern = /<(?:\w+:)?pre\b/;
11
10
 
@@ -72,7 +71,7 @@ class AutoSplitter {
72
71
  break;
73
72
  case SectionType.Require:
74
73
  section.modules.forEach( (module) => {
75
- totalSize += "sap.ui.requireSync('');".length + ModuleName.toRequireJSName(module).length;
74
+ totalSize += "sap.ui.requireSync('');".length + toRequireJSName(module).length;
76
75
  });
77
76
  break;
78
77
  default:
@@ -90,7 +89,7 @@ class AutoSplitter {
90
89
  const splittedModules = [];
91
90
  let moduleNameWithPart = moduleDef.name;
92
91
  if ( !/__part__/.test(moduleNameWithPart) ) {
93
- moduleNameWithPart = ModuleName.toRequireJSName(moduleNameWithPart) + "-__part__.js";
92
+ moduleNameWithPart = toRequireJSName(moduleNameWithPart) + "-__part__.js";
94
93
  }
95
94
  // vars = Object.create(null);
96
95
 
@@ -177,7 +176,7 @@ class AutoSplitter {
177
176
  currentModule.sections.push( currentSection );
178
177
  section.modules.forEach( (module) => {
179
178
  currentSection.filters.push( module );
180
- totalSize += 21 + ModuleName.toRequireJSName(module).length;
179
+ totalSize += 21 + toRequireJSName(module).length;
181
180
  });
182
181
  break;
183
182
  default:
@@ -257,4 +256,4 @@ class AutoSplitter {
257
256
  } */
258
257
  }
259
258
 
260
- module.exports = AutoSplitter;
259
+ export default AutoSplitter;
@@ -1,22 +1,22 @@
1
1
  /* eslint quotes: ["error", "double", { "allowTemplateLiterals": true }] */
2
2
  // for consistency of write calls, we generally allow template literals
3
- "use strict";
4
3
 
5
- const path = require("path");
6
- const {pd} = require("pretty-data");
7
- const {parseJS, Syntax} = require("../utils/parseUtils");
8
- const {encode: encodeMappings, decode: decodeMappings} = require("@jridgewell/sourcemap-codec");
9
-
10
- const {isMethodCall} = require("../utils/ASTUtils");
11
- const ModuleName = require("../utils/ModuleName");
12
- const UI5ClientConstants = require("../UI5ClientConstants");
13
- const escapePropertiesFile = require("../utils/escapePropertiesFile");
14
-
15
- const BundleResolver = require("./Resolver");
16
- const BundleSplitter = require("./AutoSplitter");
17
- const {SectionType} = require("./BundleDefinition");
18
- const BundleWriter = require("./BundleWriter");
19
- const log = require("@ui5/logger").getLogger("lbt:bundle:Builder");
4
+ import path from "node:path";
5
+ import {pd} from "pretty-data";
6
+ import {parseJS, Syntax} from "../utils/parseUtils.js";
7
+ import {encode as encodeMappings, decode as decodeMappings} from "@jridgewell/sourcemap-codec";
8
+ import {isMethodCall} from "../utils/ASTUtils.js";
9
+ import {toUI5LegacyName, toRequireJSName} from "../utils/ModuleName.js";
10
+ import {
11
+ MODULE__UI5LOADER, MODULE__UI5LOADER_AUTOCONFIG,
12
+ MODULE__JQUERY_SAP_GLOBAL, MODULE__SAP_UI_CORE_CORE} from "../UI5ClientConstants.js";
13
+ import escapePropertiesFile from "../utils/escapePropertiesFile.js";
14
+ import BundleResolver from "./Resolver.js";
15
+ import BundleSplitter from "./AutoSplitter.js";
16
+ import {SectionType} from "./BundleDefinition.js";
17
+ import BundleWriter from "./BundleWriter.js";
18
+ import logger from "@ui5/logger";
19
+ const log = logger.getLogger("lbt:bundle:Builder");
20
20
 
21
21
  const sourceMappingUrlPattern = /\/\/# sourceMappingURL=(.+)\s*$/;
22
22
  const httpPattern = /^https?:\/\//i;
@@ -63,14 +63,14 @@ const EVOBundleFormat = {
63
63
  },
64
64
 
65
65
  requireSync(moduleName) {
66
- return `sap.ui.requireSync("${ModuleName.toRequireJSName(moduleName)}");\n`;
66
+ return `sap.ui.requireSync("${toRequireJSName(moduleName)}");\n`;
67
67
  },
68
68
 
69
69
  shouldDecorate(resolvedModule) {
70
- return resolvedModule.executes(UI5ClientConstants.MODULE__UI5LOADER) ||
71
- resolvedModule.executes(UI5ClientConstants.MODULE__UI5LOADER_AUTOCONFIG) ||
72
- resolvedModule.executes(UI5ClientConstants.MODULE__JQUERY_SAP_GLOBAL) ||
73
- resolvedModule.executes(UI5ClientConstants.MODULE__SAP_UI_CORE_CORE);
70
+ return resolvedModule.executes(MODULE__UI5LOADER) ||
71
+ resolvedModule.executes(MODULE__UI5LOADER_AUTOCONFIG) ||
72
+ resolvedModule.executes(MODULE__JQUERY_SAP_GLOBAL) ||
73
+ resolvedModule.executes(MODULE__SAP_UI_CORE_CORE);
74
74
  }
75
75
  };
76
76
 
@@ -232,11 +232,11 @@ class BundleBuilder {
232
232
  /* NODE-TODO, moduleName is not defined
233
233
  It should contain the name of the module which is currently build (1st parameter of _createBundle).
234
234
  But when the ui5loader is present, declareRawModules should be forced to false anyhow.
235
- this.outW.writeln("jQuery.sap.declare('", ModuleName.toUI5LegacyName(moduleName), "');");
235
+ this.outW.writeln("jQuery.sap.declare('", toUI5LegacyName(moduleName), "');");
236
236
  */
237
237
  this.missingRawDeclarations.forEach( (module) => {
238
238
  // 2nd parameter set to 'false': do not create namespaces - they nevertheless would come too late
239
- this.outW.writeln(`jQuery.sap.declare('${ModuleName.toUI5LegacyName(module)}', false);`);
239
+ this.outW.writeln(`jQuery.sap.declare('${toUI5LegacyName(module)}', false);`);
240
240
  });
241
241
  this.missingRawDeclarations = [];
242
242
  }
@@ -258,7 +258,7 @@ class BundleBuilder {
258
258
  if ( section.declareRawModules ) {
259
259
  this.missingRawDeclarations.push(moduleName);
260
260
  }
261
- if ( moduleName === UI5ClientConstants.MODULE__JQUERY_SAP_GLOBAL ) {
261
+ if ( moduleName === MODULE__JQUERY_SAP_GLOBAL ) {
262
262
  this.jqglobalAvailable = true;
263
263
  }
264
264
  } else {
@@ -413,7 +413,7 @@ class BundleBuilder {
413
413
  *
414
414
  * @param {string} moduleName module name
415
415
  * @param {ModuleInfo} info
416
- * @param {module:@ui5/fs.Resource} resource
416
+ * @param {@ui5/fs/Resource} resource
417
417
  * @returns {Promise<boolean>}
418
418
  */
419
419
  async writePreloadModule(moduleName, info, resource) {
@@ -539,7 +539,7 @@ class BundleBuilder {
539
539
  const sourceMapUrlMatch = moduleContent.match(sourceMappingUrlPattern);
540
540
  if (sourceMapUrlMatch) {
541
541
  const sourceMapUrl = sourceMapUrlMatch[1];
542
- log.verbose(`Found source map reference in content of module ${moduleName}: ${sourceMapUrl}`);
542
+ log.silly(`Found source map reference in content of module ${moduleName}: ${sourceMapUrl}`);
543
543
 
544
544
  // Strip sourceMappingURL from module code to be bundled
545
545
  // It has no effect and might be cause for confusion
@@ -578,7 +578,7 @@ class BundleBuilder {
578
578
  }
579
579
  } else {
580
580
  const sourceMapFileCandidate = resourcePath.slice("/resources/".length) + ".map";
581
- log.verbose(`Could not find a sourceMappingURL reference in content of module ${moduleName}. ` +
581
+ log.silly(`Could not find a sourceMappingURL reference in content of module ${moduleName}. ` +
582
582
  `Attempting to find a source map resource based on the module's path: ${sourceMapFileCandidate}`);
583
583
  try {
584
584
  const sourceMapResource = await this.pool.findResource(sourceMapFileCandidate);
@@ -587,7 +587,7 @@ class BundleBuilder {
587
587
  }
588
588
  } catch (e) {
589
589
  // No input source map
590
- log.verbose(`Could not find a source map for module ${moduleName}: ${e.message}`);
590
+ log.silly(`Could not find a source map for module ${moduleName}: ${e.message}`);
591
591
  }
592
592
  }
593
593
 
@@ -648,8 +648,8 @@ async function rewriteDefine({moduleName, moduleContent, moduleSourceMap}) {
648
648
 
649
649
  // Inject module name if missing
650
650
  if ( defineCall.arguments.length == 0 ||
651
- defineCall.arguments[0].type !== Syntax.Literal ) {
652
- let value = `"${ModuleName.toRequireJSName(moduleName)}"`;
651
+ ![Syntax.Literal, Syntax.TemplateLiteral].includes(defineCall.arguments[0].type)) {
652
+ let value = `"${toRequireJSName(moduleName)}"`;
653
653
  let index;
654
654
 
655
655
  if (defineCall.arguments.length == 0) {
@@ -773,10 +773,7 @@ function createTransientSourceMap({moduleName, moduleContent, includeContent = f
773
773
  return sourceMap;
774
774
  }
775
775
 
776
- module.exports = BundleBuilder;
776
+ export default BundleBuilder;
777
777
 
778
- // Export local functions for testing only
779
- /* istanbul ignore else */
780
- if (process.env.NODE_ENV === "test") {
781
- module.exports.__localFunctions__ = {rewriteDefine, createTransientSourceMap};
782
- }
778
+ export const __localFunctions__ = (process.env.NODE_ENV === "test") ?
779
+ {rewriteDefine, createTransientSourceMap} : undefined;
@@ -1,6 +1,4 @@
1
- "use strict";
2
-
3
- const SectionType = {
1
+ export const SectionType = {
4
2
  /**
5
3
  * The modules are assumed to exist already in the loading environment.
6
4
  */
@@ -31,5 +29,3 @@ const SectionType = {
31
29
  */
32
30
  Require: "require"
33
31
  };
34
-
35
- module.exports.SectionType = SectionType;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
 
3
2
 
4
3
  const NL = "\n";
@@ -101,4 +100,4 @@ class BundleWriter {
101
100
  }
102
101
  }
103
102
 
104
- module.exports = BundleWriter;
103
+ export default BundleWriter;