gjs.guide recommends writing GJS import statements like this:
const Gtk = imports.gi.Gtk;
while most actual code that I see, and also the built-in Gnome Builder templates have this:
import Gtk from 'gi://Gtk';
What's the difference between the two? When should I prefer one over the other?
After bumming around in the gjs repository for a while I've stumbled upon this file: doc/ESModules.md
In it they refer to "imports" as the legacy way of importing modules. From what I understood from that document:
importspredatesimport(it was a way of describing modules in GJS before ES actually had modules)importsgives you allvars from the module, whileimportonly gives you things that were explicitly exported with theexportkeyword;importshould be preferred for new code.