babel-plugin-transform-modules-ui5 7.7.0 → 7.8.0

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
@@ -3,6 +3,29 @@
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.8.0](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.7.1...v7.8.0) (2025-09-11)
7
+
8
+
9
+ ### Features
10
+
11
+ * support optional super call ([#143](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/143)) ([e09f561](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/e09f5617eb98b082e1630caa2d23801d3fc91650))
12
+
13
+
14
+
15
+
16
+
17
+ ## [7.7.1](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.7.0...v7.7.1) (2025-05-13)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * autoConvertControllerClass to consider controller.ts file as well (not just .js) ([#140](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/140)) ([788705d](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/788705dde44091cfecb47e9f51a5bd294b39af4b)), closes [#139](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/139)
23
+ * noWrapBeforeImport must wrap first import if no code is before ([#141](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/141)) ([d80c070](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/d80c070e181b03546d381d8ee2fb0ddfc09d4e5a))
24
+
25
+
26
+
27
+
28
+
6
29
  # [7.7.0](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.6.2...v7.7.0) (2024-09-16)
7
30
 
8
31
 
@@ -14,8 +14,7 @@ var ast = _interopRequireWildcard(require("../../utils/ast"));
14
14
  var _jsdoc = require("./jsdoc");
15
15
  var _decorators = require("./decorators");
16
16
  var _imports = require("./imports");
17
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
19
18
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
19
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
20
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -8,8 +8,7 @@ var _core = require("@babel/core");
8
8
  var th = _interopRequireWildcard(require("../utils/templates"));
9
9
  var ast = _interopRequireWildcard(require("../utils/ast"));
10
10
  var classes = _interopRequireWildcard(require("./helpers/classes"));
11
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
12
  const CONSTRUCTOR = "constructor";
14
13
  const ClassTransformVisitor = exports.ClassTransformVisitor = {
15
14
  ImportDeclaration(path) {
@@ -111,7 +110,7 @@ const ClassTransformVisitor = exports.ClassTransformVisitor = {
111
110
  /*!
112
111
  * Visits function calls.
113
112
  */
114
- CallExpression(path) {
113
+ "OptionalCallExpression|CallExpression"(path) {
115
114
  const {
116
115
  node
117
116
  } = path;
@@ -126,9 +125,9 @@ const ClassTransformVisitor = exports.ClassTransformVisitor = {
126
125
  if (_core.types.isSuper(callee)) {
127
126
  replaceConstructorSuperCall(path, node, this.superClassName);
128
127
  } else if (_core.types.isSuper(callee.object)) {
129
- replaceObjectSuperCall(path, node, this.superClassName);
128
+ replaceObjectSuperCall(path, node, this.superClassName, path.isOptionalCallExpression());
130
129
  } else if (isSuperApply(callee)) {
131
- replaceSuperApplyCall(path, node, this.superClassName);
130
+ replaceSuperApplyCall(path, node, this.superClassName, path.isOptionalCallExpression());
132
131
  }
133
132
  }
134
133
  },
@@ -169,25 +168,27 @@ function replaceConstructorSuperCall(path, node, superClassName) {
169
168
  /**
170
169
  * Replace super.method() call
171
170
  */
172
- function replaceObjectSuperCall(path, node, superClassName) {
173
- replaceSuperNamedCall(path, node, superClassName, node.callee.property.name);
171
+ function replaceObjectSuperCall(path, node, superClassName, optional = false) {
172
+ replaceSuperNamedCall(path, node, superClassName, node.callee.property.name, optional);
174
173
  }
175
174
 
176
175
  /**
177
176
  * Replace super.method.apply() call
178
177
  */
179
- function replaceSuperApplyCall(path, node, superClassName) {
178
+ function replaceSuperApplyCall(path, node, superClassName, optional = false) {
180
179
  const methodName = node.callee.object.property.name;
181
- path.replaceWith(_core.types.callExpression(_core.types.identifier(`${superClassName}.prototype.${methodName}.apply`), node.arguments));
180
+ const op = optional ? "?." : ".";
181
+ path.replaceWith(_core.types.callExpression(_core.types.identifier(`${superClassName}.prototype.${methodName}${op}apply`), node.arguments));
182
182
  }
183
- function replaceSuperNamedCall(path, node, superClassName, methodName) {
183
+ function replaceSuperNamedCall(path, node, superClassName, methodName, optional = false) {
184
184
  // .call() is better for simple args (or not args) but doesn't work right for spread args
185
185
  // if it gets further transpiled by babel spread args transform (will be .call.apply(...).
186
186
  const thisEx = _core.types.thisExpression();
187
187
  const hasSpread = node.arguments.some(_core.types.isSpreadElement);
188
188
  const caller = hasSpread ? "apply" : "call";
189
189
  const callArgs = hasSpread ? [thisEx, _core.types.arrayExpression(node.arguments)] : [thisEx, ...node.arguments];
190
- path.replaceWith(_core.types.callExpression(_core.types.identifier(`${superClassName}.prototype.${methodName}.${caller}`), callArgs));
190
+ const op = optional ? "?." : ".";
191
+ path.replaceWith(_core.types.callExpression(_core.types.identifier(`${superClassName}.prototype.${methodName}${op}${caller}`), callArgs));
191
192
  }
192
193
  function doesClassExtendFromImport(node, imports) {
193
194
  const superClass = node.superClass;
@@ -203,7 +204,8 @@ function shouldConvertClass(file, node, opts, classInfo) {
203
204
  if (classInfo.name || classInfo.alias || classInfo.controller || classInfo.namespace) {
204
205
  return true;
205
206
  }
206
- if (/.*[.]controller[.]js$/.test(file.opts.filename) && opts.autoConvertControllerClass !== false) {
207
+ // Convert controller classes
208
+ if (/.*[.]controller[.](js|ts)$/.test(file.opts.filename) && opts.autoConvertControllerClass !== false) {
207
209
  return true;
208
210
  }
209
211
  return false;
@@ -8,8 +8,7 @@ exports.getDefaultExportName = getDefaultExportName;
8
8
  var _core = require("@babel/core");
9
9
  var th = _interopRequireWildcard(require("../../utils/templates"));
10
10
  var ast = _interopRequireWildcard(require("../../utils/ast"));
11
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
12
  /**
14
13
  * Collapse named exports onto the default export so that the default export can be returned directly,
15
14
  * so that exports can be easily used by code that does not include an import interop.
@@ -8,8 +8,7 @@ var _core = require("@babel/core");
8
8
  var eh = _interopRequireWildcard(require("./exports"));
9
9
  var th = _interopRequireWildcard(require("../../utils/templates"));
10
10
  var ast = _interopRequireWildcard(require("../../utils/ast"));
11
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
12
  function wrap(visitor, programNode, opts) {
14
13
  var _body;
15
14
  let {
@@ -89,6 +88,11 @@ function wrap(visitor, programNode, opts) {
89
88
  let reachedFirstImport = false;
90
89
  const fullBody = body;
91
90
  const newBody = [];
91
+
92
+ // If there is no lastBeforeWrapping, the first import is not marked
93
+ if (!fullBody.find(item => item.lastBeforeWrapping)) {
94
+ reachedFirstImport = true;
95
+ }
92
96
  for (const item of fullBody) {
93
97
  if (reachedFirstImport) {
94
98
  newBody.push(item);
@@ -11,15 +11,14 @@ var th = _interopRequireWildcard(require("../utils/templates"));
11
11
  var ast = _interopRequireWildcard(require("../utils/ast"));
12
12
  var _jsdoc = require("../classes/helpers/jsdoc");
13
13
  const _excluded = ["filename", "opts"];
14
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
17
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
19
18
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
20
19
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
21
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
22
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
20
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
21
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
23
22
  const resolveSource = (src, filename) => {
24
23
  src = src.replace(/\\/g, "/");
25
24
  const dir = (0, _path.dirname)(filename);
@@ -198,9 +197,13 @@ const ModuleTransformVisitor = exports.ModuleTransformVisitor = {
198
197
  }
199
198
 
200
199
  // this is the very first import in noWrapBeforeImport mode and there are sibling nodes before this import
201
- if (opts.noWrapBeforeImport && !this.firstImportMarked && path.inList && path.key > 0) {
202
- // mark the direct predecessor as the last one to exclude from wrapping
203
- path.getSibling(path.key - 1).node.lastBeforeWrapping = true;
200
+ if (opts.noWrapBeforeImport && !this.firstImportMarked && path.inList) {
201
+ // for the first element there is a special case as we can't mark the previous one
202
+ // therefore we do not mark anything to make clear that there's nothing to exclude
203
+ if (path.key > 0) {
204
+ // mark the direct predecessor as the last one to exclude from wrapping
205
+ path.getSibling(path.key - 1).node.lastBeforeWrapping = true;
206
+ }
204
207
  this.firstImportMarked = true;
205
208
  }
206
209
  path.replaceWithMultiple(deconstructors);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-transform-modules-ui5",
3
- "version": "7.7.0",
3
+ "version": "7.8.0",
4
4
  "description": "An unofficial babel plugin for SAP UI5.",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -96,5 +96,5 @@
96
96
  "prettier": "^3.3.3",
97
97
  "rimraf": "^6.0.1"
98
98
  },
99
- "gitHead": "0685a329208b50e1a5ff8f4cb5a6974d85364012"
99
+ "gitHead": "d0c106c3b4a88bf2f44eaa09622311bbf4471bc8"
100
100
  }