A require like function for GJS
npm install gjs-require``sh
$ ./gjs-require test/index.js
gjs-require/test/index.js
gjs-require/test/ran/dom.js
random: 0.212101615295042
true
`
* automatically provides __dirname and __filename variables (top level onyl)module
* automatically provides and exports (top level onyl).
* simplifies imports through GJS resolving absolutes and relative paths (note: module should start with either or /)GLib
* usable to also require , Gio.File or any other gi namespace
You can either use gjs-require as executable, and pass along one or more files, or you can use it as gjs argument itself, and still pass along files to require, giving you the chance to configure gjs flags too.
Last, but not least, you can const {require} = imports.require assuming the gjs-require folder is part of import.searchPath.
`shvia terminal
curl -LO https://webreflection.github.io/gjs-require
chmod a+x gjs-require
./gjs-require file.js