babel-plugin-transform-modules-ui5 7.3.1 → 7.4.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 CHANGED
@@ -3,6 +3,33 @@
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.1](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.4.0...v7.4.1) (2024-06-02)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * ensure to remove file ext .js only from module path ([#127](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/127)) ([c6afb92](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/c6afb92c2f758a245086baa6f77d3274bb4e5466))
12
+
13
+
14
+
15
+
16
+
17
+ # [7.4.0](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.3.1...v7.4.0) (2024-05-31)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * remove empty export declaration added by TypeScript ([3cb14cf](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/3cb14cf7aefd400d0191d364f457c66452edc32a)), closes [/github.com/babel/babel/blob/main/packages/babel-plugin-transform-typescript/src/index.ts#L399](https://github.com//github.com/babel/babel/blob/main/packages/babel-plugin-transform-typescript/src/index.ts/issues/L399)
23
+
24
+
25
+ ### Features
26
+
27
+ * imports added by other plugins are also included in the sap.ui.define calls ([#126](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/126)) ([895fe62](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/895fe624df66a6db1b9daa5cadce8a984ced5af4))
28
+
29
+
30
+
31
+
32
+
6
33
  ## [7.3.1](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.3.0...v7.3.1) (2024-05-12)
7
34
 
8
35
 
package/dist/index.js CHANGED
@@ -59,6 +59,9 @@ module.exports = () => {
59
59
  exit(path, {
60
60
  opts
61
61
  }) {
62
+ path.traverse({
63
+ ImportDeclaration: _visitor2.ModuleTransformVisitor.ImportDeclaration
64
+ }, this);
62
65
  (0, _wrapper.wrap)(this, path.node, opts);
63
66
  }
64
67
  }
@@ -22,7 +22,16 @@ function wrap(visitor, programNode, opts) {
22
22
  injectDynamicImportHelper
23
23
  } = visitor;
24
24
  const needsWrap = !!(defaultExport || imports.length || namedExports.length || injectDynamicImportHelper);
25
- if (!needsWrap) return;
25
+ if (!needsWrap) {
26
+ // cleanup the program node if it's empty (just having empty imports)
27
+ programNode.body = programNode.body.filter(node => {
28
+ if (_core.types.isExportNamedDeclaration(node)) {
29
+ return node.declaration != null;
30
+ }
31
+ return true;
32
+ });
33
+ return;
34
+ }
26
35
  let {
27
36
  body
28
37
  } = programNode;
@@ -37,11 +37,11 @@ const hasGlobalExportFlag = node => (0, _jsdoc.hasJsdocGlobalExportFlag)(node);
37
37
  const addImport = (imports, imp, filename, first) => {
38
38
  const existingImport = imports.find(i => i.src === imp.src);
39
39
  if (!existingImport) {
40
- // if a module ends with the file extension ".js" and it can be resolved to
40
+ // if a module path ends with the file extension ".js" and it can be resolved to
41
41
  // a local file having also the file extension ".js" and not ".js.js" then
42
42
  // we need to slice the file extension to avoid redundant file extension
43
43
  // (the require/define of UI5 always adds the file extension ".js" to the module name)
44
- if (imp.src.indexOf(".js") != -1) {
44
+ if (/^(?:(@[^/]+)\/)?([^/]+)\/(.*)\.js$/.test(imp.src)) {
45
45
  try {
46
46
  const modulePath = require.resolve(imp.src);
47
47
  if (modulePath.endsWith(imp.src.split("/").pop())) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-transform-modules-ui5",
3
- "version": "7.3.1",
3
+ "version": "7.4.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": "^3.1.0",
95
95
  "rimraf": "^5.0.5"
96
96
  },
97
- "gitHead": "aaa2b6503de89f673191f11f84879996b5b5936a"
97
+ "gitHead": "9c9165b630703bc760131df1277f258468c809ea"
98
98
  }