Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to import this specific javascript library in a QML project?
Forum Updated to NodeBB v4.3 + New Features

How to import this specific javascript library in a QML project?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 193 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DeutschBahn
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved