babel-plugin-transform-modules-ui5 7.6.0 → 7.6.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.
- package/CHANGELOG.md +11 -0
- package/dist/classes/helpers/classes.js +43 -18
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [7.6.1](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.6.0...v7.6.1) (2024-09-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* support wrapped controller extension assignments ([dfa51b6](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/dfa51b613259aeedb3f20987f5e5165ca35545d8))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [7.6.0](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.5.0...v7.6.0) (2024-07-22)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -161,24 +161,20 @@ function convertClassToUI5Extend(path, node, classInfo, extraStaticProps, import
|
|
|
161
161
|
// @transformControllerExtension marker, because it is not a type assignment. In the resulting code, the
|
|
162
162
|
// "ControllerExtension.use(...)" part should be removed and the content of the brackets should be assigned
|
|
163
163
|
// directly to the member property.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
extendProps.unshift(buildObjectProperty(member)); // add it to the properties of the extend() config object
|
|
179
|
-
continue; // prevent the member from also being added to the constructor
|
|
180
|
-
}
|
|
181
|
-
}
|
|
164
|
+
const rightSide = member.value;
|
|
165
|
+
if (isCallToControllerExtensionUse(rightSide, memberPath)) {
|
|
166
|
+
member.value = rightSide.arguments[0];
|
|
167
|
+
extendProps.unshift(buildObjectProperty(member)); // add it to the properties of the extend() config object
|
|
168
|
+
continue; // prevent the member from also being added to the constructor
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// code instrumentation sometimes wraps ControllerExtension.use() calls like:
|
|
172
|
+
// this.routing = (cov_1uvvg22e7l().s[5]++, ControllerExtension.use(Routing.override({ … })));
|
|
173
|
+
if (_core.types.isSequenceExpression(rightSide) && isCallToControllerExtensionUse(rightSide.expressions[rightSide.expressions.length - 1], memberPath)) {
|
|
174
|
+
rightSide.expressions[rightSide.expressions.length - 1] = rightSide.expressions[rightSide.expressions.length - 1].arguments[0];
|
|
175
|
+
member.value = rightSide;
|
|
176
|
+
extendProps.unshift(buildObjectProperty(member)); // add it to the properties of the extend() config object
|
|
177
|
+
continue; // prevent the member from also being added to the constructor
|
|
182
178
|
}
|
|
183
179
|
|
|
184
180
|
// Special handling for TypeScript limitation where metadata, renderer and overrides must be properties.
|
|
@@ -212,6 +208,35 @@ function convertClassToUI5Extend(path, node, classInfo, extraStaticProps, import
|
|
|
212
208
|
}
|
|
213
209
|
}
|
|
214
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Checks whether the given thing is a CallExpression that calls ControllerExtension.use(...)
|
|
213
|
+
*
|
|
214
|
+
* @param {*} expression the thing to check - does not need to be a CallExpression
|
|
215
|
+
* @param {string} memberPath
|
|
216
|
+
* @returns true if the given expression is a CallExpression that calls ControllerExtension.use(...)
|
|
217
|
+
*/
|
|
218
|
+
function isCallToControllerExtensionUse(expression, memberPath) {
|
|
219
|
+
if (!_core.types.isCallExpression(expression)) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
const callee = expression.callee;
|
|
223
|
+
if (_core.types.isMemberExpression(callee) && _core.types.isIdentifier(callee.object) && _core.types.isIdentifier(callee.property) && callee.property.name === "use" // we are looking for "ControllerExtension.use(...)"
|
|
224
|
+
) {
|
|
225
|
+
var _memberPath$hub2, _callee$object, _importDeclaration$so;
|
|
226
|
+
const importDeclaration = (0, _imports.getImportDeclaration)(memberPath === null || memberPath === void 0 || (_memberPath$hub2 = memberPath.hub) === null || _memberPath$hub2 === void 0 || (_memberPath$hub2 = _memberPath$hub2.file) === null || _memberPath$hub2 === void 0 || (_memberPath$hub2 = _memberPath$hub2.opts) === null || _memberPath$hub2 === void 0 ? void 0 : _memberPath$hub2.filename, callee === null || callee === void 0 || (_callee$object = callee.object) === null || _callee$object === void 0 ? void 0 : _callee$object.name // usually, but not necessarily always: "ControllerExtension"...
|
|
227
|
+
);
|
|
228
|
+
// ...hence we rather look at the imported module name to be sure
|
|
229
|
+
if ((importDeclaration === null || importDeclaration === void 0 || (_importDeclaration$so = importDeclaration.source) === null || _importDeclaration$so === void 0 ? void 0 : _importDeclaration$so.value) === "sap/ui/core/mvc/ControllerExtension") {
|
|
230
|
+
if (!expression.arguments || expression.arguments.length !== 1) {
|
|
231
|
+
// exactly one argument must be there
|
|
232
|
+
throw memberPath.buildCodeFrameError(`ControllerExtension.use() must be called with exactly one argument but has ${expression.arguments ? expression.arguments.length : 0}`);
|
|
233
|
+
}
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return false; // return false if not a match
|
|
238
|
+
}
|
|
239
|
+
|
|
215
240
|
// Arrow function properties need to get moved to the constructor so that
|
|
216
241
|
// they're bound properly to the class instance, to align with the spec.
|
|
217
242
|
// For controllers, use onInit rather than constructor, since controller constructors don't work.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-transform-modules-ui5",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.1",
|
|
4
4
|
"description": "An unofficial babel plugin for SAP UI5.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"prettier": "^3.1.0",
|
|
95
95
|
"rimraf": "^5.0.5"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "bd1be642e7f4e1849a2716cefa64f4e048f42bae"
|
|
98
98
|
}
|