-
Notifications
You must be signed in to change notification settings - Fork 5
Description
The GJS GI implementation allows users to access GI libraries like the following:
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;Similarly, in Python GI libraries are imported using:
from gi.repository import GObject;
from gi.repository import Gtk;In NodeJS we could achieve something similar using an ES6 Proxy object.
module.exports = new Proxy({}, {
get: function(target, property, receiver) {
return load(property);
});this would allow users to import GI libraries in NodeJS using the following:
# common JS
const { GObject, Gtk } = require('node-gir');
# es6 import
import { GObject, Gtk } from 'node-gir';and obviously we'd still allow users to require the load() function that node-gir currently exports so that they can import specific versions of GI libraries.
Using a Proxy would mean the library would have a minimum NodeJS version of 6.4 (when Proxy was introduced to node). I think this is acceptable as the previous LTS, version 4, is very old now and 6 is the following LTS version. It is likely that node-gir won't work on node versions before 6 anyway due to v8 API breakages. CI currently tests against version 6,8,9.
Thoughts