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

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,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.2.2](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.2.1...v7.2.2) (2023-07-18)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * ensure copyright to be kept after typescript processing ([#107](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/107)) ([da9aa69](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/da9aa69c94017e085d7f5a22abde04b123d9307d))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [7.2.1](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.2.0...v7.2.1) (2023-06-13)
7
18
 
8
19
 
package/dist/index.js CHANGED
@@ -39,6 +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
43
  this.defaultExport = null;
43
44
  this.defaultExportNode = null;
44
45
  this.exportGlobal = false;
@@ -27,13 +27,27 @@ function wrap(visitor, programNode, opts) {
27
27
  body
28
28
  } = programNode;
29
29
 
30
- // find the copyright comment from the original program body
31
- const 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) => {
30
+ // find the copyright comment from the original program body and remove it there
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
33
  if (comment.value.startsWith("!")) {
33
34
  arr.splice(idx, 1);
34
35
  return true;
35
36
  }
36
37
  });
38
+
39
+ // in case of TypeScript transpiling taking place upfront, the copyright comment
40
+ // is associcated with the program and not the program body, so we need to find it
41
+ // and move it to the new program body (which is sap.ui.define)
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) => {
45
+ if (comment.value.startsWith("!")) {
46
+ arr.splice(idx, 1);
47
+ return true;
48
+ }
49
+ });
50
+ }
37
51
  let allExportHelperAdded = false;
38
52
  let extendAdded = false;
39
53
  opts.collapse = !opts.noExportCollapse;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-transform-modules-ui5",
3
- "version": "7.2.1",
3
+ "version": "7.2.2",
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": "^2.8.8",
95
95
  "rimraf": "^5.0.1"
96
96
  },
97
- "gitHead": "c2412968863ebeddb8c7c8cc26794759dc83c37b"
97
+ "gitHead": "744a18300e56c98edbf88c7528c17c2e6134bd63"
98
98
  }