babel-plugin-transform-modules-ui5 7.2.0 → 7.2.1
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 +12 -0
- package/dist/classes/visitor.js +9 -11
- package/dist/modules/visitor.js +29 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.1](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.2.0...v7.2.1) (2023-06-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* 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)
|
|
12
|
+
* 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)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
# [7.2.0](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.1.5...v7.2.0) (2023-05-30)
|
|
7
19
|
|
|
8
20
|
|
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/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.1",
|
|
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": "c2412968863ebeddb8c7c8cc26794759dc83c37b"
|
|
98
98
|
}
|