@ui5/builder 3.0.0-alpha.8 → 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 (84) hide show
  1. package/.reuse/dep5 +2 -2
  2. package/CHANGELOG.md +50 -2
  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 +14 -7
  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 -177
  84. package/lib/tasks/TaskUtil.js +0 -237
package/.reuse/dep5 CHANGED
@@ -25,9 +25,9 @@ Disclaimer: The code in this project may include calls to APIs (“API Calls”)
25
25
  parties the right to use of access any SAP External Product, through API Calls.
26
26
 
27
27
  Files: *
28
- Copyright: 2018-2020 SAP SE or an SAP affiliate company and UI5 Tooling contributors
28
+ Copyright: 2018-2022 SAP SE or an SAP affiliate company and UI5 Tooling contributors
29
29
  License: Apache-2.0
30
30
 
31
31
  Files: lib/processors/jsdoc/lib/*
32
- Copyright: 2009-2020 SAP SE or an SAP affiliate company and OpenUI5 contributors
32
+ Copyright: 2009-2022 SAP SE or an SAP affiliate company and OpenUI5 contributors
33
33
  License: Apache-2.0
package/CHANGELOG.md CHANGED
@@ -2,10 +2,53 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
4
4
 
5
- A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.8...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v3.0.0-beta.1...HEAD).
6
+
7
+ <a name="v3.0.0-beta.1"></a>
8
+ ## [v3.0.0-beta.1] - 2022-11-07
9
+
10
+ <a name="v3.0.0-alpha.12"></a>
11
+ ## [v3.0.0-alpha.12] - 2022-10-24
12
+ ### Breaking Changes
13
+ - Transform to native ESM ([#790](https://github.com/SAP/ui5-builder/issues/790)) [`a439aa9`](https://github.com/SAP/ui5-builder/commit/a439aa9f679dfe2e18b8c540f54876f94c0de119)
14
+
15
+ ### BREAKING CHANGE
16
+
17
+ This package has been transformed to native ESM. Therefore it no longer provides a CommonJS export.
18
+ If your project uses CommonJS, it needs to be converted to ESM or use a dynamic import.
19
+
20
+ For more information see also:
21
+ - https://sap.github.io/ui5-tooling/updates/migrate-v3/
22
+ - https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
23
+
24
+
25
+ <a name="v3.0.0-alpha.11"></a>
26
+ ## [v3.0.0-alpha.11] - 2022-10-20
27
+ ### Bug Fixes
28
+ - **package.json:** Downgrade es5-ext dependency [`2b71707`](https://github.com/SAP/ui5-builder/commit/2b71707683480b26aab9957c09e5d22bce8a6450)
29
+
30
+ ### Dependency Updates
31
+ - Bump escope from 3.6.0 to 4.0.0 [`e25af0d`](https://github.com/SAP/ui5-builder/commit/e25af0d9c1184916aa037b4b4ca23d15c5f2a408)
32
+
33
+ ### Features
34
+ - **builder:** Improve support for ES6+ syntax ([#774](https://github.com/SAP/ui5-builder/issues/774)) [`90385fe`](https://github.com/SAP/ui5-builder/commit/90385feb7cea1e5b864cff035b01263a492972a9)
35
+ - **jsdoc:** Improve support for ES6+ syntax ([#785](https://github.com/SAP/ui5-builder/issues/785)) [`187a6a3`](https://github.com/SAP/ui5-builder/commit/187a6a35000145d70bf41e0d8b724e5ea8d8dc78)
36
+
37
+ ### Reverts
38
+ - [FIX] package.json: Downgrade es5-ext dependency
39
+
40
+
41
+ <a name="v3.0.0-alpha.10"></a>
42
+ ## [v3.0.0-alpha.10] - 2022-08-09
43
+
44
+ <a name="v3.0.0-alpha.9"></a>
45
+ ## [v3.0.0-alpha.9] - 2022-07-27
46
+ ### Bug Fixes
47
+ - **minify:** Change default to not omit source map resources [`6d75a49`](https://github.com/SAP/ui5-builder/commit/6d75a495224590097332fc061c66cfe0e8f4c151)
48
+
6
49
 
7
50
  <a name="v3.0.0-alpha.8"></a>
8
- ## [v3.0.0-alpha.8] - 2022-07-14
51
+ ## [v3.0.0-alpha.8] - 2022-07-15
9
52
 
10
53
  <a name="v3.0.0-alpha.7"></a>
11
54
  ## [v3.0.0-alpha.7] - 2022-06-14
@@ -744,6 +787,11 @@ to load the custom bundle file instead.
744
787
  - Add ability to configure component preloads and custom bundles [`2241e5f`](https://github.com/SAP/ui5-builder/commit/2241e5ff98fd95f1f80cc74959655ae7a9c660e7)
745
788
 
746
789
 
790
+ [v3.0.0-beta.1]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.12...v3.0.0-beta.1
791
+ [v3.0.0-alpha.12]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.11...v3.0.0-alpha.12
792
+ [v3.0.0-alpha.11]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.10...v3.0.0-alpha.11
793
+ [v3.0.0-alpha.10]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.9...v3.0.0-alpha.10
794
+ [v3.0.0-alpha.9]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.8...v3.0.0-alpha.9
747
795
  [v3.0.0-alpha.8]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.7...v3.0.0-alpha.8
748
796
  [v3.0.0-alpha.7]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.6...v3.0.0-alpha.7
749
797
  [v3.0.0-alpha.6]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.5...v3.0.0-alpha.6
package/CONTRIBUTING.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # Contributing to the UI5 Tooling
2
2
 
3
- See CONTRIBUTING.md in the [SAP/ui5-tooling](https://github.com/SAP/ui5-tooling/blob/master/CONTRIBUTING.md) repository.
3
+ See CONTRIBUTING.md in the [SAP/ui5-tooling](https://github.com/SAP/ui5-tooling/blob/main/CONTRIBUTING.md) repository.
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-tooling/master/docs/images/UI5_logo_wide.png)
1
+ ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-tooling/main/docs/images/UI5_logo_wide.png)
2
2
 
3
3
  # ui5-builder
4
4
  > Modules for building UI5 projects
5
5
  > Part of the [UI5 Tooling](https://github.com/SAP/ui5-tooling)
6
6
 
7
7
  [![REUSE status](https://api.reuse.software/badge/github.com/SAP/ui5-builder)](https://api.reuse.software/info/github.com/SAP/ui5-builder)
8
- [![Build Status](https://dev.azure.com/sap/opensource/_apis/build/status/SAP.ui5-builder?branchName=master)](https://dev.azure.com/sap/opensource/_build/latest?definitionId=26&branchName=master)
8
+ [![Build Status](https://dev.azure.com/sap/opensource/_apis/build/status/SAP.ui5-builder?branchName=main)](https://dev.azure.com/sap/opensource/_build/latest?definitionId=26&branchName=main)
9
9
  [![npm Package Version](https://badge.fury.io/js/%40ui5%2Fbuilder.svg)](https://www.npmjs.com/package/@ui5/builder)
10
10
  [![Coverage Status](https://coveralls.io/repos/github/SAP/ui5-builder/badge.svg)](https://coveralls.io/github/SAP/ui5-builder)
11
11
 
@@ -13,10 +13,10 @@
13
13
  Can be found here: [sap.github.io/ui5-tooling](https://sap.github.io/ui5-tooling/pages/Builder/)
14
14
 
15
15
  ## Contributing
16
- Please check our [Contribution Guidelines](https://github.com/SAP/ui5-tooling/blob/master/CONTRIBUTING.md).
16
+ Please check our [Contribution Guidelines](https://github.com/SAP/ui5-tooling/blob/main/CONTRIBUTING.md).
17
17
 
18
18
  ## Support
19
- Please follow our [Contribution Guidelines](https://github.com/SAP/ui5-tooling/blob/master/CONTRIBUTING.md#report-an-issue) on how to report an issue.
19
+ Please follow our [Contribution Guidelines](https://github.com/SAP/ui5-tooling/blob/main/CONTRIBUTING.md#report-an-issue) on how to report an issue.
20
20
 
21
21
  Please report issues in the main [UI5 Tooling](https://github.com/SAP/ui5-tooling) repository.
22
22
 
package/jsdoc.json CHANGED
@@ -3,13 +3,13 @@
3
3
  "allowUnknownTags": false
4
4
  },
5
5
  "source": {
6
- "include": ["README.md", "index.js"],
6
+ "include": ["README.md"],
7
7
  "exclude": ["lib/lbt/utils/JSTokenizer.js"],
8
8
  "includePattern": ".+\\.js$",
9
9
  "excludePattern": "(node_modules(\\\\|/))"
10
10
  },
11
11
  "plugins": [
12
- "./jsdoc-plugin"
12
+ "./jsdoc-plugin.cjs"
13
13
  ],
14
14
  "opts": {
15
15
  "encoding": "utf8",
@@ -1,13 +1,12 @@
1
- "use strict";
2
1
 
3
- module.exports.MODULE__UI5LOADER = "ui5loader.js";
4
- module.exports.MODULE__UI5LOADER_AUTOCONFIG = "ui5loader-autoconfig.js";
5
- module.exports.MODULE__JQUERY_SAP_GLOBAL = "jquery.sap.global.js";
6
- module.exports.MODULE__SAP_UI_CORE_CORE = "sap/ui/core/Core.js";
7
- module.exports.EVO_MARKER_RESOURCE = module.exports.MODULE__UI5LOADER;
2
+ export const MODULE__UI5LOADER = "ui5loader.js";
3
+ export const MODULE__UI5LOADER_AUTOCONFIG = "ui5loader-autoconfig.js";
4
+ export const MODULE__JQUERY_SAP_GLOBAL = "jquery.sap.global.js";
5
+ export const MODULE__SAP_UI_CORE_CORE = "sap/ui/core/Core.js";
6
+ export const EVO_MARKER_RESOURCE = MODULE__UI5LOADER;
8
7
 
9
- module.exports.getRendererName = function( module ) {
8
+ export function getRendererName( module ) {
10
9
  if ( /\.js$/.test(module) ) {
11
10
  return module.replace(/\.js$/, "Renderer.js");
12
11
  }
13
- };
12
+ }
@@ -18,10 +18,10 @@
18
18
  * This class can handle multiple concurrent analysis calls, it has no instance state
19
19
  * other than the pool (which is readonly).
20
20
  */
