CJS/ESM Libary in GJS?

Hi Gnome Community,

I want to develop a little GTK4 Application with gjs and need to use this libary. I tried to figure it our for my self how to integreate this libary in my application but for the last two days I wasn’t able to wrap my head around it.
Could anyone provide me a foolproof tutorial?

Could anyone provide me a foolproof tutorial?

No. A node library can only be used in gjs if it doesn’t use any node-specific APIs, either directly or indirectly. I’m afraid there’s no way around that, foolproof or otherwise.

There are some pointers in a presentation that I gave a few years ago: https://ptomato.name/talks/las2021/#26

If you can build a bundle with browserify, that will sometimes successfully replace the Node APIs. No guarantee though.

I wrote a bit about this here MQTT module for gjs?

Thanks for all your fast answers. I think I will drop this project because I currently haven’t enough knowledge to understand javascript.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.