babel-plugin-transform-modules-ui5 7.0.4 → 7.0.6

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/dist/utils/ast.js CHANGED
@@ -3,75 +3,66 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isObjectAssignOrExtendsExpression = isObjectAssignOrExtendsExpression;
7
- exports.isObjectAssignExpression = isObjectAssignExpression;
8
- exports.isExtendsHelperExpression = isExtendsHelperExpression;
9
- exports.isImport = isImport;
10
- exports.isIdentifierNamed = isIdentifierNamed;
11
- exports.isCommentBlock = isCommentBlock;
12
- exports.getIdName = getIdName;
13
- exports.isSuperCallExpression = isSuperCallExpression;
6
+ exports.convertDeclarationToExpression = convertDeclarationToExpression;
7
+ exports.convertFunctionDeclarationToExpression = convertFunctionDeclarationToExpression;
14
8
  exports.findPropertiesOfNode = findPropertiesOfNode;
9
+ exports.getIdName = getIdName;
15
10
  exports.getInternalStaticThingsOfClass = getInternalStaticThingsOfClass;
16
11
  exports.getOtherPropertiesOfIdentifier = getOtherPropertiesOfIdentifier;
17
- exports.getPropertiesOfObjectAssignOrExtendHelper = getPropertiesOfObjectAssignOrExtendHelper;
18
12
  exports.getPropNames = getPropNames;
13
+ exports.getPropertiesOfObjectAssignOrExtendHelper = getPropertiesOfObjectAssignOrExtendHelper;
19
14
  exports.groupPropertiesByName = groupPropertiesByName;
20
- exports.convertFunctionDeclarationToExpression = convertFunctionDeclarationToExpression;
21
- exports.convertDeclarationToExpression = convertDeclarationToExpression;
22
- exports.isSuperPrototypeCallOf = isSuperPrototypeCallOf;
23
15
  exports.isCallExpressionCalling = isCallExpressionCalling;
16
+ exports.isCommentBlock = isCommentBlock;
17
+ exports.isExtendsHelperExpression = isExtendsHelperExpression;
18
+ exports.isIdentifierNamed = isIdentifierNamed;
19
+ exports.isImport = isImport;
20
+ exports.isObjectAssignExpression = isObjectAssignExpression;
21
+ exports.isObjectAssignOrExtendsExpression = isObjectAssignOrExtendsExpression;
22
+ exports.isSuperCallExpression = isSuperCallExpression;
23
+ exports.isSuperPrototypeCallOf = isSuperPrototypeCallOf;
24
24
  exports.isThisExpressionUsed = isThisExpressionUsed;
25
-
26
25
  var _core = require("@babel/core");
27
-
28
- var _arrayFlatten = _interopRequireDefault(require("array-flatten"));
29
-
30
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
-
26
+ var _arrayFlatten = require("array-flatten");
32
27
  function isObjectAssignOrExtendsExpression(node) {
33
28
  return isObjectAssignExpression(node) || isExtendsHelperExpression(node);
34
29
  }
35
-
36
30
  function isObjectAssignExpression(node) {
37
31
  if (!_core.types.isCallExpression(node)) return false;
38
32
  const callee = node && node.callee;
39
33
  return !!(callee.object && callee.property && callee.object.name === "Object" && callee.property.name === "assign");
40
34
  }
41
-
42
35
  function isExtendsHelperExpression(node) {
43
36
  if (!_core.types.isCallExpression(node)) return false;
44
37
  const callee = node && node.callee;
45
38
  return isIdentifierNamed(callee, "_extends");
46
- } // t.isImport only exists if the dynamic import syntax plugin is used, so avoid using that to make it optional.
47
-
39
+ }
48
40
 
41
+ // t.isImport only exists if the dynamic import syntax plugin is used, so avoid using that to make it optional.
49
42
  function isImport(node) {
50
43
  return node && node.type === "Import";
51
44
  }
52
-
53
45
  function isIdentifierNamed(node, name) {
54
46
  return _core.types.isIdentifier(node, {
55
47
  name: name
56
48
  });
57
- } // This doesn't exist on babel-types
58
-
49
+ }
59
50
 
