babel-plugin-transform-modules-ui5 7.4.1 → 7.4.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 +11 -0
- package/dist/modules/visitor.js +17 -1
- package/package.json +2 -2
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.4.2](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.4.1...v7.4.2) (2024-06-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* remove mandatory ESM file extensions from sap.ui.define imports ([#129](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/129)) ([571dfa1](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/571dfa192984c9838c573909546b42a85b71e5b6))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [7.4.1](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.4.0...v7.4.1) (2024-06-02)
|
|
7
18
|
|
|
8
19
|
|
package/dist/modules/visitor.js
CHANGED
|
@@ -43,7 +43,23 @@ const addImport = (imports, imp, filename, first) => {
|
|
|
43
43
|
// (the require/define of UI5 always adds the file extension ".js" to the module name)
|
|
44
44
|
if (/^(?:(@[^/]+)\/)?([^/]+)\/(.*)\.js$/.test(imp.src)) {
|
|
45
45
|
try {
|
|
46
|
-
|
|
46
|
+
let modulePath;
|
|
47
|
+
let absModuleSrc = imp.src;
|
|
48
|
+
// if the module has a relative path, resolve it to an absolute path
|
|
49
|
+
// and verify if the file exists, if not, try to resolve it as a module
|
|
50
|
+
if (/^\.\.?\//.test(absModuleSrc)) {
|
|
51
|
+
absModuleSrc = (0, _path.resolve)((0, _path.dirname)(filename), absModuleSrc);
|
|
52
|
+
// handle the fallback of module names introduced with Node 20.0.0
|
|
53
|
+
[".js", ".jsx", ".ts", ".tsx"].some(ext => {
|
|
54
|
+
if ((0, _fs.existsSync)(absModuleSrc.replace(/\.js$/, ext))) {
|
|
55
|
+
modulePath = imp.src;
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
modulePath = require.resolve(absModuleSrc);
|
|
61
|
+
}
|
|
62
|
+
// detect removal of file extension and log a hint
|
|
47
63
|
if (modulePath.endsWith(imp.src.split("/").pop())) {
|
|
48
64
|
console.log(`\x1b[33mHint:\x1b[0m Removed file extension for dependency "\x1b[34m${imp.src}\x1b[0m" found in \x1b[90m${filename}\x1b[0m`);
|
|
49
65
|
imp.src = imp.src.slice(0, -3);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-transform-modules-ui5",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.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": "^3.1.0",
|
|
95
95
|
"rimraf": "^5.0.5"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "840510e9de26aa1e17946cf0f3a2b6395089e7e1"
|
|
98
98
|
}
|