diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml
index e72cd31e1..e223ee128 100644
--- a/js/js-resources.gresource.xml
+++ b/js/js-resources.gresource.xml
@@ -75,6 +75,7 @@
ui/keyboard.js
ui/layout.js
ui/lightbox.js
+ ui/listModes.js
ui/locatePointer.js
ui/lookingGlass.js
ui/magnifier.js
diff --git a/js/ui/listModes.js b/js/ui/listModes.js
new file mode 100644
index 000000000..986f977f4
--- /dev/null
+++ b/js/ui/listModes.js
@@ -0,0 +1,5 @@
+import './environment.js';
+
+import {listModes} from './sessionMode.js';
+
+listModes();
diff --git a/src/main.c b/src/main.c
index a19c452a2..97b9d24c0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -489,8 +489,7 @@ list_modes (const char *option_name,
{
ShellGlobal *global;
GjsContext *context;
- const char *script;
- int status;
+ uint8_t status;
/* Many of our imports require global to be set, so rather than
* tayloring our imports carefully here to avoid that dependency,
@@ -503,9 +502,10 @@ list_modes (const char *option_name,
shell_introspection_init ();
- script = "imports.ui.environment.init();"
- "imports.ui.sessionMode.listModes();";
- if (!gjs_context_eval (context, script, -1, "", &status, NULL))
+ if (!gjs_context_eval_module_file (context,
+ "resource:///org/gnome/shell/ui/listModes.js",
+ &status,
+ NULL))
g_message ("Retrieving list of available modes failed.");
g_object_unref (context);