51
+ // This doesn't exist on babel-types
60
52
  function isCommentBlock(node) {
61
53
  return node && node.type === "CommentBlock";
62
54
  }
63
-
64
55
  function getIdName(node) {
65
56
  return node.id && node.id.name;
66
57
  }
67
-
68
58
  function isSuperCallExpression(expression) {
69
59
  return _core.types.isCallExpression(expression) && expression.callee.type === "Super";
70
- } // export function isSuperExpressionStatement(node) {
60
+ }
61
+
62
+ // export function isSuperExpressionStatement(node) {
71
63
  // return isSuperCallExpression(node.expression)
72
64
  // }
73
65
 
74
-
75
66
  function findPropertiesOfNode(blockScopeNode, declaration) {
76
67
  if (_core.types.isFunctionDeclaration(declaration) || _core.types.isArrowFunctionExpression(declaration)) {
77
68
  return null;
@@ -84,13 +75,12 @@ function findPropertiesOfNode(blockScopeNode, declaration) {
84
75
  } else if (isObjectAssignOrExtendsExpression(declaration)) {
85
76
  return getPropertiesOfObjectAssignOrExtendHelper(declaration, blockScopeNode);
86
77
  }
87
-
88
78
  return null;
89
79
  }
90
-
91
80
  function getInternalStaticThingsOfClass(classNode) {
92
81
  return classNode.body.body.filter(item => item.static);
93
82
  }
83
+
94
84
  /**
95
85
  * Traverse the top-level of the scope (program or function body) looking for either:
96
86
  * - ObjectExpression assignments to the object variable.
@@ -98,17 +88,14 @@ function getInternalStaticThingsOfClass(classNode) {
98
88
  *
99
89
  * @return Array<{key, value}>
100
90
  */
101
-
102
-
103
91
  function getOtherPropertiesOfIdentifier(blockScopeNode, idName) {
104
- return (0, _arrayFlatten.default)(blockScopeNode.body.map(node => {
92
+ return (0, _arrayFlatten.flatten)(blockScopeNode.body.map(node => {
105
93
  if (_core.types.isExpressionStatement(node)) {
106
94
  // ID = value | ID.key = value | ID.key.nested = value
107
95
  const {
108
96
  left,
109
97
  right
110
98
  } = node.expression;
111
-
112
99
  if (_core.types.isAssignmentExpression(node.expression)) {
113
100
  if (_core.types.isIdentifier(left) && left.name === idName) {
114
101
  // ID = value
@@ -121,7 +108,6 @@ function getOtherPropertiesOfIdentifier(blockScopeNode, idName) {
121
108
  object,
122
109
  property: key
123
110
  } = left;
124
-
125
111
  if (_core.types.isIdentifier(object) && object.name === idName) {
126
112
  // ID.key = value
127
113
  return {
@@ -136,10 +122,9 @@ function getOtherPropertiesOfIdentifier(blockScopeNode, idName) {
136
122
  }
137
123
  }).filter(item => item));
138
124
  }
139
-
140
125
  function getPropertiesOfObjectAssignOrExtendHelper(node, blockScopeNode) {
141
126
  // Check all the args and recursively try to get props of identifiers (although they may be imported)
142
- return (0, _arrayFlatten.default)(node.arguments.map(arg => {
127
+ return (0, _arrayFlatten.flatten)(node.arguments.map(arg => {
143
128
  if (_core.types.isObjectExpression(arg)) {
144
129
  return arg.properties;
145
130
  } else if (_core.types.isIdentifier(arg)) {
@@ -148,22 +133,18 @@ function getPropertiesOfObjectAssignOrExtendHelper(node, blockScopeNode) {
148
133
  }
149
134
  }));
150
135
  }
151
-
152
136
  function getPropNames(props) {
153
137
  return props.map(prop => prop.key.name);
154
138
  }
155
-
156
139
  function groupPropertiesByName(properties) {
157
140
  return properties && properties.reduce((accumulator, property) => {
158
141
  accumulator[property.key.name] = property.value;
159
142
  return accumulator;
160
143
  }, {});
161
144
  }
162
-
163
145
  function convertFunctionDeclarationToExpression(declaration) {
164
146
  return _core.types.functionExpression(declaration.id, declaration.params, declaration.body, declaration.generator, declaration.async);
165
147
  }
166
-
167
148
  function convertDeclarationToExpression(declaration) {
168
149
  if (_core.types.isFunctionDeclaration(declaration)) {
169
150
  return convertFunctionDeclarationToExpression(declaration);
@@ -171,10 +152,10 @@ function convertDeclarationToExpression(declaration) {
171
152
  return declaration;
172
153
  }
173
154
  }
174
-
175
155
  function isSuperPrototypeCallOf(expression, superClassName, superMethodName) {
176
156
  return _core.types.isCallExpression(expression) && isCallExpressionCalling(expression, `${superClassName}.prototype.${superMethodName}.apply`);
177
157
  }
158
+
178
159
  /**
179
160
  * Helper to see if a call expression is calling a given method such as sap.ui.define().
180
161
  * The AST is structured in reverse (defined > ui > sap) so we reverse the method call to compare.
@@ -182,24 +163,21 @@ function isSuperPrototypeCallOf(expression, superClassName, superMethodName) {
182
163
  * @param {CallExpression} expression
183
164
  * @param {String} dotNotationString For example, sap.ui.define or Class.prototype.method.apply
184
165
  */
185
-
186
-
187
166
  function isCallExpressionCalling(expression, dotNotationString) {
188
167
  if (!_core.types.isCallExpression(expression)) return false;
189
168
  const callee = expression.callee;
190
169
  const parts = dotNotationString.split(".");
191
170
  let node = callee;
192
-
193
171
  for (const nextNamePart of parts.reverse()) {
194
- if (!node) return false; // property won't be there for an anonymous function
195
-
172
+ if (!node) return false;
173
+ // property won't be there for an anonymous function
196
174
  const nodeName = node.name || node.property && node.property.name;
197
175
  if (nodeName !== nextNamePart) return false;
198
176
  node = node.object;
199
177
  }
200
-
201
178
  return true;
202
179
  }
180
+
203
181
  /**
204
182
  * Recursively search through some parts of a node's for use of 'this'.
205
183
  * It checks the callee and the arguments and traverses into arrow functions.
@@ -222,25 +200,19 @@ function isCallExpressionCalling(expression, dotNotationString) {
222
200
  *
223
201
  * @param {*} node
224
202
  */
225
-
226
-
227
203
  function isThisExpressionUsed(node) {
228
204
  if (!node) {
229
205
  return false;
230
206
  }
231
-
232
207
  if (Array.isArray(node)) {
233
208
  return node.some(isThisExpressionUsed);
234
209
  }
235
-
236
210
  if (_core.types.isThisExpression(node)) {
237
211
  return true;
238
212
  }
239
-
240
213
  if (_core.types.isFunctionExpression(node)) {
241
214
  return false;
242
215
  }
243
-
244
216
  const traversableProps = ["body", "callee", "arguments", "expression", "object", "property"];
245
217
  return traversableProps.some(prop => node[prop] && isThisExpressionUsed(node[prop]));
246
218
  }
@@ -3,15 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.buildInheritingFunction = exports.buildInheritingConstructor = exports.buildExtendAssign = exports.buildExportDefault = exports.buildDynamicImportHelper = exports.buildDefineGlobal = exports.buildDefine = exports.buildDefaultImportInterop = exports.buildDefaultImportDeconstructor = exports.buildDeclareExports = exports.buildConstDeclaration = exports.buildAssign = exports.buildAllExportHelper = exports.buildAllExport = void 0;
6
7
  exports.buildNamedExport = buildNamedExport;
7
- exports.buildInheritingConstructor = exports.buildInheritingFunction = exports.buildExtendAssign = exports.buildNamedImportDestructor = exports.buildConstDeclaration = exports.buildDynamicImportHelper = exports.buildDefaultImportDeconstructor = exports.buildDefaultImportInterop = exports.buildReturn = exports.buildAllExport = exports.buildAllExportHelper = exports.buildReturnExports = exports.buildExportDefault = exports.buildTempExport = exports.buildDeclareExports = exports.buildDefineGlobal = exports.buildDefine = exports.buildAssign = exports.exportsIdentifier = void 0;
8
-
8
+ exports.exportsIdentifier = exports.buildTempExport = exports.buildReturnExports = exports.buildReturn = exports.buildNamedImportDestructor = void 0;
9
9
  var _core = require("@babel/core");
10
-
11
10
  const exportName = "__exports";
12
-
13
11
  const exportsIdentifier = _core.types.identifier(exportName);
14
-
15
12
  exports.exportsIdentifier = exportsIdentifier;
16
13
  const buildAssign = (0, _core.template)(`
17
14
  OBJECT.NAME = VALUE;
@@ -27,15 +24,17 @@ const buildDefineGlobal = (0, _core.template)(`
27
24
  sap.ui.define(SOURCES, function (PARAMS) {
28
25
  BODY;
29
26
  }, true);
30
- `); // Uses 'var' since it gets added during wrap
27
+ `);
31
28
 
29
+ // Uses 'var' since it gets added during wrap
32
30
  exports.buildDefineGlobal = buildDefineGlobal;
33
31
  const buildDeclareExports = (0, _core.template)(`
34
32
  var ${exportName} = {
35
33
  __esModule: true
36
34
  };
37
- `); // Uses 'var' since it gets added during wrap
35
+ `);
38
36
 
37
+ // Uses 'var' since it gets added during wrap
39
38
  exports.buildDeclareExports = buildDeclareExports;
40
39
  const buildTempExport = (0, _core.template)(`
41
40
  var ${exportName} = VALUE;
@@ -49,7 +48,6 @@ const buildReturnExports = (0, _core.template)(`
49
48
  return ${exportName};
50
49
  `);
51
50
  exports.buildReturnExports = buildReturnExports;
52
-
53
51
  function buildNamedExport(obj) {
54
52
  return buildAssign({
55
53
  OBJECT: exportsIdentifier,
@@ -57,7 +55,6 @@ function buildNamedExport(obj) {
57
55
  VALUE: obj.value
58
56
  });
59
57
  }
60
-
61
58
  const buildAllExportHelper = (0, _core.template)(`
62
59
  function extendExports(exports, obj) {
63
60
  Object.keys(obj).forEach(function (key) {
@@ -86,8 +83,9 @@ const buildDefaultImportInterop = (0, _core.template)(`
86
83
  exports.buildDefaultImportInterop = buildDefaultImportInterop;
87
84
  const buildDefaultImportDeconstructor = (0, _core.template)(`
88
85
  const LOCAL = _interopRequireDefault(MODULE);
89
- `); // TODO: inject __extends instead of Object.assign unless useBuiltIns in set
86
+ `);
90
87
 
88
+ // TODO: inject __extends instead of Object.assign unless useBuiltIns in set
91
89
  exports.buildDefaultImportDeconstructor = buildDefaultImportDeconstructor;
92
90
  const buildDynamicImportHelper = (0, _core.template)(`
93
91
  function __ui5_require_async(path) {
@@ -119,8 +117,9 @@ const buildNamedImportDestructor = (0, _core.template)(`
119
117
  exports.buildNamedImportDestructor = buildNamedImportDestructor;
120
118
  const buildExtendAssign = (0, _core.template)(`
121
119
  const NAME = SUPER.extend(FQN, OBJECT);
122
- `); // This is use when there is not already the function, so always propagate arguments.
120
+ `);
123
121
 
122
+ // This is use when there is not already the function, so always propagate arguments.
124
123
  exports.buildExtendAssign = buildExtendAssign;
125
124
  const buildInheritingFunction = (0, _core.template)(`
126
125
  function NAME() {
@@ -128,8 +127,9 @@ const buildInheritingFunction = (0, _core.template)(`
128
127
  SUPER.prototype.NAME.apply(this, arguments);
129
128
  }
130
129
  }
131
- `); // This is use when there is not already the function, so always propagate arguments.
130
+ `);
132
131
 
132
+ // This is use when there is not already the function, so always propagate arguments.
133
133
  exports.buildInheritingFunction = buildInheritingFunction;
134
134
  const buildInheritingConstructor = (0, _core.template)(`
135
135
  function constructor() {
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "babel-plugin-transform-modules-ui5",
3
- "version": "7.0.4",
3
+ "version": "7.0.6",
4
4
  "description": "An unofficial babel plugin for SAP UI5.",
5
5
  "main": "dist/index.js",
6
- "repository": "https://github.com/r-murphy/babel-plugin-ui5/tree/master/packages/plugin",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/ui5-community/babel-plugin-transform-modules-ui5.git",
9
+ "directory": "packages/plugin"
10
+ },
7
11
  "engines": {
8
12
  "node": ">=6"
9
13
  },
@@ -52,38 +56,40 @@
52
56
  ]
53
57
  },
54
58
  "dependencies": {
55
- "array-flatten": "^2.1.2",
59
+ "array-flatten": "^3.0.0",
56
60
  "doctrine": "^3.0.0",
57
61
  "ignore-case": "^0.1.0",
58
62
  "object-assign-defined": "^1.0.2"
59
63
  },
60
64
  "devDependencies": {
61
- "@babel/cli": "^7.7.4",
62
- "@babel/core": "^7.7.4",
63
- "@babel/plugin-proposal-object-rest-spread": "^7.7.4",
64
- "@babel/plugin-syntax-class-properties": "^7.7.4",
65
- "@babel/plugin-syntax-decorators": "^7.7.4",
66
- "@babel/plugin-syntax-dynamic-import": "^7.7.4",
67
- "@babel/plugin-syntax-object-rest-spread": "^7.7.4",
68
- "@babel/plugin-transform-typescript": "^7.7.4",
69
- "@babel/preset-env": "^7.7.4",
70
- "@babel/preset-flow": "^7.7.4",
71
- "@babel/preset-typescript": "^7.7.4",
65
+ "@babel/cli": "^7.21.0",
66
+ "@babel/core": "^7.21.0",
67
+ "@babel/eslint-parser": "^7.19.1",
68
+ "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
69
+ "@babel/plugin-syntax-class-properties": "^7.12.13",
70
+ "@babel/plugin-syntax-decorators": "^7.21.0",
71
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
72
+ "@babel/plugin-syntax-object-rest-spread": "^7.8.3",
73
+ "@babel/plugin-transform-typescript": "^7.21.0",
74
+ "@babel/preset-env": "^7.20.2",
75
+ "@babel/preset-flow": "^7.18.6",
76
+ "@babel/preset-typescript": "^7.21.0",
72
77
  "babel-eslint": "^10.0.3",
73
- "babel-jest": "^24.9.0",
74
- "core-js": "^3.4.7",
75
- "eslint": "^6.7.2",
76
- "eslint-config-standard": "^14.1.0",
77
- "eslint-plugin-import": "^2.18.2",
78
- "eslint-plugin-node": "^9.1.0",
79
- "eslint-plugin-prettier": "^3.1.1",
80
- "eslint-plugin-promise": "^4.2.1",
81
- "eslint-plugin-standard": "^4.0.1",
82
- "fs-extra": "^8.1.0",
83
- "husky": "^3.1.0",
84
- "jest": "^24.9.0",
85
- "lint-staged": "^9.5.0",
86
- "prettier": "^1.19.1",
87
- "rimraf": "^3.0.0"
88
- }
78
+ "babel-jest": "^29.4.3",
79
+ "core-js": "^3.28.0",
80
+ "eslint": "^8.34.0",
81
+ "eslint-config-standard": "^17.0.0",
82
+ "eslint-plugin-import": "^2.27.5",
83
+ "eslint-plugin-node": "^11.1.0",
84
+ "eslint-plugin-prettier": "^4.2.1",
85
+ "eslint-plugin-promise": "^6.1.1",
86
+ "eslint-plugin-standard": "^4.1.0",
87
+ "fs-extra": "^11.1.0",
88
+ "husky": "^8.0.3",
89
+ "jest": "^29.4.3",
90
+ "lint-staged": "^13.1.2",
91
+ "prettier": "^2.8.4",
92
+ "rimraf": "^4.1.2"
93
+ },
94
+ "gitHead": "54502a82694651b982a671b8fd5849c51caf1bdb"
89
95
  }