babel-plugin-transform-modules-ui5 7.2.2 → 7.2.4

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,28 @@
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.2.4](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.2.3...v7.2.4) (2023-07-20)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * ensure template to be ES5 compliant ([#111](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/111)) ([16819bc](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/16819bc91ce1942e0968a0f7efaa4e7cf767b665))
12
+
13
+
14
+
15
+
16
+
17
+ ## [7.2.3](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.2.2...v7.2.3) (2023-07-18)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * copyright comment must be appended as leading comment to file ([#108](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/108)) ([8194671](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/81946714f1d48c82a6609ec3fc1c820e5fff9e51))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [7.2.2](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.2.1...v7.2.2) (2023-07-18)
7
29
 
8
30
 
@@ -30,7 +30,7 @@ const ClassTransformVisitor = {
30
30
  const {
31
31
  node
32
32
  } = path;
33
- const className = node === null || node === void 0 ? void 0 : (_node$id = node.id) === null || _node$id === void 0 ? void 0 : _node$id.name;
33
+ const className = node === null || node === void 0 || (_node$id = node.id) === null || _node$id === void 0 ? void 0 : _node$id.name;
34
34
  if (!className || opts.neverConvertClass) {
35
35
  return;
36
36
  }
@@ -69,7 +69,7 @@ const ClassTransformVisitor = {
69
69
  parent,
70
70
  parentPath
71
71
  } = path;
72
- const className = node === null || node === void 0 ? void 0 : (_node$id2 = node.id) === null || _node$id2 === void 0 ? void 0 : _node$id2.name;
72
+ const className = node === null || node === void 0 || (_node$id2 = node.id) === null || _node$id2 === void 0 ? void 0 : _node$id2.name;
73
73
 
74
74
  // Only if classinfo has been found we process this file
75
75
  const classInfo = (_this$classInfo = this.classInfo) === null || _this$classInfo === void 0 ? void 0 : _this$classInfo[className];
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ module.exports = () => {
39
39
 
40
40
  // Properties for Module Transform
41
41
  this.programNode = path.node;
42
- this.comments = path.parent.comments;
42
+ this.parent = path.parent;
43
43
  this.defaultExport = null;
44
44
  this.defaultExportNode = null;
45
45
  this.exportGlobal = false;
@@ -11,7 +11,7 @@ var ast = _interopRequireWildcard(require("../../utils/ast"));
11
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
13
  function wrap(visitor, programNode, opts) {
14
- var _body, _body$, _body$$leadingComment;
14
+ var _body;
15
15
  let {
16
16
  defaultExport,
17
17
  exportGlobal,
@@ -29,7 +29,7 @@ function wrap(visitor, programNode, opts) {
29
29
 
30
30
  // find the copyright comment from the original program body and remove it there
31
31
  // since it need to be put around the new program body (which is sap.ui.define)
32
- let copyright = (_body = body) === null || _body === void 0 ? void 0 : (_body$ = _body[0]) === null || _body$ === void 0 ? void 0 : (_body$$leadingComment = _body$.leadingComments) === null || _body$$leadingComment === void 0 ? void 0 : _body$$leadingComment.find((comment, idx, arr) => {
32
+ let copyright = (_body = body) === null || _body === void 0 || (_body = _body[0]) === null || _body === void 0 || (_body = _body.leadingComments) === null || _body === void 0 ? void 0 : _body.find((comment, idx, arr) => {
33
33
  if (comment.value.startsWith("!")) {
34
34
  arr.splice(idx, 1);
35
35
  return true;
@@ -40,8 +40,8 @@ function wrap(visitor, programNode, opts) {
40
40
  // is associcated with the program and not the program body, so we need to find it
41
41
  // and move it to the new program body (which is sap.ui.define)
42
42
  if (!copyright) {
43
- var _visitor$comments;
44
- copyright = (_visitor$comments = visitor.comments) === null || _visitor$comments === void 0 ? void 0 : _visitor$comments.find((comment, idx, arr) => {
43
+ var _visitor$parent;
44
+ copyright = (_visitor$parent = visitor.parent) === null || _visitor$parent === void 0 || (_visitor$parent = _visitor$parent.comments) === null || _visitor$parent === void 0 ? void 0 : _visitor$parent.find((comment, idx, arr) => {
45
45
  if (comment.value.startsWith("!")) {
46
46
  arr.splice(idx, 1);
47
47
  return true;
@@ -133,8 +133,9 @@ function wrap(visitor, programNode, opts) {
133
133
  programNode.body = [...preDefine, generateDefine(body, imports, exportGlobal || opts.exportAllGlobal)];
134
134
 
135
135
  // if a copyright comment is present we append it to the new program node
136
- if (copyright) {
137
- programNode.body[0].leadingComments = [copyright];
136
+ if (copyright && visitor.parent) {
137
+ visitor.parent.leadingComments = visitor.parent.leadingComments || [];
138
+ visitor.parent.leadingComments.unshift(copyright);
138
139
  }
139
140
  }
140
141
  function hasUseStrict(node) {
@@ -305,15 +305,15 @@ const ModuleTransformVisitor = {
305
305
  const {
306
306
  node
307
307
  } = path;
308
- if ((node === null || node === void 0 ? void 0 : (_node$object = node.object) === null || _node$object === void 0 ? void 0 : _node$object.type) === "MetaProperty") {
308
+ if ((node === null || node === void 0 || (_node$object = node.object) === null || _node$object === void 0 ? void 0 : _node$object.type) === "MetaProperty") {
309
309
  var _node$property, _node$property2;
310
310
  // replace all "import.meta.url" with "module.url"
311
- if ((node === null || node === void 0 ? void 0 : (_node$property = node.property) === null || _node$property === void 0 ? void 0 : _node$property.name) === "url") {
311
+ if ((node === null || node === void 0 || (_node$property = node.property) === null || _node$property === void 0 ? void 0 : _node$property.name) === "url") {
312
312
  path.replaceWith(_objectSpread(_objectSpread({}, node), (0, _core.template)`module.url`()));
313
313
  addModuleImport(this.imports, "module");
314
314
  }
315
315
  // replace all "import.meta.resolve(...)" with "require.toUrl(...)"
316
- else if ((node === null || node === void 0 ? void 0 : (_node$property2 = node.property) === null || _node$property2 === void 0 ? void 0 : _node$property2.name) === "resolve") {
316
+ else if ((node === null || node === void 0 || (_node$property2 = node.property) === null || _node$property2 === void 0 ? void 0 : _node$property2.name) === "resolve") {
317
317
  path.replaceWith(_objectSpread(_objectSpread({}, node), (0, _core.template)`require.toUrl`()));
318
318
  addModuleImport(this.imports, "require");
319
319
  }
@@ -155,14 +155,14 @@ const buildDefaultImportDeconstructor = (0, _core.template)(`
155
155
  exports.buildDefaultImportDeconstructor = buildDefaultImportDeconstructor;
156
156
  const buildDynamicImportHelper = (0, _core.template)(`
157
157
  function __ui5_require_async(path) {
158
- return new Promise((resolve, reject) => {
159
- sap.ui.require([path], (module) => {
158
+ return new Promise(function(resolve, reject) {
159
+ sap.ui.require([path], function(module) {
160
160
  if (!(module && module.__esModule)) {
161
161
  module = module === null || !(typeof module === "object" && path.endsWith("/library")) ? { default: module } : module;
162
162
  Object.defineProperty(module, "__esModule", { value: true });
163
163
  }
164
164
  resolve(module);
165
- }, (err) => {
165
+ }, function(err) {
166
166
  reject(err);
167
167
  });
168
168
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-transform-modules-ui5",
3
- "version": "7.2.2",
3
+ "version": "7.2.4",
4
4
  "description": "An unofficial babel plugin for SAP UI5.",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -63,36 +63,36 @@
63
63
  "object-assign-defined": "^1.0.2"
64
64
  },
65
65
  "devDependencies": {
66
- "@babel/cli": "^7.21.5",
67
- "@babel/core": "^7.22.1",
68
- "@babel/eslint-parser": "^7.21.8",
69
- "@babel/plugin-proposal-decorators": "^7.22.3",
66
+ "@babel/cli": "^7.22.9",
67
+ "@babel/core": "^7.22.9",
68
+ "@babel/eslint-parser": "^7.22.9",
69
+ "@babel/plugin-proposal-decorators": "^7.22.7",
70
70
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
71
71
  "@babel/plugin-syntax-class-properties": "^7.12.13",
72
- "@babel/plugin-syntax-decorators": "^7.22.3",
72
+ "@babel/plugin-syntax-decorators": "^7.22.5",
73
73
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
74
74
  "@babel/plugin-syntax-object-rest-spread": "^7.8.3",
75
- "@babel/plugin-transform-property-mutators": "^7.20.7",
76
- "@babel/plugin-transform-typescript": "^7.22.3",
77
- "@babel/preset-env": "^7.22.2",
78
- "@babel/preset-flow": "^7.21.4",
79
- "@babel/preset-typescript": "^7.21.5",
75
+ "@babel/plugin-transform-property-mutators": "^7.22.5",
76
+ "@babel/plugin-transform-typescript": "^7.22.9",
77
+ "@babel/preset-env": "^7.22.9",
78
+ "@babel/preset-flow": "^7.22.5",
79
+ "@babel/preset-typescript": "^7.22.5",
80
80
  "babel-eslint": "^10.0.3",
81
- "babel-jest": "^29.5.0",
82
- "core-js": "^3.30.2",
83
- "eslint": "^8.41.0",
84
- "eslint-config-standard": "^17.0.0",
81
+ "babel-jest": "^29.6.1",
82
+ "core-js": "^3.31.1",
83
+ "eslint": "^8.45.0",
84
+ "eslint-config-standard": "^17.1.0",
85
85
  "eslint-plugin-import": "^2.27.5",
86
86
  "eslint-plugin-node": "^11.1.0",
87
- "eslint-plugin-prettier": "^4.2.1",
87
+ "eslint-plugin-prettier": "^5.0.0",
88
88
  "eslint-plugin-promise": "^6.1.1",
89
89
  "eslint-plugin-standard": "^4.1.0",
90
90
  "fs-extra": "^11.1.1",
91
91
  "husky": "^8.0.3",
92
- "jest": "^29.5.0",
93
- "lint-staged": "^13.2.2",
94
- "prettier": "^2.8.8",
92
+ "jest": "^29.6.1",
93
+ "lint-staged": "^13.2.3",
94
+ "prettier": "^3.0.0",
95
95
  "rimraf": "^5.0.1"
96
96
  },
97
- "gitHead": "744a18300e56c98edbf88c7528c17c2e6134bd63"
97
+ "gitHead": "57a9c2365de4c2ba507905a778ef473de06afa0a"
98
98
  }