How to import this specific javascript library in a QML project?
-
Hello,
I would like to utilize the Prettier code formatting API: https://github.com/prettier/prettier but I am having difficulties with importing it properly.
There is a standalone version which is not reliant on Node to function: https://prettier.io/docs/en/browser.html#global but I am getting many errors when importing it.
I first realized that the code seems to be incompatible with the currently supported ECMA version in QT 6 (which seems to be ECMA 7th Edition as mentioned here: https://doc.qt.io/qt-6/qtqml-javascript-hostenvironment.html) so I transpiled the code with Babel and attempted to import the standalone.js file with the following method:
import "./lib/standalone/standalone.js" as Prettier
Now when attempting to use the .format function as specified in the API, I get an error that the function is not available on the imported object. When looking at the Prettier object in the debugger I can see that there is indeed no format function but also that any of the properties exported in module.exports are also not available.
Would anyone know how I can properly import this project?
I am using QT Creator with QT version 6.4.0