babel-plugin-transform-modules-ui5
babel-plugin-transform-modules-ui5 copied to clipboard
autoConvertControllerClass=true -> consider .controller.ts files
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
Hi everyone,
I have created pull request #140.
Oliver
Fix is includes in version 7.7.1