babel-plugin-transform-modules-ui5 icon indicating copy to clipboard operation
babel-plugin-transform-modules-ui5 copied to clipboard

autoConvertControllerClass=true -> consider .controller.ts files

Open oliversviszt opened this issue 7 months ago • 1 comments

Hello,

The option autoConvertControllerClass is implemented in: function shouldConvertClass(file, node, opts, classInfo) { ... if (/.*[.]controller[.]js$/.test(file.opts.filename) && opts.autoConvertControllerClass !== false) { return true; } ... return false; }

Which is in line with the documentation: "Converts the classes in a .controller.js file by default, if it extends from an imported class."

However, if developing UI5 in TypeScript, file.opts.filename is the .ts file that is currently being transpiled by Babel, so the above regex will not match because of the extension.

I am using the following .babelrc: ` { "sourceRoot": "webapp/", "presets": [ [ "@babel/preset-env", { "targets": { "chrome": "134" }, "modules": false } ], [ "transform-ui5", { "namespacePrefix": "com.whatever.something", "autoConvertControllerClass": true } ], [ "@babel/preset-typescript", {

        }
    ]
],
"sourceMaps": true

} `

Would suggest to change the regex to if (/.*[.]controller[.](js|ts)$/.test(file.opts.filename) ...

Cheers, Oliver

oliversviszt avatar Mar 31 '25 20:03 oliversviszt

Hi everyone,

I have created pull request #140.

Oliver

oliversviszt avatar Apr 12 '25 06:04 oliversviszt

Fix is includes in version 7.7.1

petermuessig avatar May 13 '25 07:05 petermuessig