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

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.3](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.2.2...v7.2.3) (2023-07-18)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * 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))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [7.2.2](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.2.1...v7.2.2) (2023-07-18)
7
18
 
8
19
 
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;
@@ -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, _visitor$parent$comme;
44
+ copyright = (_visitor$parent = visitor.parent) === null || _visitor$parent === void 0 ? void 0 : (_visitor$parent$comme = _visitor$parent.comments) === null || _visitor$parent$comme === void 0 ? void 0 : _visitor$parent$comme.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) {
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.3",
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": "744a18300e56c98edbf88c7528c17c2e6134bd63"
97
+ "gitHead": "bfdb0979de1cbaeff7c4d373761f261de469d376"
98
98
  }