babel-plugin-transform-modules-ui5 7.2.0 → 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 +23 -0
- package/dist/classes/visitor.js +9 -11
- package/dist/index.js +1 -0
- package/dist/modules/helpers/wrapper.js +16 -2
- package/dist/modules/visitor.js +29 -0
- package/package.json +2 -2
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.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
|
+
|
|
17
|
+
## [7.2.1](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.2.0...v7.2.1) (2023-06-13)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* add support for import.meta.url|resolve ([#106](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/106)) ([afb1e6d](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/afb1e6daa0fcc9896fd184ac9d66990d0a29214a)), closes [#103](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/103)
|
|
23
|
+
* support for anonymous classes ([#105](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/105)) ([64773d1](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/64773d180bf65e544806b9f04b7334cd76831b3d)), closes [#104](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/104)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
# [7.2.0](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.1.5...v7.2.0) (2023-05-30)
|
|
7
30
|
|
|
8
31
|
|
package/dist/classes/visitor.js
CHANGED
|
@@ -26,14 +26,12 @@ const ClassTransformVisitor = {
|
|
|
26
26
|
file,
|
|
27
27
|
opts = {}
|
|
28
28
|
}) {
|
|
29
|
-
var _node$decorators;
|
|
29
|
+
var _node$id, _node$decorators;
|
|
30
30
|
const {
|
|
31
31
|
node
|
|
32
32
|
} = path;
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
} = node.id;
|
|
36
|
-
if (opts.neverConvertClass) {
|
|
33
|
+
const className = node === null || node === void 0 ? void 0 : (_node$id = node.id) === null || _node$id === void 0 ? void 0 : _node$id.name;
|
|
34
|
+
if (!className || opts.neverConvertClass) {
|
|
37
35
|
return;
|
|
38
36
|
}
|
|
39
37
|
if (!doesClassExtendFromImport(node, [...this.importNames])) {
|
|
@@ -56,22 +54,22 @@ const ClassTransformVisitor = {
|
|
|
56
54
|
// Save super class name for converting super calls
|
|
57
55
|
this.superClassName = classInfo.superClassName;
|
|
58
56
|
// store the classinfo
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
if (className) {
|
|
58
|
+
this.classInfo = this.classInfo || {};
|
|
59
|
+
this.classInfo[className] = classInfo;
|
|
60
|
+
}
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
exit(path, {
|
|
64
64
|
opts = {}
|
|
65
65
|
}) {
|
|
66
|
-
var _this$classInfo;
|
|
66
|
+
var _node$id2, _this$classInfo;
|
|
67
67
|
const {
|
|
68
68
|
node,
|
|
69
69
|
parent,
|
|
70
70
|
parentPath
|
|
71
71
|
} = path;
|
|
72
|
-
const
|
|
73
|
-
name: className
|
|
74
|
-
} = node.id;
|
|
72
|
+
const className = node === null || node === void 0 ? void 0 : (_node$id2 = node.id) === null || _node$id2 === void 0 ? void 0 : _node$id2.name;
|
|
75
73
|
|
|
76
74
|
// Only if classinfo has been found we process this file
|
|
77
75
|
const classInfo = (_this$classInfo = this.classInfo) === null || _this$classInfo === void 0 ? void 0 : _this$classInfo[className];
|
package/dist/index.js
CHANGED
|
@@ -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
|
-
|
|
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/dist/modules/visitor.js
CHANGED
|
@@ -21,6 +21,16 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
21
21
|
const tempModuleName = name => `__${name}`;
|
|
22
22
|
const cleanImportSource = src => src.replace(/(\/)|(-)|(@)/g, "_").replace(/\./g, "");
|
|
23
23
|
const hasGlobalExportFlag = node => (0, _jsdoc.hasJsdocGlobalExportFlag)(node);
|
|
24
|
+
const addModuleImport = (imports, name) => {
|
|
25
|
+
const existingImport = imports.find(imp => imp.src === name);
|
|
26
|
+
if (!existingImport) {
|
|
27
|
+
imports.unshift({
|
|
28
|
+
src: name,
|
|
29
|
+
name: name,
|
|
30
|
+
tmpName: name
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
24
34
|
const ModuleTransformVisitor = {
|
|
25
35
|
/*!
|
|
26
36
|
* Removes the ES6 import and adds the details to the import array in our state.
|
|
@@ -289,6 +299,25 @@ const ModuleTransformVisitor = {
|
|
|
289
299
|
callee: _core.types.identifier("__ui5_require_async")
|
|
290
300
|
}));
|
|
291
301
|
}
|
|
302
|
+
},
|
|
303
|
+
MemberExpression(path) {
|
|
304
|
+
var _node$object;
|
|
305
|
+
const {
|
|
306
|
+
node
|
|
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") {
|
|
309
|
+
var _node$property, _node$property2;
|
|
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") {
|
|
312
|
+
path.replaceWith(_objectSpread(_objectSpread({}, node), (0, _core.template)`module.url`()));
|
|
313
|
+
addModuleImport(this.imports, "module");
|
|
314
|
+
}
|
|
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") {
|
|
317
|
+
path.replaceWith(_objectSpread(_objectSpread({}, node), (0, _core.template)`require.toUrl`()));
|
|
318
|
+
addModuleImport(this.imports, "require");
|
|
319
|
+
}
|
|
320
|
+
}
|
|
292
321
|
}
|
|
293
322
|
};
|
|
294
323
|
exports.ModuleTransformVisitor = ModuleTransformVisitor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-transform-modules-ui5",
|
|
3
|
-
"version": "7.2.
|
|
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": "
|
|
97
|
+
"gitHead": "744a18300e56c98edbf88c7528c17c2e6134bd63"
|
|
98
98
|
}
|