21
- "use strict";
22
21
 
23
- const ModuleName = require("../utils/ModuleName");
24
- const log = require("@ui5/logger").getLogger("lbt:analyzer:ComponentAnalyzer");
22
+ import {fromUI5LegacyName} from "../utils/ModuleName.js";
23
+ import logger from "@ui5/logger";
24
+ const log = logger.getLogger("lbt:analyzer:ComponentAnalyzer");
25
25
 
26
26
  // ---------------------------------------------------------------------------------------------------------
27
27
 
@@ -66,6 +66,53 @@ class ComponentAnalyzer {
66
66
  return info;
67
67
  }
68
68
 
69
+ _getRootViewModule(rootView) {
70
+ // For runtime logic see sap/ui/core/UIComponent#createContent and sap/ui/core/mvc/View#_getModuleName
71
+
72
+ if (typeof rootView === "string") {
73
+ rootView = {
74
+ viewName: rootView
75
+ };
76
+ }
77
+ if (!rootView.type) {
78
+ rootView.type = "XML";
79
+ }
80
+
81
+ if (!rootView.viewName) {
82
+ log.warn(`Unable to analyze sap.ui5/rootView: Missing viewName`);
83
+ return null;
84
+ }
85
+
86
+ if (rootView.viewName.startsWith("module:")) {
87
+ return rootView.viewName.slice("module:".length) + ".js";
88
+ }
89
+
90
+ let viewTypeExtension;
91
+
92
+ switch (rootView.type) {
93
+ case "JS":
94
+ viewTypeExtension = ".view.js";
95
+ break;
96
+ case "JSON":
97
+ viewTypeExtension = ".view.json";
98
+ break;
99
+ case "Template":
100
+ viewTypeExtension = ".view.tmpl";
101
+ break;
102
+ case "XML":
103
+ viewTypeExtension = ".view.xml";
104
+ break;
105
+ case "HTML":
106
+ viewTypeExtension = ".view.html";
107
+ break;
108
+ default:
109
+ log.warn(`Unable to analyze sap.ui5/rootView: Unknown type '${rootView.type}'`);
110
+ return null;
111
+ }
112
+
113
+ return fromUI5LegacyName(rootView.viewName, viewTypeExtension);
114
+ }
115
+
69
116
  /**
70
117
  * Evaluates a manifest after it has been read and parsed
71
118
  * and adds any newly found dependencies to the given info object.
@@ -88,30 +135,21 @@ class ComponentAnalyzer {
88
135
  }
89
136
 
90
137
  if ( ui5.rootView ) {
91
- let rootView;
92
- if ( typeof ui5.rootView === "string" ) {
93
- rootView = {
94
- viewName: ui5.rootView,
95
- type: "XML"
96
- };
97
- } else {
98
- rootView = ui5.rootView;
138
+ const module = this._getRootViewModule(ui5.rootView);
139
+ if (module) {
140
+ log.verbose("adding root view dependency ", module);
141
+ info.addDependency( module );
99
142
  }
100
- const module = ModuleName.fromUI5LegacyName(
101
- rootView.viewName,
102
- ".view." + rootView.type.toLowerCase() );
103
- log.verbose("adding root view dependency ", module);
104
- info.addDependency( module );
105
143
  }
106
144
 
107
145
  each( ui5.dependencies && ui5.dependencies.libs, (options, lib) => {
108
- const module = ModuleName.fromUI5LegacyName(lib, "/library.js");
146
+ const module = fromUI5LegacyName(lib, "/library.js");
109
147
  log.verbose("adding library dependency ", module, options.lazy || false);
110
148
  info.addDependency( module, options.lazy ); // lazy -> conditional dependency
111
149
  });
112
150
 
113
151
  each( ui5.dependencies && ui5.dependencies.components, (options, component) => {
114
- const module = ModuleName.fromUI5LegacyName(component, "/Component.js");
152
+ const module = fromUI5LegacyName(component, "/Component.js");
115
153
  log.verbose("adding component dependency ", module, options.lazy || false);
116
154
  info.addDependency( module, options.lazy ); // lazy -> conditional dependency
117
155
  });
@@ -163,7 +201,7 @@ class ComponentAnalyzer {
163
201
  log.warn(`Neither a type nor a dataSource has been defined for model "${model}".`);
164
202
  return;
165
203
  }
166
- const module = ModuleName.fromUI5LegacyName( modelType );
204
+ const module = fromUI5LegacyName( modelType );
167
205
  log.verbose("derived model implementation dependency ", module);
168
206
  info.addDependency(module);
169
207
  });
@@ -175,7 +213,7 @@ class ComponentAnalyzer {
175
213
  // See sap/ui/core/UIComponent#init
176
214
  if (routing.routes) {
177
215
  const routerClassName = routingConfig.routerClass || "sap.ui.core.routing.Router";
178
- const routerClassModule = ModuleName.fromUI5LegacyName(routerClassName);
216
+ const routerClassModule = fromUI5LegacyName(routerClassName);
179
217
  log.verbose(`adding router dependency '${routerClassModule}'`);
180
218
  info.addDependency(routerClassModule);
181
219
  } else if (routing.targets) {
@@ -194,7 +232,7 @@ class ComponentAnalyzer {
194
232
  if (target && target.viewName) {
195
233
  // merge target config with default config
196
234
  const config = Object.assign({}, routing.config, target);
197
- const module = ModuleName.fromUI5LegacyName(
235
+ const module = fromUI5LegacyName(
198
236
  (config.viewPath ? config.viewPath + "." : "") +
199
237
  config.viewName, ".view." + config.viewType.toLowerCase() );
200
238
  log.verbose("converting routing target '%s' to view dependency '%s'", targetName, module);
@@ -209,4 +247,4 @@ class ComponentAnalyzer {
209
247
  }
210
248
  }
211
249
 
212
- module.exports = ComponentAnalyzer;
250
+ export default ComponentAnalyzer;
@@ -56,13 +56,13 @@
56
56
  * This class can handle multiple concurrent analysis calls, it has no instance state other than the pool
57
57
  * (which is readonly).
58
58
  */
