@ui5/builder 2.11.7 → 2.11.8

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.
package/CHANGELOG.md CHANGED
@@ -2,10 +2,17 @@
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/v2.11.7...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v2.11.8...HEAD).
6
+
7
+ <a name="v2.11.8"></a>
8
+ ## [v2.11.8] - 2022-10-28
9
+ ### Bug Fixes
10
+ - **ComponentAnalyzer:** Fix detection of rootView [`acb3d9f`](https://github.com/SAP/ui5-builder/commit/acb3d9fd7fc60ad61ac88d68cb0fd5296b795e9f)
11
+ - **XMLTemplateAnalyzer:** Fix detection of nested views [`1cbfd82`](https://github.com/SAP/ui5-builder/commit/1cbfd82396e5fa78455e0a696e9229a2e8a337fc)
12
+
6
13
 
7
14
  <a name="v2.11.7"></a>
8
- ## [v2.11.7] - 2022-10-16
15
+ ## [v2.11.7] - 2022-10-20
9
16
  ### Dependency Updates
10
17
  - Bump escope from 3.6.0 to 4.0.0 [`852b37f`](https://github.com/SAP/ui5-builder/commit/852b37f549f3927decbc1b40cc6055325472d625)
11
18
 
@@ -663,6 +670,7 @@ to load the custom bundle file instead.
663
670
  - Add ability to configure component preloads and custom bundles [`2241e5f`](https://github.com/SAP/ui5-builder/commit/2241e5ff98fd95f1f80cc74959655ae7a9c660e7)
664
671
 
665
672
 
673
+ [v2.11.8]: https://github.com/SAP/ui5-builder/compare/v2.11.7...v2.11.8
666
674
  [v2.11.7]: https://github.com/SAP/ui5-builder/compare/v2.11.6...v2.11.7
667
675
  [v2.11.6]: https://github.com/SAP/ui5-builder/compare/v2.11.5...v2.11.6
668
676
  [v2.11.5]: https://github.com/SAP/ui5-builder/compare/v2.11.4...v2.11.5
@@ -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 ModuleName.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,20 +135,11 @@ 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) => {
@@ -37,10 +37,12 @@ const FRAGMENT_FRAGMENTNAME_ATTRIBUTE = "fragmentName";
37
37
  const FRAGMENT_TYPE_ATTRIBUTE = "type";
38
38
 
39
39
  // different view types
40
+ const VIEW_MODULE = "sap/ui/core/mvc/View.js";
40
41
  const HTMLVIEW_MODULE = "sap/ui/core/mvc/HTMLView.js";
41
42
  const JSVIEW_MODULE = "sap/ui/core/mvc/JSView.js";
42
43
  const JSONVIEW_MODULE = "sap/ui/core/mvc/JSONView.js";
43
44
  const XMLVIEW_MODULE = "sap/ui/core/mvc/XMLView.js";
45
+ const TEMPLATEVIEW_MODULE = "sap/ui/core/mvc/TemplateView.js";
44
46
  const ANYVIEW_VIEWNAME_ATTRIBUTE = "viewName";
45
47
  const XMLVIEW_CONTROLLERNAME_ATTRIBUTE = "controllerName";
46
48
  const XMLVIEW_RESBUNDLENAME_ATTRIBUTE = "resourceBundleName";
@@ -48,6 +50,7 @@ const XMLVIEW_CORE_REQUIRE_ATTRIBUTE_NS = {
48
50
  uri: "sap.ui.core",
49
51
  local: "require"
50
52
  };
53
+ const VIEW_TYPE_ATTRIBUTE = "type";
51
54
 
52
55
  /*
53
56
  * Helper to simplify access to node attributes.
@@ -347,6 +350,54 @@ class XMLTemplateAnalyzer {
347
350
  // console.log("child view detected %s", childViewModuleName);
348
351
  this._addDependency(childViewModuleName, conditional);
349
352
  }
353
+ } else if ( moduleName === TEMPLATEVIEW_MODULE ) {
354
+ const viewName = getAttribute(node, ANYVIEW_VIEWNAME_ATTRIBUTE);
355
+ if ( viewName ) {
356
+ const childViewModuleName = ModuleName.fromUI5LegacyName( viewName, ".view.tmpl" );
357
+ // console.log("child view detected %s", childViewModuleName);
358
+ this._addDependency(childViewModuleName, conditional);
359
+ }
360
+ } else if ( moduleName === VIEW_MODULE ) {
361
+ const viewName = getAttribute(node, ANYVIEW_VIEWNAME_ATTRIBUTE);
362
+ if ( viewName ) {
363
+ let childViewModuleName;
364
+
365
+ if (viewName.startsWith("module:")) {
366
+ childViewModuleName = viewName.slice("module:".length) + ".js";
367
+ } else {
368
+ const viewType = getAttribute(node, VIEW_TYPE_ATTRIBUTE);
369
+
370
+ let viewTypeExtension;
371
+
372
+ switch (viewType) {
373
+ case "JS":
374
+ viewTypeExtension = ".view.js";
375
+ break;
376
+ case "JSON":
377
+ viewTypeExtension = ".view.json";
378
+ break;
379
+ case "Template":
380
+ viewTypeExtension = ".view.tmpl";
381
+ break;
382
+ case "XML":
383
+ viewTypeExtension = ".view.xml";
384
+ break;
385
+ case "HTML":
386
+ viewTypeExtension = ".view.html";
387
+ break;
388
+ default:
389
+ log.warn(`Unable to analyze sap.ui5/rootView: Unknown type '${viewType}'`);
390
+ }
391
+
392
+ if (viewTypeExtension) {
393
+ childViewModuleName = ModuleName.fromUI5LegacyName(viewName, viewTypeExtension);
394
+ }
395
+ }
396
+ if (childViewModuleName) {
397
+ // console.log("child view detected %s", childViewModuleName);
398
+ this._addDependency(childViewModuleName, conditional);
399
+ }
400
+ }
350
401
  }
351
402
  } catch (err) {
352
403
  // ignore missing resources
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/builder",
3
- "version": "2.11.7",
3
+ "version": "2.11.8",
4
4
  "description": "UI5 Tooling - Builder",
5
5
  "author": {
6
6
  "name": "SAP SE",