Improve importing when using ES modules
Importing modules from GI can be quite verbose repetitive and prone to errors as each gi module is exported on-demand with a temporary module that exports as default only one gi namespace.
So we need to do:
import Gtk from 'gi://Gtk';
import Gdk from 'gi://Gdk';
import Foo from 'gi://Foo';
import FooBar from `gi://Foo`; // oh, duplicate name but it's not clear.
Ideally it would be nice to be able to do:
/* 1) */ import {GLib, GObject, Foo as Bar, 'Gtk-3.0' as Gtk3, Gtk_40 as Gtk4} from 'gi'; // or another uri as gi://repository
/* 2) */ import {Window} from `gi://Gtk`; // Probably hard to implement as would require lots of initialization
/* 3) */ import gi from gi;
/* 4) */ const { Gdk } = gi; // also nice to have, or maybe using something like `gi.modules`
All this keeping compatibility with the current import Foo from 'gi://Foo'
and import Foo from 'gi://Foo?version=1.0'
syntax.
A current possible implementation is done in !815 (closed) but it should probably be tuned so that we have another internal gi method to require modules without pre-loading them and taking care of gi.versions
;
Edited by Marco Trevisan