59
- "use strict";
60
59
 
61
- const ModuleName = require("../utils/ModuleName");
62
- const SapUiDefine = require("../calls/SapUiDefine");
63
- const {parseJS, Syntax} = require("../utils/parseUtils");
64
- const {getValue, isMethodCall, isString} = require("../utils/ASTUtils");
65
- const log = require("@ui5/logger").getLogger("lbt:analyzer:FioriElementAnalyzer");
60
+ import {fromUI5LegacyName} from "../utils/ModuleName.js";
61
+ import SapUiDefine from "../calls/SapUiDefine.js";
62
+ import {parseJS, Syntax} from "../utils/parseUtils.js";
63
+ import {getValue, isMethodCall, getStringValue} from "../utils/ASTUtils.js";
64
+ import logger from "@ui5/logger";
65
+ const log = logger.getLogger("lbt:analyzer:FioriElementAnalyzer");
66
66
 
67
67
  // ---------------------------------------------------------------------------------------------------------
68
68
 
@@ -129,7 +129,7 @@ class FioriElementsAnalyzer {
129
129
  }
130
130
  each(activityCfg, (actionCfg) => {
131
131
  if ( actionCfg.template ) {
132
- const module = ModuleName.fromUI5LegacyName( "sap.fe.templates." +
132
+ const module = fromUI5LegacyName( "sap.fe.templates." +
133
133
  actionCfg.template + ".Component" );
134
134
  log.verbose("template app: add dependency to template component %s", module);
135
135
  info.addDependency(module);
@@ -151,7 +151,7 @@ class FioriElementsAnalyzer {
151
151
  const templateName = (pageConfig.component && pageConfig.component.settings &&
152
152
  pageConfig.component.settings.templateName) || defaultTemplateName;
153
153
  if ( templateName ) {
154
- const templateModuleName = ModuleName.fromUI5LegacyName( templateName, ".view.xml" );
154
+ const templateModuleName = fromUI5LegacyName( templateName, ".view.xml" );
155
155
  log.verbose("template app: add dependency to template view %s", templateModuleName);
156
156
  appInfo.addDependency(templateModuleName);
157
157
  }
@@ -165,25 +165,36 @@ class FioriElementsAnalyzer {
165
165
  const TA = defineCall.findImportName("sap/fe/core/TemplateAssembler.js");
166
166
  // console.log("local name for TemplateAssembler: %s", TA);
167
167
  if ( TA && defineCall.factory ) {
168
- defineCall.factory.body.body.forEach( (stmt) => {
169
- if ( stmt.type === Syntax.ReturnStatement &&
170
- isMethodCall(stmt.argument, [TA, "getTemplateComponent"]) &&
171
- stmt.argument.arguments.length > 2 &&
172
- stmt.argument.arguments[2].type === "ObjectExpression" ) {
173
- templateName = this._analyzeTemplateClassDefinition(stmt.argument.arguments[2]) || templateName;
168
+ if (defineCall.factory.type === Syntax.ArrowFunctionExpression &&
169
+ defineCall.factory.expression === true) {
170
+ if ( this._isTemplateClassDefinition(TA, defineCall.factory.body) ) {
171
+ templateName =
172
+ this._analyzeTemplateClassDefinition(defineCall.factory.body.arguments[2]) || templateName;
174
173
  }
175
- });
174
+ } else {
175
+ defineCall.factory.body.body.forEach( (stmt) => {
176
+ if ( stmt.type === Syntax.ReturnStatement &&
177
+ this._isTemplateClassDefinition(TA, stmt.argument)
178
+ ) {
179
+ templateName =
180
+ this._analyzeTemplateClassDefinition(stmt.argument.arguments[2]) || templateName;
181
+ }
182
+ });
183
+ }
176
184
  }
177
185
  }
178
186
  return templateName;
179
187
  }
180
188
 
189
+ _isTemplateClassDefinition(TA, node) {
190
+ return isMethodCall(node, [TA, "getTemplateComponent"]) &&
191
+ node.arguments.length > 2 &&
192
+ node.arguments[2].type === "ObjectExpression";
193
+ }
194
+
181
195
  _analyzeTemplateClassDefinition(clazz) {
182
- const defaultValue = getValue(clazz, ["metadata", "properties", "templateName", "defaultValue"]);
183
- if ( isString(defaultValue) ) {
184
- return defaultValue.value;
185
- }
196
+ return getStringValue(getValue(clazz, ["metadata", "properties", "templateName", "defaultValue"]));
186
197
  }
187
198
  }
188
199
 
189
- module.exports = FioriElementsAnalyzer;
200
+ export default FioriElementsAnalyzer;
@@ -1,12 +1,21 @@
1
- "use strict";
2
-
3
- const {Syntax, VisitorKeys} = require("../utils/parseUtils");
4
- const escope = require("escope");
5
- const ModuleName = require("../utils/ModuleName");
6
- const {Format: ModuleFormat} = require("../resources/ModuleInfo");
7
- const UI5ClientConstants = require("../UI5ClientConstants");
8
- const {findOwnProperty, getLocation, getPropertyKey, isMethodCall, isString} = require("../utils/ASTUtils");
9
- const log = require("@ui5/logger").getLogger("lbt:analyzer:JSModuleAnalyzer");
1
+ import {Syntax, VisitorKeys} from "../utils/parseUtils.js";
2
+ import escope from "escope";
3
+ import {fromUI5LegacyName, fromRequireJSName, resolveRelativeRequireJSName} from "../utils/ModuleName.js";
4
+ import moduleInfo from "../resources/ModuleInfo.js";
5
+ const ModuleFormat = moduleInfo.Format;
6
+ import {MODULE__JQUERY_SAP_GLOBAL, MODULE__UI5LOADER_AUTOCONFIG} from "../UI5ClientConstants.js";
7
+ import {
8
+ findOwnProperty,
9
+ getLocation,
10
+ getPropertyKey,
11
+ isMethodCall,
12
+ isString,
13
+ getStringValue,
14
+ } from "../utils/ASTUtils.js";
15
+
16
+ import logger from "@ui5/logger";
17
+
18
+ const log = logger.getLogger("lbt:analyzer:JSModuleAnalyzer");
10
19
 
11
20
  // ------------------------------------------------------------------------------------------------------------------
12
21
 
@@ -64,7 +73,7 @@ const EnrichedVisitorKeys = (function() {
64
73
  BreakStatement: [],
65
74
  CallExpression: [], // special handling
66
75
  CatchClause: ["param", "body"],
67
- ChainExpression: [],
76
+ ChainExpression: ["expression"],
68
77
  ClassBody: [],
69
78
  ClassDeclaration: [],
70
79
  ClassExpression: [],
@@ -114,7 +123,7 @@ const EnrichedVisitorKeys = (function() {
114
123
  ImportSpecifier: [], // imported, local
115
124
  Literal: [],
116
125
  LabeledStatement: [],
117
- LogicalExpression: [],
126
+ LogicalExpression: ["right"],
118
127
  MemberExpression: [],
119
128
  MetaProperty: toBeDone(["meta", "property"]),
120
129
  MethodDefinition: [],
@@ -350,13 +359,13 @@ class JSModuleAnalyzer {
350
359
 
351
360
  // depending on the used module APIs, add an implicit dependency to the loader entry module
352
361
  if ( info.format === ModuleFormat.UI5_LEGACY ) {
353
- info.addImplicitDependency(UI5ClientConstants.MODULE__JQUERY_SAP_GLOBAL);
362
+ info.addImplicitDependency(MODULE__JQUERY_SAP_GLOBAL);
354
363
  } else if ( info.format === ModuleFormat.UI5_DEFINE ) {
355
364
  // Note: the implicit dependency for sap.ui.define modules points to the standard UI5
356
365
  // loader config module. A more general approach would be to add a dependency to the loader
357
366
  // only, but then standard configuration would be missed by dependency resolution
358
367
  // (to be clarified)
359
- info.addImplicitDependency(UI5ClientConstants.MODULE__UI5LOADER_AUTOCONFIG);
368
+ info.addImplicitDependency(MODULE__UI5LOADER_AUTOCONFIG);
360
369
  }
361
370
 
362
371
  if ( !bIsUi5Module ) {
@@ -541,21 +550,27 @@ class JSModuleAnalyzer {
541
550
 
542
551
  function onDeclare(node) {
543
552
  const args = node.arguments;
544
- if ( args.length > 0 && isString(args[0]) ) {
545
- const name = ModuleName.fromUI5LegacyName( args[0].value );
546
- if ( nModuleDeclarations === 1 && !mainModuleFound) {
547
- // if this is the first declaration, then this is the main module declaration
548
- // note that this overrides an already given name
549
- setMainModuleInfo(name, getDocumentation(node));
550
- } else if ( nModuleDeclarations > 1 && name === info.name ) {
551
- // ignore duplicate declarations (e.g. in behavior file of design time controls)
552
- log.warn(`duplicate declaration of module name at ${getLocation(args)} in ${name}`);
553
+ if (args.length > 0) {
554
+ const value = getStringValue(args[0]);
555
+ if (value !== undefined) {
556
+ const name = fromUI5LegacyName(value);
557
+ if ( nModuleDeclarations === 1 && !mainModuleFound) {
558
+ // if this is the first declaration, then this is the main module declaration
559
+ // note that this overrides an already given name
560
+ setMainModuleInfo(name, getDocumentation(node));
561
+ } else if ( nModuleDeclarations > 1 && name === info.name ) {
562
+ // ignore duplicate declarations (e.g. in behavior file of design time controls)
563
+ log.warn(`duplicate declaration of module name at ${getLocation(args)} in ${name}`);
564
+ } else {
565
+ // otherwise it is just a submodule declaration
566
+ info.addSubModule(name);
567
+ }
568
+ return;
553
569
  } else {
554
- // otherwise it is just a submodule declaration
555
- info.addSubModule(name);
570
+ log.error("jQuery.sap.declare: module name could not be determined from first argument:", args[0]);
556
571
  }
557
572
  } else {
558
- log.error("jQuery.sap.declare: module name could not be determined from first argument:", args[0]);
573
+ log.error("jQuery.sap.declare: module name could not be determined, no arguments are given");
559
574
  }
560
575
  }
561
576
 
@@ -569,20 +584,26 @@ class JSModuleAnalyzer {
569
584
 
570
585
  // determine the name of the module
571
586
  let name = null;
572
- if ( i < nArgs && isString(args[i]) ) {
573
- name = ModuleName.fromRequireJSName( args[i++].value );
574
- if ( name === defaultName ) {
575
- // hardcoded name equals the file name, so this definition qualifies as main module definition
576
- setMainModuleInfo(name, desc);
577
- } else {
578
- info.addSubModule(name);
579
- if ( candidateName == null ) {
580
- // remember the name and description in case no other module qualifies as main module
581
- candidateName = name;
582
- candidateDescription = desc;
587
+ if ( i < nArgs ) {
588
+ const value = getStringValue( args[i] );
589
+ if ( value !== undefined ) {
590
+ name = fromRequireJSName(value);
591
+ if ( name === defaultName ) {
592
+ // hardcoded name equals the file name, so this definition qualifies as main module definition
593
+ setMainModuleInfo(name, desc);
594
+ } else {
595
+ info.addSubModule(name);
596
+ if ( candidateName == null ) {
597
+ // remember the name and description in case no other module qualifies as main module
598
+ candidateName = name;
599
+ candidateDescription = desc;
600
+ }
583
601
  }
602
+ i++;
584
603
  }
585
- } else {
604
+ }
605
+
606
+ if ( !name ) {
586
607
  nUnnamedDefines++;
587
608
  if ( nUnnamedDefines > 1 ) {
588
609
  throw new Error(
@@ -614,15 +635,25 @@ class JSModuleAnalyzer {
614
635
  // UI5 signature with one or many required modules
615
636
  for (let i = 0; i < nArgs; i++) {
616
637
  const arg = args[i];
617
- if ( isString(arg) ) {
618
- const requiredModuleName = ModuleName.fromUI5LegacyName( arg.value );
638
+ const value = getStringValue(arg);
639
+ if ( value !== undefined ) {
640
+ const requiredModuleName = fromUI5LegacyName( value );
619
641
  info.addDependency(requiredModuleName, conditional);
620
- } else if ( arg.type == Syntax.ConditionalExpression &&
621
- isString(arg.consequent) && isString(arg.alternate) ) {
622
- const requiredModuleName1 = ModuleName.fromUI5LegacyName( arg.consequent.value );
623
- info.addDependency(requiredModuleName1, true);
624
- const requiredModuleName2 = ModuleName.fromUI5LegacyName( arg.alternate.value );
625
- info.addDependency(requiredModuleName2, true);
642
+ } else if ( arg.type == Syntax.ConditionalExpression) {
643
+ const consequentValue = getStringValue(arg.consequent);
644
+ const alternateValue = getStringValue(arg.alternate);
645
+ if ( consequentValue !== undefined ) {
646
+ const requiredModuleName1 = fromUI5LegacyName( consequentValue );
647
+ info.addDependency(requiredModuleName1, true);
648
+ }
649
+ if ( alternateValue !== undefined ) {
650
+ const requiredModuleName2 = fromUI5LegacyName( alternateValue );
651
+ info.addDependency(requiredModuleName2, true);
652
+ }
653
+ if ( consequentValue === undefined || alternateValue === undefined ) {
654
+ log.verbose("jQuery.sap.require: cannot evaluate dynamic arguments: ", arg && arg.type);
655
+ info.dynamicDependencies = true;
656
+ }
626
657
  } else {
627
658
  log.verbose("jQuery.sap.require: cannot evaluate dynamic arguments: ", arg && arg.type);
628
659
  info.dynamicDependencies = true;
@@ -637,9 +668,10 @@ class JSModuleAnalyzer {
637
668
  const i = 0;
638
669
 
639
670
  if ( i < nArgs ) {
640
- if ( isString(args[i]) ) {
671
+ const value = getStringValue(args[i]);
672
+ if ( value !== undefined ) {
641
673
  // sap.ui.requireSync does not support relative dependencies
642
- const moduleName = ModuleName.fromRequireJSName( args[i].value );
674
+ const moduleName = fromRequireJSName( value );
643
675
  info.addDependency(moduleName, conditional);
644
676
  } else {
645
677
  log.verbose("sap.ui.requireSync: cannot evaluate dynamic arguments: ", args[i] && args[i].type);
@@ -654,18 +686,24 @@ class JSModuleAnalyzer {
654
686
  let i = 0;
655
687
 
656
688
  // determine the name of the module
657
- if ( i < nArgs && isString(args[i]) ) {
658
- const moduleName = ModuleName.fromRequireJSName( args[i++].value );
659
- info.addSubModule(moduleName);
660
-
661
- // add dependencies
662
- // to correctly identify dependencies e.g. of a library-preload
663
- const elementArg = args[i++];
664
- if (elementArg && elementArg.type === Syntax.ArrayExpression) {
665
- elementArg.elements.forEach((element) => {
666
- const dependencyName = ModuleName.resolveRelativeRequireJSName(moduleName, element.value);
667
- info.addDependency(dependencyName, conditional);
668
- });
689
+ if ( i < nArgs ) {
690
+ const value = getStringValue(args[i++]);
691
+ if ( value !== undefined ) {
692
+ const moduleName = fromRequireJSName( value );
693
+ info.addSubModule(moduleName);
694
+
695
+ // add dependencies
696
+ // to correctly identify dependencies e.g. of a library-preload
697
+ const elementArg = args[i++];
698
+ if (elementArg && elementArg.type === Syntax.ArrayExpression) {
699
+ elementArg.elements.forEach((element) => {
700
+ const dependencyName = resolveRelativeRequireJSName(moduleName,
701
+ getStringValue(element));
702
+ info.addDependency(dependencyName, conditional);
703
+ });
704
+ }
705
+ } else {
706
+ log.warn("sap.ui.predefine call has a non supported type for module name (ignored)");
669
707
  }
670
708
  } else {
671
709
  log.warn("sap.ui.predefine call is missing a module name (ignored)");
@@ -692,8 +730,11 @@ class JSModuleAnalyzer {
692
730
  if ( modules && modules.type == Syntax.ObjectExpression ) {
693
731
  modules.properties.forEach( function(property) {
694
732
  let moduleName = getPropertyKey(property);
733
+ if ( !moduleName ) {
734
+ return;
735
+ }
695
736
  if ( namesUseLegacyNotation ) {
696
- moduleName = ModuleName.fromUI5LegacyName(moduleName);
737
+ moduleName = fromUI5LegacyName(moduleName);
697
738
  }
698
739
  info.addSubModule(moduleName);
699
740
  });
@@ -705,16 +746,17 @@ class JSModuleAnalyzer {
705
746
  function analyzeDependencyArray(array, conditional, name) {
706
747
  // console.log(array);
707
748
  array.forEach( (item) => {
708
- if ( isString(item) ) {
749
+ const value = getStringValue(item);
750
+ if ( value !== undefined ) {
709
751
  // ignore special AMD dependencies (require, exports, module)
710
- if ( SPECIAL_AMD_DEPENDENCIES.indexOf(item.value) >= 0 ) {
752
+ if ( SPECIAL_AMD_DEPENDENCIES.indexOf(value) >= 0 ) {
711
753
  return;
712
754
  }
713
755
  let requiredModule;
714
756
  if (name == null) {
715
- requiredModule = ModuleName.fromRequireJSName( item.value );
757
+ requiredModule = fromRequireJSName( value );
716
758
  } else {
717
- requiredModule = ModuleName.resolveRelativeRequireJSName(name, item.value);
759
+ requiredModule = resolveRelativeRequireJSName(name, value);
718
760
  }
719
761
  info.addDependency( requiredModule, conditional );
720
762
  } else {
@@ -766,4 +808,4 @@ class JSModuleAnalyzer {
766
808
  }
767
809
 
768
810
 
769
- module.exports = JSModuleAnalyzer;
811
+ export default JSModuleAnalyzer;