How and where is 'imports' defined in gnome-shell source code?

Hello guys,

I was browsing the gnome-shell source, and noticed the following code:

const ExtensionUtils = imports.misc.extensionUtils;

I was wondering where imports is defined, it seems it gets referenced a lot, but can’t seem to find where and how it is defined…

Kind regards,


It’s not surprising that you didn’t find it, as imports isn’t defined by gnome-shell at all, but by gjs itself.

Keep in mind that both gjs and gnome-shell predate ecmascript modules (i.e. import/export statements) in javascript, so gjs had to come up with its own import system.

(gjs does support standard modules nowadays, and the plan is to port to them eventually, hopefully in time for 43. But it’s a breaking change for extensions, so will need some care and communication)

Woah, this explains a lot! Thank you very much for the quick reply!

See also Legacy Imports

Very nice! Thank you as well! The pieces start to fit together :slight_smile:

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