Using ES6 modules in KWin Scripts

Mikhail Zolotukhin mail at genda.life
Sun Aug 29 13:33:01 BST 2021


Hello,

I want to develop a KWin Script using QML and TypeScript. Unfotunately I cannot get it to work, so that it can use the feature intoduced in ES6 standard - modules. To test this with minimal working example I did the following: I created main.qml with the following content:

```import QtQuick 2.0
import "../code/script.js" as K

Item {
    id: scriptRoot
    Component.onCompleted: {
        console.log("Starting the script");
        K.main();
    }
}

```

Also I have two javascript files: script.js:

```import modu from "./mod";

function main() {
  console.log("Hello from main script!");
  modu();
}

```

mod.js:

```export default function modu() {
  console.log("Hello from module!");
}
```
Unfortunately, I cannot get this setup to work. In KWin logs, I have nothing (No string is printed). However, if I remove the js import from QML, at least the "Starting the script" is printed.

>From what I understand, QML Javascript Engine should support modules (and ES7) according to the documentation:

> The QML runtime implements the 7th edition of the standard

I would like to ask a help from the experts of KWin: is this a KWin scripting limitation? Why no logs are printed at all? What can I do to create a KWin script with ES6 modules?
 
Best Regards,
Mikhail Zolotukhin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-devel/attachments/20210829/67bc47ac/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: publickey - mail at genda.life - 0x2B64AF62.asc
Type: application/pgp-keys
Size: 717 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-devel/attachments/20210829/67bc47ac/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/kde-devel/attachments/20210829/67bc47ac/attachment.sig>


More information about the kde-devel mailing list