[gnome-maps/wip/mlundblad/es6-modules] WIP: port to ES6 modules




commit 68c05def513e58beb7b4592730843eef2ed25c7c
Author: Marcus Lundblad <ml dfupdate se>
Date:   Tue May 3 00:02:54 2022 +0200

    WIP: port to ES6 modules

 src/address.js                          |   2 +-
 src/application.js                      | 106 +++++-----
 src/boundingBox.js                      |   4 +-
 src/color.js                            |   8 +-
 src/constants.js                        |   8 +-
 src/contactPlace.js                     |  15 +-
 src/contextMenu.js                      |  86 ++++----
 src/favoritesPopover.js                 |  50 ++---
 src/geoclue.js                          |  53 ++---
 src/geocode.js                          |  10 +-
 src/gpxShapeLayer.js                    |  40 ++--
 src/graphHopperGeocode.js               |  16 +-
 src/headerBar.js                        |  46 +++--
 src/http.js                             |   6 +-
 src/layersPopover.js                    |  82 ++++----
 src/location.js                         |  15 +-
 src/main.js                             |  44 ++--
 src/mainWindow.js                       |  76 +++----
 src/mapBubble.js                        |  46 +++--
 src/mapMarker.js                        |  78 +++----
 src/mapView.js                          | 273 ++++++++++++------------
 src/mapWalker.js                        |  50 ++---
 src/org.gnome.Maps.in                   |  14 +-
 src/org.gnome.Maps.src.gresource.xml.in |  12 ++
 src/osmAccountDialog.js                 |  42 ++--
 src/osmConnection.js                    |  84 ++++----
 src/osmEdit.js                          |  18 +-
 src/osmEditDialog.js                    | 129 ++++++------
 src/osmNames.js                         |   6 +-
 src/osmTypeListRow.js                   |  20 +-
 src/osmTypePopover.js                   |  38 ++--
 src/osmTypeSearchEntry.js               |  24 ++-
 src/osmUtils.js                         |   4 +-
 src/overpass.js                         |  44 ++--
 src/photonGeocode.js                    |  16 +-
 src/photonParser.js                     |  12 +-
 src/place.js                            |  33 +--
 src/placeButtons.js                     |  66 +++---
 src/placeFormatter.js                   |  14 +-
 src/placeIcons.js                       |   2 +-
 src/placeListRow.js                     |  40 ++--
 src/placeStore.js                       |  65 +++---
 src/placeView.js                        |  72 +++----
 src/placeViewImage.js                   |  19 +-
 src/placeZoom.js                        |   2 +-
 src/route.js                            |  32 +--
 src/routeQuery.js                       | 134 ++++++------
 src/searchPopover.js                    |  20 +-
 src/sendToDialog.js                     |  98 ++++-----
 src/shapeLayer.js                       |  47 +++--
 src/storedRoute.js                      | 111 +++++-----
 src/time.js                             |  15 +-
 src/transitOptions.js                   |  34 +--
 src/translations.js                     |  22 +-
 src/turnPointMarker.js                  |  41 ++--
 src/uris.js                             |  16 +-
 src/utils.js                            | 106 +++++-----
 src/wikipedia.js                        |  20 +-
 src/zoomInDialog.js                     |  24 ++-
 tests/addressTest.js                    |   8 +-
 tests/boundingBoxTest.js                |  52 ++---
 tests/colorTest.js                      |  14 +-
 tests/meson.build                       |  31 ++-
 tests/osmNamesTest.js                   |  34 +--
 tests/placeIconsTest.js                 |  10 +-
 tests/placeZoomTest.js                  |  35 ++--
 tests/test.in                           |  16 +-
 tests/timeTest.js                       |  18 +-
 tests/translationsTest.js               | 355 ++++++++++++++++----------------
 tests/urisTest.js                       |  18 +-
 tests/utilsTest.js                      |  56 ++---
 tests/wikipediaTest.js                  |  34 ++-
 72 files changed, 1710 insertions(+), 1581 deletions(-)
---
diff --git a/src/address.js b/src/address.js
index 0d171840..84af3a89 100644
--- a/src/address.js
+++ b/src/address.js
@@ -121,7 +121,7 @@ const FORMAT_MAP = {
     'VN': 'số %2$s %1$s'
 }
 
-function streetAddressForCountryCode(streetName, housenumber, countryCode) {
+export function streetAddressForCountryCode(streetName, housenumber, countryCode) {
     let format = FORMAT_MAP[countryCode];
 
     if (format)
diff --git a/src/application.js b/src/application.js
index 385061d5..2092f0d9 100644
--- a/src/application.js
+++ b/src/application.js
@@ -20,21 +20,21 @@
  *         Zeeshan Ali (Khattak) <zeeshanak gnome org>
  */
 
-const GLib = imports.gi.GLib;
-const GObject = imports.gi.GObject;
-const Geocode = imports.gi.GeocodeGlib;
-const Gio = imports.gi.Gio;
-const Gtk = imports.gi.Gtk;
-const GtkClutter = imports.gi.GtkClutter;
-const Hdy = imports.gi.Handy;
-
-const ContactPlace = imports.contactPlace;
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
+import Geocode from 'gi://GeocodeGlib';
+import Gio from 'gi://Gio';
+import Gtk from 'gi://Gtk';
+import GtkClutter from 'gi://GtkClutter';
+import Hdy from 'gi://Handy';
+
+import {ContactPlace} from './contactPlace.js';
 const Format = imports.format;
-const Geoclue = imports.geoclue;
-const GeocodeFactory = imports.geocode;
-const MainWindow = imports.mainWindow;
-const Maps = imports.gi.GnomeMaps;
-const OSMEdit = imports.osmEdit;
+import {Geoclue} from './geoclue.js';
+import * as GeocodeFactory from './geocode.js';
+import {MainWindow} from './mainWindow.js';
+import Maps from 'gi://GnomeMaps';
+import * as OSMEdit from './osmEdit.js';
 const OSMTypeSearchEntry = imports.osmTypeSearchEntry;
 const PlaceStore = imports.placeStore;
 const RoutingDelegator = imports.routingDelegator;
@@ -43,45 +43,31 @@ const Settings = imports.settings;
 const Utils = imports.utils;
 const URIS = imports.uris;
 
-// used globally
-var application = null;
-var settings = null;
-var placeStore = null;
-var routingDelegator = null;
-var geoclue = null;
-var contactStore = null;
-var osmEdit = null;
-var normalStartup = true;
-var routeQuery = null;
-
 const _ensuredTypes = [OSMTypeSearchEntry.OSMTypeSearchEntry];
 
-var Application = GObject.registerClass({
-    Properties: {
-        'selected-place': GObject.ParamSpec.object('selected-place',
-                                                   'Selected Place',
-                                                   'The selected place',
-                                                   GObject.ParamFlags.READABLE |
-                                                   GObject.ParamFlags.WRITABLE,
-                                                   Geocode.Place),
-        'adaptive-mode': GObject.ParamSpec.boolean('adaptive-mode',
-                                                   'Adaptive Move',
-                                                   'Whether the main window is in adaptive (narrow) mode',
-                                                   GObject.ParamFlags.READABLE |
-                                                   GObject.ParamFlags.WRITABLE),
-    },
-}, class Application extends Gtk.Application {
+export class Application extends Gtk.Application {
+
+    // used globally
+    static application = null;
+    static settings = null;
+    static placeStore = null;
+    static routingDelegator = null;
+    static geoclue = null;
+    static contactStore = null;
+    static osmEdit = null;
+    static normalStartup = true;
+    static routeQuery = null;
 
-    _init() {
+    constructor() {
         /* Translators: This is the program name. */
         GLib.set_application_name(_("Maps"));
 
         /* Needed to be able to use in UI files */
         _ensuredTypes.forEach((type) => GObject.type_ensure(type));
 
-        super._init({ application_id: pkg.name,
-                      flags: Gio.ApplicationFlags.HANDLES_OPEN |
-                             Gio.ApplicationFlags.HANDLES_COMMAND_LINE });
+        super({ application_id: pkg.name,
+                flags: Gio.ApplicationFlags.HANDLES_OPEN |
+                       Gio.ApplicationFlags.HANDLES_COMMAND_LINE });
 
         this.add_main_option('local',
                              0,
@@ -196,7 +182,7 @@ var Application = GObject.registerClass({
     }
 
     _initPlaceStore() {
-        placeStore = new PlaceStore.PlaceStore({
+        Application.placeStore = new PlaceStore({
             recentPlacesLimit: settings.get('recent-places-limit'),
             recentRoutesLimit: settings.get('recent-routes-limit')
         });
@@ -256,13 +242,13 @@ var Application = GObject.registerClass({
     }
 
     _initServices() {
-        settings         = Settings.getSettings('org.gnome.Maps');
-        routeQuery       = new RouteQuery.RouteQuery();
-        routingDelegator = new RoutingDelegator.RoutingDelegator({ query: routeQuery });
-        geoclue          = new Geoclue.Geoclue();
-        contactStore = new Maps.ContactStore();
+        Application.settings         = Settings.getSettings('org.gnome.Maps');
+        Application.routeQuery       = new RouteQuery();
+        Application.routingDelegator = new RoutingDelegator({ query: routeQuery });
+        Application.geoclue          = new Geoclue();
+        Application.contactStore = new GnomeMaps.ContactStore();
         contactStore.load();
-        osmEdit = new OSMEdit.OSMEdit();
+        Application.osmEdit = new OSMEdit();
     }
 
     _createWindow() {
@@ -443,4 +429,20 @@ var Application = GObject.registerClass({
     _onWindowDestroy(window) {
         this._mainWindow = null;
     }
-});
+}
+
+GObject.registerClass({
+    Properties: {
+        'selected-place': GObject.ParamSpec.object('selected-place',
+                                                   'Selected Place',
+                                                   'The selected place',
+                                                   GObject.ParamFlags.READABLE |
+                                                   GObject.ParamFlags.WRITABLE,
+                                                   Geocode.Place),
+        'adaptive-mode': GObject.ParamSpec.boolean('adaptive-mode',
+                                                   'Adaptive Move',
+                                                   'Whether the main window is in adaptive (narrow) mode',
+                                                   GObject.ParamFlags.READABLE |
+                                                   GObject.ParamFlags.WRITABLE),
+    }
+}, Application);
diff --git a/src/boundingBox.js b/src/boundingBox.js
index 0c06875e..396db2ca 100644
--- a/src/boundingBox.js
+++ b/src/boundingBox.js
@@ -19,9 +19,9 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const Constants = imports.constants;
+import * as Constants from './constants.js';
 
-var BoundingBox = class {
+export class BoundingBox {
     constructor(params) {
         /* default to a bounding box the "opposite" of covering the whole
          * visible world, this way extending with a coordinate will ensure
diff --git a/src/color.js b/src/color.js
index 36f21f24..a51dd1c9 100644
--- a/src/color.js
+++ b/src/color.js
@@ -27,7 +27,7 @@ const MIN_CONTRAST_RATIO = 2.0;
  * from a hex-encoded color string. Optionally, if defaultValue is supplied,
  * fallback to that if color is undefined.
  */
-function parseColor(color, component, defaultValue) {
+export function parseColor(color, component, defaultValue) {
     if (color) {
         let index = component * 2;
         return parseInt(color.substring(index, index + 2), 16) / 255;
@@ -41,7 +41,7 @@ function parseColor(color, component, defaultValue) {
  * notation (i.e. ffffff for white) according to the W3C WCAG definition:
  * https://www.w3.org/WAI/GL/wiki/Relative_luminance
  */
-function relativeLuminance(color) {
+export function relativeLuminance(color) {
     let rsRGB = parseColor(color, 0);
     let gsRGB = parseColor(color, 1);
     let bsRGB = parseColor(color, 2);
@@ -60,7 +60,7 @@ function relativeLuminance(color) {
  * (i.e. ffffff for white) according to the W3C WCAG definition:
  * https://www.w3.org/WAI/GL/wiki/Contrast_ratio
  */
-function contrastRatio(color1, color2) {
+export function contrastRatio(color1, color2) {
     let lc1 = relativeLuminance(color1);
     let lc2 = relativeLuminance(color2);
     /* order by luminance, lighter before darker */
@@ -76,7 +76,7 @@ function contrastRatio(color1, color2) {
  * has enough contrast against the background, otherwise (or if that argument
  * is undefined), return the one of black or white giving the highest contrast
  */
-function getContrastingForegroundColor(backgroundColor,
+export function getContrastingForegroundColor(backgroundColor,
                                        desiredForegroundColor) {
     if (!desiredForegroundColor ||
         (contrastRatio(backgroundColor, desiredForegroundColor) <
diff --git a/src/constants.js b/src/constants.js
index a3419ec7..43a7635e 100644
--- a/src/constants.js
+++ b/src/constants.js
@@ -22,7 +22,7 @@
 /**
  * Constraints of visible location in the standard Mercaartor projection.
  */
-var MIN_LATITUDE = -85.0511287798;
-var MAX_LATITUDE = 85.0511287798;
-var MIN_LONGITUDE = -180;
-var MAX_LONGITUDE = 180;
+export var MIN_LATITUDE = -85.0511287798;
+export var MAX_LATITUDE = 85.0511287798;
+export var MIN_LONGITUDE = -180;
+export var MAX_LONGITUDE = 180;
diff --git a/src/contactPlace.js b/src/contactPlace.js
index 6c036c22..52f8870e 100644
--- a/src/contactPlace.js
+++ b/src/contactPlace.js
@@ -19,18 +19,17 @@
  * Author: Jonas Danielsson <jonas threetimestwo org>
  */
 
-const GObject = imports.gi.GObject;
+import GObject from 'gi://GObject';
 
-const Place = imports.place;
+import {Place} from './place.js';
 
-var ContactPlace = GObject.registerClass(
-class ContactPlace extends Place.Place {
-    _init(params) {
+export class ContactPlace extends Place {
+    constructor(params) {
         this._contact = params.contact;
         delete params.contact;
 
         params.store = false;
-        super._init(params);
+        super(params);
     }
 
     get icon() {
@@ -42,4 +41,6 @@ class ContactPlace extends Place.Place {
                 this.osm_type,
                 this.osm_id].join('-');
     }
-});
+}
+
+GObject.registerClass(ContactPlace);
diff --git a/src/contextMenu.js b/src/contextMenu.js
index 6de6a8c8..4d9e4ee2 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -19,40 +19,32 @@
  * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
  */
 
-const Gdk = imports.gi.Gdk;
-const Geocode = imports.gi.GeocodeGlib;
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+import Gdk from 'gi://Gdk';
+import GeocodeGlib from 'gi://GeocodeGlib';
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
 const Mainloop = imports.mainloop;
 
-const Application = imports.application;
-const GeocodeFactory = imports.geocode;
-const Location = imports.location;
-const OSMAccountDialog = imports.osmAccountDialog;
-const OSMEdit = imports.osmEdit;
-const OSMEditDialog = imports.osmEditDialog;
-const Place = imports.place;
-const RouteQuery = imports.routeQuery;
-const Utils = imports.utils;
-const ZoomInDialog = imports.zoomInDialog;
-
-var ContextMenu = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/context-menu.ui',
-    InternalChildren: [ 'whatsHereItem',
-                        'geoURIItem',
-                        'addOSMLocationItem',
-                        'routeFromHereItem',
-                        'addIntermediateDestinationItem',
-                        'routeToHereItem' ],
-}, class ContextMenu extends Gtk.Menu {
-    _init(params) {
+import {Application} from './application.js';
+import * as GeocodeFactory from './geocode.js';
+import {Location} from './location.js';
+import {OSMAccountDialog} from './osmAccountDialog.js';
+import {OSMEdit} from './osmEdit.js';
+import {OSMEditDialog} from './osmEditDialog.js';
+import {Place} from './place.js';
+import {RouteQuery} from './routeQuery.js';
+import * as Utils from './utils.js';
+import {ZoomInDialog} from './zoomInDialog.js';
+
+export class ContextMenu extends Gtk.Menu {
+    constructor(params) {
         this._mapView = params.mapView;
         delete params.mapView;
 
         this._mainWindow = params.mainWindow;
         delete params.mainWindow;
 
-        super._init(params);
+        super(params);
 
         this._buttonGesture =
             new Gtk.GestureSingle({ widget: this._mapView,
@@ -98,19 +90,19 @@ var ContextMenu = GObject.registerClass({
 
     _onRouteFromHereActivated() {
         let query = Application.routeQuery;
-        let location = new Location.Location({ latitude: this._latitude,
-                                               longitude: this._longitude,
-                                               accuracy: 0 });
-        let place = new Place.Place({ location: location, store: false });
+        let location = new Location({ latitude: this._latitude,
+                                      longitude: this._longitude,
+                                      accuracy: 0 });
+        let place = new Place({ location: location, store: false });
 
         query.points[0].place = place;
     }
 
     _onRouteToHereActivated() {
         let query = Application.routeQuery;
-        let location = new Location.Location({ latitude: this._latitude,
-                                               longitude: this._longitude,
-                                               accuracy: 0 });
+        let location = new Location({ latitude: this._latitude,
+                                      longitude: this._longitude,
+                                      accuracy: 0 });
         let place = new Place.Place({ location: location, store: false });
 
         query.points.last().place = place;
@@ -118,10 +110,10 @@ var ContextMenu = GObject.registerClass({
 
     _onAddIntermediateDestinationActivated() {
         let query = Application.routeQuery;
-        let location = new Location.Location({ latitude: this._latitude,
-                                               longitude: this._longitude,
-                                               accuracy: 0 });
-        let place = new Place.Place({ location: location, store: false });
+        let location = new Location({ latitude: this._latitude,
+                                      longitude: this._longitude,
+                                      accuracy: 0 });
+        let place = new Place({ location: location, store: false });
 
         query.addPoint(-1).place = place;
     }
@@ -140,12 +132,12 @@ var ContextMenu = GObject.registerClass({
     }
 
     _onGeoURIActivated() {
-        let location = new Location.Location({ latitude: this._latitude,
-                                               longitude: this._longitude,
-                                               accuracy: 0 });
+        let location = new Location({ latitude: this._latitude,
+                                      longitude: this._longitude,
+                                      accuracy: 0 });
         let display = Gdk.Display.get_default();
         let clipboard = Gtk.Clipboard.get_default(display);
-        let uri = location.to_uri(Geocode.LocationURIScheme.GEO);
+        let uri = location.to_uri(GeocodeGlib.LocationURIScheme.GEO);
 
         clipboard.set_text(uri, uri.length);
     }
@@ -198,4 +190,14 @@ var ContextMenu = GObject.registerClass({
             }
         });
     }
-});
+}
+
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/context-menu.ui',
+    InternalChildren: [ 'whatsHereItem',
+                        'geoURIItem',
+                        'addOSMLocationItem',
+                        'routeFromHereItem',
+                        'addIntermediateDestinationItem',
+                        'routeToHereItem' ],
+}, ContextMenu);
diff --git a/src/favoritesPopover.js b/src/favoritesPopover.js
index 097c1e58..6e7169a0 100644
--- a/src/favoritesPopover.js
+++ b/src/favoritesPopover.js
@@ -17,40 +17,26 @@
  * Author: Jonas Danielsson <jonas threetimestwo org>
  */
 
-const GLib = imports.gi.GLib;
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
 
-const Application = imports.application;
-const PlaceListRow = imports.placeListRow;
-const PlaceStore = imports.placeStore;
+import {Application} from './application.js';
+import {PlaceListRow} from './placeListRow.js';
+import {PlaceStore} from './placeStore.js';
 
 const _N_VISIBLE = 6;
 
-var FavoritesPopover = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/favorites-popover.ui',
-    InternalChildren: [ 'mainGrid',
-                        'entry',
-                        'scrolledWindow',
-                        'list' ],
-    Properties: {
-        'rows': GObject.ParamSpec.int('rows',
-                                        '',
-                                        '',
-                                        GObject.ParamFlags.READABLE |
-                                        GObject.ParamFlags.WRITABLE,
-                                        0, GLib.MAXINT32, 0)
-    }
-}, class FavoritesPopover extends Gtk.Popover {
+export class FavoritesPopover extends Gtk.Popover {
 
-    _init(params) {
+    constructor(params) {
         params = params || { };
 
         this._mapView = params.mapView;
         delete params.mapView;
 
         params.transitions_enabled = false;
-        super._init(params);
+        super(params);
 
         this._rows = 0;
 
@@ -117,4 +103,20 @@ var FavoritesPopover = GObject.registerClass({
 
         this.rows = rows;
     }
-});
+}
+
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/favorites-popover.ui',
+    InternalChildren: [ 'mainGrid',
+                        'entry',
+                        'scrolledWindow',
+                        'list' ],
+    Properties: {
+        'rows': GObject.ParamSpec.int('rows',
+                                        '',
+                                        '',
+                                        GObject.ParamFlags.READABLE |
+                                        GObject.ParamFlags.WRITABLE,
+                                        0, GLib.MAXINT32, 0)
+    }
+}, FavoritesPopover);
diff --git a/src/geoclue.js b/src/geoclue.js
index af127355..8a1497de 100644
--- a/src/geoclue.js
+++ b/src/geoclue.js
@@ -19,15 +19,14 @@
  * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
  */
 
-const GObject = imports.gi.GObject;
-const GClue = imports.gi.Geoclue;
-const Gio = imports.gi.Gio;
+import GObject from 'gi://GObject';
+import GClue from 'gi://Geoclue';
+import Gio from 'gi://Gio';
 const Mainloop = imports.mainloop;
 
-const Place = imports.place;
-const Location = imports.location;
-const Settings = imports.settings;
-const Utils = imports.utils;
+import {Place} from './place.js';
+import {Location} from './location.js';
+import * as Utils from './utils.js';
 
 var State = {
     INITIAL: 0,
@@ -36,21 +35,7 @@ var State = {
     FAILED: 3
 };
 
-var Geoclue = GObject.registerClass({
-    Signals: {
-        'location-changed': { }
-    },
-    Properties: {
-        'state': GObject.ParamSpec.int('state',
-                                       '',
-                                       '',
-                                       GObject.ParamFlags.READABLE |
-                                       GObject.ParamFlags.WRITABLE,
-                                       State.INITIAL,
-                                       State.FAILED,
-                                       State.INITIAL)
-    },
-}, class Geoclue extends GObject.Object {
+export class Geoclue extends GObject.Object {
 
     set state(s) {
         this._state = s;
@@ -61,7 +46,7 @@ var Geoclue = GObject.registerClass({
         return this._state;
     }
 
-    _init() {
+    constructor() {
         super._init();
         this.place = null;
         this._state = State.INITIAL;
@@ -119,8 +104,8 @@ var Geoclue = GObject.registerClass({
 
     _updateLocation(location) {
         if (!this.place)
-            this.place = new Place.Place({ name: _("Current Location"),
-                                           isCurrentLocation: true });
+            this.place = new Place({ name: _("Current Location"),
+                                     isCurrentLocation: true });
 
         this.place.location = location;
         this.emit('location-changed');
@@ -128,4 +113,20 @@ var Geoclue = GObject.registerClass({
                     " (" + location.latitude + ", " + location.longitude +
                     ", accuracy = " + location.accuracy + " m)");
     }
-});
+}
+
+GObject.registerClass({
+    Signals: {
+        'location-changed': { }
+    },
+    Properties: {
+        'state': GObject.ParamSpec.int('state',
+                                       '',
+                                       '',
+                                       GObject.ParamFlags.READABLE |
+                                       GObject.ParamFlags.WRITABLE,
+                                       State.INITIAL,
+                                       State.FAILED,
+                                       State.INITIAL)
+    },
+}, Geoclue);
diff --git a/src/geocode.js b/src/geocode.js
index 7623684a..996cd91d 100644
--- a/src/geocode.js
+++ b/src/geocode.js
@@ -19,18 +19,18 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const Service = imports.service;
-const GraphHopperGeocode = imports.graphHopperGeocode;
-const PhotonGeocode = imports.photonGeocode;
+import * as Service from './service.js';
+import {GraphHopperGeocode} from './graphHopperGeocode.js';
+import {PhotonGeocode} from './photonGeocode.js';
 
 var _geocoder = null;
 
 function getGeocoder() {
     if (!_geocoder) {
         if (Service.getService().photonGeocode)
-            _geocoder = new PhotonGeocode.PhotonGeocode();
+            _geocoder = new PhotonGeocode();
         else
-            _geocoder = new GraphHopperGeocode.GraphHopperGeocode();
+            _geocoder = new GraphHopperGeocode();
     }
 
     return _geocoder;
diff --git a/src/gpxShapeLayer.js b/src/gpxShapeLayer.js
index e3a23b99..d684e2ce 100644
--- a/src/gpxShapeLayer.js
+++ b/src/gpxShapeLayer.js
@@ -17,24 +17,28 @@
  * Author: Hashem Nasarat <hashem riseup net>
  */
 
-const GObject = imports.gi.GObject;
+import GObject from 'gi://GObject';
 
-const GeoJSONSource = imports.geoJSONSource;
-const ShapeLayer = imports.shapeLayer;
-const Utils = imports.utils;
-const Togeojson = imports.togeojson.togeojson;
-const Domparser = imports.xmldom.domparser;
+import {GeoJSONSource} from './geoJSONSource.js';
+import {ShapeLayer} from './shapeLayer.js';
+import * as Utils from './utils.js';
+import * as Togeojson from './togeojson/togeojson.js';
+import * as Domparser from './xmldom/domparser.js';
 
-var GpxShapeLayer = GObject.registerClass(
-class GpxShapeLayer extends ShapeLayer.ShapeLayer {
+export class GpxShapeLayer extends ShapeLayer {
 
-    _init(params) {
-        super._init(params);
+    static mimeTypes = ['application/gpx+xml' ];
+    static displayName = 'GPX';
 
-        this._mapSource = new GeoJSONSource.GeoJSONSource({
-            mapView: this._mapView,
-            markerLayer: this._markerLayer
-        });
+    static createInstance(params) {
+        return new GpxShapeLayer(params);
+    };
+
+    constructor(params) {
+        super(params);
+
+        this._mapSource = new GeoJSONSource({ mapView: this._mapView,
+                                              markerLayer: this._markerLayer });
     }
 
     _parseContent() {
@@ -43,10 +47,6 @@ class GpxShapeLayer extends ShapeLayer.ShapeLayer {
         let json = Togeojson.toGeoJSON.gpx(parser.parseFromString(s));
         this._mapSource.parse(json);
     }
-});
+}
 
-GpxShapeLayer.mimeTypes = ['application/gpx+xml' ];
-GpxShapeLayer.displayName = 'GPX';
-GpxShapeLayer.createInstance = function(params) {
-    return new GpxShapeLayer(params);
-};
+GObject.registerClass(GpxShapeLayer);
diff --git a/src/graphHopperGeocode.js b/src/graphHopperGeocode.js
index 975cde2e..b74142c3 100644
--- a/src/graphHopperGeocode.js
+++ b/src/graphHopperGeocode.js
@@ -21,19 +21,19 @@
 
 const Format = imports.format;
 
-const GLib = imports.gi.GLib;
-const Soup = imports.gi.Soup;
+import GLib from 'gi://GLib';
+import Soup from 'gi://Soup';
 
-const Application = imports.application;
-const HTTP = imports.http;
-const PhotonParser = imports.photonParser;
-const Service = imports.service;
-const Utils = imports.utils;
+import {Application} from './application.js';
+import * as HTTP from './http.js';
+import * as PhotonParser from './photonParser.js';
+import * as Service from './service.js';
+import * as Utils from './utils.js';
 
 // HTTP session timeout (in seconds)
 const TIMEOUT = 5;
 
-var GraphHopperGeocode = class {
+export class GraphHopperGeocode {
     constructor() {
         this._session =
             new Soup.Session({ user_agent : 'gnome-maps/' + pkg.version,
diff --git a/src/headerBar.js b/src/headerBar.js
index cbd74274..d010893b 100644
--- a/src/headerBar.js
+++ b/src/headerBar.js
@@ -20,25 +20,22 @@
  *         Zeeshan Ali (Khattak) <zeeshanak gnome org>
  */
 
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
 
-const FavoritesPopover = imports.favoritesPopover;
-const LayersPopover = imports.layersPopover;
-const MapView = imports.mapView;
+import {FavoritesPopover} from './favoritesPopover.js';
+import {LayersPopover} from './layersPopover.js';
+import {MapView} from './mapView.js';
 
-var HeaderBarLeft = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/headerbar-left.ui',
-    InternalChildren: [ 'layersButton' ]
-}, class HeaderBarLeft extends Gtk.Box {
-    _init(params) {
+export class HeaderBarLeft extends Gtk.Box {
+    constructor(params) {
         this._application = params.application;
         delete params.application;
 
         this._mapView = params.mapView;
         delete params.mapView;
 
-        super._init(params);
+        super(params);
 
         this._layersPopover = new LayersPopover.LayersPopover({
             mapView: this._mapView
@@ -49,22 +46,22 @@ var HeaderBarLeft = GObject.registerClass({
     popdownLayersPopover() {
         this._layersPopover.popdown();
     }
-});
+}
 
-var HeaderBarRight = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/headerbar-right.ui',
-    InternalChildren: [ 'toggleSidebarButton',
-                        'favoritesButton',
-                        'printRouteButton' ]
-}, class HeaderBarRight extends Gtk.Box {
-    _init(params) {
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/headerbar-left.ui',
+    InternalChildren: [ 'layersButton' ]
+}, HeaderBarLeft);
+
+export class HeaderBarRight extends Gtk.Box {
+    constructor(params) {
         this._application = params.application;
         delete params.application;
 
         this._mapView = params.mapView;
         delete params.mapView;
 
-        super._init(params);
+        super(params);
 
         this._favoritesButton.popover = new FavoritesPopover.FavoritesPopover({
             mapView: this._mapView
@@ -78,4 +75,11 @@ var HeaderBarRight = GObject.registerClass({
         this._mapView.bind_property('routeShowing', this._printRouteButton,
                                     'visible', GObject.BindingFlags.DEFAULT);
     }
-});
+}
+
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/headerbar-right.ui',
+    InternalChildren: [ 'toggleSidebarButton',
+                        'favoritesButton',
+                        'printRouteButton' ]
+}, HeaderBarRight);
diff --git a/src/http.js b/src/http.js
index 8d853fee..ee8e65dc 100644
--- a/src/http.js
+++ b/src/http.js
@@ -19,7 +19,7 @@
  * Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
  */
 
-const Soup = imports.gi.Soup;
+import Soup from 'gi://Soup';
 
 function encode(data) {
     if(data === null)
@@ -28,7 +28,7 @@ function encode(data) {
     return Soup.URI.encode(data.toString(), '&');
 }
 
-var Query = class Query {
+export class Query {
 
     constructor(obj) {
         this._query = {};
@@ -73,4 +73,4 @@ var Query = class Query {
         }
         return vars.join('&');
     }
-};
+}
diff --git a/src/layersPopover.js b/src/layersPopover.js
index d421b71f..55059aa8 100644
--- a/src/layersPopover.js
+++ b/src/layersPopover.js
@@ -17,33 +17,29 @@
  * Author: Dario Di Nucci <linkin88mail gmail com>
  */
 
-const Champlain = imports.gi.Champlain;
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
-const Gdk = imports.gi.Gdk;
-const Hdy = imports.gi.Handy;
-
-const Application = imports.application;
-const MapSource = imports.mapSource;
-const MapView = imports.mapView;
-const Service = imports.service;
-const ShapeLayer = imports.shapeLayer;
-const Utils = imports.utils;
+import Champlain from 'gi://Champlain';
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
+import Gdk from 'gi://Gdk';
+import Handy from 'gi://Handy';
+
+import {Application} from './application.js';
+import {MapSource} from './mapSource.js';
+import {MapView} from './mapView.js';
+import * as Service from './service.js';
+import {ShapeLayer} from './shapeLayer.js';
+import * as Utils from './utils.js';
 
 const PREVIEW_WIDTH = 230;
 const PREVIEW_HEIGHT = 80;
 
-var ShapeLayerRow = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/shape-layer-row.ui',
-    Children: ['closeButton'],
-    InternalChildren: ['layerLabel', 'visibleButton']
-}, class ShapeLayerRow extends Gtk.ListBoxRow {
+export class ShapeLayerRow extends Gtk.ListBoxRow {
 
-    _init(params) {
+    constructor(params) {
         this.shapeLayer = params.shapeLayer;
         delete params.shapeLayer;
 
-        super._init(params);
+        super(params);
 
         this._layerLabel.label = this.shapeLayer.getName();
         this._layerLabel.tooltip_text = this.shapeLayer.file.get_parse_name();
@@ -58,27 +54,24 @@ var ShapeLayerRow = GObject.registerClass({
                 image.icon_name = 'layer-not-visible-symbolic';
         });
     }
-});
+}
 
-var LayersPopover = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/layers-popover.ui',
-    InternalChildren: [ 'streetLayerButton',
-                        'aerialLayerButton',
-                        'streetLayerImage',
-                        'aerialLayerImage',
-                        'hybridAerialRevealer',
-                        'layersListBox',
-                        'loadLayerButton' ]
-}, class LayersPopover extends Gtk.Popover {
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/shape-layer-row.ui',
+    Children: ['closeButton'],
+    InternalChildren: ['layerLabel', 'visibleButton']
+}, ShapeLayerRow);
+
+export class LayersPopover extends Gtk.Popover {
 
-    _init(params) {
+    constructor(params) {
         this._mapView = params.mapView;
         delete params.mapView;
 
-        super._init({ width_request: 200,
-                      no_show_all: true,
-                      transitions_enabled: false,
-                      visible: false });
+        super({ width_request: 200,
+                no_show_all: true,
+                transitions_enabled: false,
+                visible: false });
 
         this._aerialLayerButton.join_group(this._streetLayerButton);
 
@@ -145,7 +138,7 @@ var LayersPopover = GObject.registerClass({
                                        this._setLayerPreviews.bind(this));
             this._mapView.view.connect("notify::longitude",
                                        this._setLayerPreviews.bind(this));
-            Hdy.StyleManager.get_default().connect("notify::dark",
+            Handy.StyleManager.get_default().connect("notify::dark",
                                                     this._onDarkChanged.bind(this));
             Application.settings.connect("changed::hybrid-aerial",
                                          this._onHybridAerialChanged.bind(this));
@@ -163,7 +156,7 @@ var LayersPopover = GObject.registerClass({
 
     _onDarkChanged() {
         if (Service.getService().tiles.streetDark &&
-            Hdy.StyleManager.get_default().dark) {
+            Handy.StyleManager.get_default().dark) {
             this._setLayerPreviewImage('streetDark', true);
         } else {
             this._setLayerPreviewImage('street', true);
@@ -181,7 +174,7 @@ var LayersPopover = GObject.registerClass({
 
     _setLayerPreviews() {
         if (Service.getService().tiles.streetDark &&
-            Hdy.StyleManager.get_default().dark) {
+            Handy.StyleManager.get_default().dark) {
             this._setLayerPreviewImage('streetDark');
         } else {
             this._setLayerPreviewImage('street');
@@ -264,4 +257,15 @@ var LayersPopover = GObject.registerClass({
         this._layersListBox.show();
         return row;
     }
-});
+}
+
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/layers-popover.ui',
+    InternalChildren: [ 'streetLayerButton',
+                        'aerialLayerButton',
+                        'streetLayerImage',
+                        'aerialLayerImage',
+                        'hybridAerialRevealer',
+                        'layersListBox',
+                        'loadLayerButton' ]
+}, LayersPopover);
diff --git a/src/location.js b/src/location.js
index 88427abc..473fcbdc 100644
--- a/src/location.js
+++ b/src/location.js
@@ -21,18 +21,17 @@
  *          Jonas Danielsson <jonas threetimestwo org>
  */
 
-const Geocode = imports.gi.GeocodeGlib;
-const GObject = imports.gi.GObject;
+import Geocode from 'gi://GeocodeGlib';
+import GObject from 'gi://GObject';
 
 /* Adds heading to Geocode.Location */
-var Location = GObject.registerClass(
-class Location extends Geocode.Location {
+export class Location extends Geocode.Location {
 
-    _init(params) {
+    constructor(params) {
         this._heading = params.heading;
         delete params.heading;
 
-        super._init(params);
+        super(params);
     }
 
     get heading() {
@@ -42,4 +41,6 @@ class Location extends Geocode.Location {
     set heading(v) {
         this._heading = v;
     }
-});
+}
+
+GObject.registerClass(Location);
diff --git a/src/main.js b/src/main.js
index 6e4fa113..d46faa94 100644
--- a/src/main.js
+++ b/src/main.js
@@ -20,27 +20,29 @@
  *         Zeeshan Ali (Khattak) <zeeshanak gnome org>
  */
 
+import 'gi://Champlain?version=0.12';
+import 'gi://Clutter?version=1.0';
+import 'gi://Cogl?version=1.0';
+import 'gi://GeocodeGlib?version=1.0';
+import 'gi://Gdk?version=3.0';
+import 'gi://GdkPixbuf?version=2.0';
+import 'gi://Gio?version=2.0';
+import 'gi://GLib?version=2.0';
+import 'gi://GObject?version=2.0';
+import 'gi://Gtk?version=3.0';
+import 'gi://GtkChamplain?version=0.12';
+import 'gi://GtkClutter?version=1.0';
+import 'gi://GWeather?version=4.0';
+import 'gi://Handy?version=1';
+import 'gi://Rest?version=0.7';
+import 'gi://Soup?version=2.4';
+
+import * as system from 'system';
+
+import {Application} from './application.js';
+
 pkg.initGettext();
 pkg.initFormat();
-pkg.require({ 'cairo': '1.0',
-              'Champlain': '0.12',
-              'Clutter': '1.0',
-              'Cogl': '1.0',
-              'GeocodeGlib': '1.0',
-              'Gdk': '3.0',
-              'GdkPixbuf': '2.0',
-              'Gio': '2.0',
-              'GLib': '2.0',
-              'GObject': '2.0',
-              'Gtk': '3.0',
-              'GtkChamplain': '0.12',
-              'GtkClutter': '1.0',
-              'GWeather': '4.0',
-              'Handy': '1',
-              'Rest': '0.7',
-              'Soup': '2.4' });
-
-const Application = imports.application;
 
 function main(args) {
     /* Add prototype to get last element of an array.
@@ -53,6 +55,8 @@ function main(args) {
         }
     }
 
-    let application = new Application.Application();
+    let application = new Application();
     return application.run(args);
 }
+
+main([system.programInvocationName, ...system.programArgs]);
diff --git a/src/mainWindow.js b/src/mainWindow.js
index bb4fc69e..f565dbd8 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -20,23 +20,23 @@
  *         Zeeshan Ali (Khattak) <zeeshanak gnome org>
  */
 
-const _ = imports.gettext.gettext;
-
-const Champlain = imports.gi.Champlain;
-const GLib = imports.gi.GLib;
-const GObject = imports.gi.GObject;
-const Gdk = imports.gi.Gdk;
-const Gio = imports.gi.Gio;
-const Gtk = imports.gi.Gtk;
+//const _ = imports.gettext.gettext;
+
+import Champlain from 'gi://Champlain';
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
+import Gdk from 'gi://Gdk';
+import Gio from 'gi://Gio';
+import Gtk from 'gi://Gtk';
 const Mainloop = imports.mainloop;
 
-const Application = imports.application;
-const ContextMenu = imports.contextMenu;
-const ExportViewDialog = imports.exportViewDialog;
-const FavoritesPopover = imports.favoritesPopover;
-const Geoclue = imports.geoclue;
-const GeocodeFactory = imports.geocode;
-const HeaderBar = imports.headerBar;
+import {Application} from './application.js';
+import {ContextMenu} from './contextMenu.js';
+import {ExportViewDialog} from './exportViewDialog.js';
+import {FavoritesPopover} from './favoritesPopover.js';
+import {Geoclue} from './geoclue.js';
+import * as GeocodeFactory from './geocode.js';
+import {HeaderBarLeft, HeaderBarRight} from './headerBar.js';
 const LocationServiceDialog = imports.locationServiceDialog;
 const MapView = imports.mapView;
 const PlaceBar = imports.placeBar;
@@ -52,12 +52,10 @@ const _CONFIGURE_ID_TIMEOUT = 100; // msecs
 const _ADAPTIVE_VIEW_WIDTH = 700;
 const _PLACE_ENTRY_MARGIN = 35;
 
-var ShapeLayerFileChooser = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/shape-layer-file-chooser.ui'
-}, class ShapeLayerFileChooser extends Gtk.FileChooserNative {
+export class ShapeLayerFileChooser extends Gtk.FileChooserNative {
 
-    _init(params) {
-        super._init(params);
+    constructor(params) {
+        super(params);
         let allFilter = new Gtk.FileFilter();
         allFilter.set_name(_("All Layer Files"));
         this.add_filter(allFilter);
@@ -75,16 +73,13 @@ var ShapeLayerFileChooser = GObject.registerClass({
             this.add_filter(filter);
         });
     }
-});
+}
 
-var MainWindow = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/main-window.ui',
-    InternalChildren: [ 'headerBar',
-                        'grid',
-                        'actionBar',
-                        'actionBarRevealer',
-                        'placeBarContainer']
-}, class MainWindow extends Gtk.ApplicationWindow {
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/shape-layer-file-chooser.ui'
+}, ShapeLayerFileChooser);
+
+export class MainWindow extends Gtk.ApplicationWindow {
 
     get mapView() {
         return this._mapView;
@@ -94,8 +89,8 @@ var MainWindow = GObject.registerClass({
         return this._placeEntry;
     }
 
-    _init(params) {
-        super._init(params);
+    constructor(params) {
+        super(params);
 
         this._configureId = 0;
 
@@ -348,13 +343,13 @@ var MainWindow = GObject.registerClass({
     }
 
     _initHeaderbar() {
-        this._headerBarLeft = new HeaderBar.HeaderBarLeft({
+        this._headerBarLeft = new HeaderBarLeft({
             mapView: this._mapView,
             application: this.application
         });
         this._headerBar.pack_start(this._headerBarLeft);
 
-        this._headerBarRight = new HeaderBar.HeaderBarRight({
+        this._headerBarRight = new HeaderBarRight({
             mapView: this._mapView,
             application: this.application
         });
@@ -367,13 +362,13 @@ var MainWindow = GObject.registerClass({
                                     this._updateLocationSensitivity.bind(this));
 
         // action bar, for when the window is too narrow for the full headerbar
-        this._actionBarLeft =  new HeaderBar.HeaderBarLeft({
+        this._actionBarLeft =  new HeaderBarLeft({
             mapView: this._mapView,
             application: this.application
         })
         this._actionBar.pack_start(this._actionBarLeft);
 
-        this._actionBarRight = new HeaderBar.HeaderBarRight({
+        this._actionBarRight = new HeaderBarRight({
             mapView: this._mapView,
             application: this.application
         })
@@ -675,4 +670,13 @@ var MainWindow = GObject.registerClass({
         });
         this._fileChooser.show();
     }
-});
+}
+
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/main-window.ui',
+    InternalChildren: [ 'headerBar',
+                        'grid',
+                        'actionBar',
+                        'actionBarRevealer',
+                        'placeBarContainer']
+}, MainWindow);
diff --git a/src/mapBubble.js b/src/mapBubble.js
index 1d92c9ee..508c82c8 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -19,21 +19,21 @@
  * Author: Damián Nohales <damiannohales gmail com>
  */
 
-const Gio = imports.gi.Gio;
-const GLib = imports.gi.GLib;
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+import Gio from 'gi://Gio';
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
 const Mainloop = imports.mainloop;
 
-const Application = imports.application;
-const ContactPlace = imports.contactPlace;
-const GeocodeFactory = imports.geocode;
-const Place = imports.place;
-const PlaceView = imports.placeView;
-const PlaceButtons = imports.placeButtons;
-const PlaceFormatter = imports.placeFormatter;
-const PlaceStore = imports.placeStore;
-const Utils = imports.utils;
+import {Application} from './application.js';
+import {ContactPlace} from './contactPlace.js';
+import * as GeocodeFactory from './geocode.js';
+import {Place} from './place.js';
+import {PlaceView} from './placeView.js';
+import {PlaceButtons} from './placeButtons.js';
+import {PlaceFormatter} from './placeFormatter.js';
+import {PlaceStore} from './placeStore.js';
+import * as Utils from './utils.js';
 
 /* Maximum width of the popover content before it's forced to wrap */
 const MAX_CONTENT_WIDTH = 350;
@@ -41,10 +41,9 @@ const MAX_CONTENT_WIDTH = 350;
    contents */
 const HEIGHT_MARGIN = 100;
 
-var MapBubble = GObject.registerClass(
-class MapBubble extends Gtk.Popover {
+export class MapBubble extends Gtk.Popover {
 
-    _init(params) {
+    constructor(params) {
         let place = params.place;
         delete params.place;
 
@@ -55,9 +54,9 @@ class MapBubble extends Gtk.Popover {
         params.transitions_enabled = false;
         params.modal = false;
 
-        super._init(params);
+        super(params);
 
-        let content = new PlaceView.PlaceView({ place, mapView, visible: true });
+        let content = new PlaceView({ place, mapView, visible: true });
 
         let scrolledWindow = new MapBubbleScrolledWindow({ visible: true,
                                                            propagateNaturalWidth: true,
@@ -68,10 +67,11 @@ class MapBubble extends Gtk.Popover {
 
         this.get_style_context().add_class("map-bubble");
     }
-});
+}
 
-var MapBubbleScrolledWindow = GObject.registerClass(
-class MapBubbleScrolledWindow extends Gtk.ScrolledWindow {
+GObject.registerClass(MapBubble);
+
+export class MapBubbleScrolledWindow extends Gtk.ScrolledWindow {
     vfunc_get_preferred_width() {
         let [min, nat] = this.get_child().get_preferred_width();
         min = Math.min(min, MAX_CONTENT_WIDTH);
@@ -109,5 +109,7 @@ class MapBubbleScrolledWindow extends Gtk.ScrolledWindow {
 
         return super.vfunc_draw(cr);
     }
-});
+}
+
+GObject.registerClass(MapBubbleScrolledWindow);
 
diff --git a/src/mapMarker.js b/src/mapMarker.js
index b5a0e7fa..c8fcf7fa 100644
--- a/src/mapMarker.js
+++ b/src/mapMarker.js
@@ -19,44 +19,22 @@
  * Author: Damián Nohales <damiannohales gmail com>
  */
 
-const Cairo = imports.cairo;
-const Champlain = imports.gi.Champlain;
-const Clutter = imports.gi.Clutter;
-const Gdk = imports.gi.Gdk;
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+import Cairo from 'cairo';
+import Champlain from 'gi://Champlain';
+import Clutter from 'gi://Clutter';
+import Gdk from 'gi://Gdk';
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
 const Mainloop = imports.mainloop;
 
-const Application = imports.application;
-const MapBubble = imports.mapBubble;
-const MapWalker = imports.mapWalker;
-const Utils = imports.utils;
+import {Application} from './application.js';
+import {MapBubble} from './mapBubble.js';
+import {MapWalker} from './mapWalker.js';
+import * as Utils from './utils.js';
 
-var MapMarker = GObject.registerClass({
-    Implements: [Champlain.Exportable],
-    Abstract: true,
-    Signals: {
-        'gone-to': { }
-    },
-    Properties: {
-        'surface': GObject.ParamSpec.override('surface',
-                                              Champlain.Exportable),
-        'view-latitude': GObject.ParamSpec.double('view-latitude', '', '',
-                                                  GObject.ParamFlags.READABLE |
-                                                  GObject.ParamFlags.WRITABLE,
-                                                  -90, 90, 0),
-        'view-longitude': GObject.ParamSpec.double('view-longitude', '', '',
-                                                   GObject.ParamFlags.READABLE |
-                                                   GObject.ParamFlags.WRITABLE,
-                                                   -180, 180, 0),
-        'view-zoom-level': GObject.ParamSpec.int('view-zoom-level', '', '',
-                                                 GObject.ParamFlags.READABLE |
-                                                 GObject.ParamFlags.WRITABLE,
-                                                 0, 20, 3)
-    }
-}, class MapMarker extends Champlain.Marker {
+export class MapMarker extends Champlain.Marker {
 
-    _init(params) {
+    constructor(params) {
         this._place = params.place;
         delete params.place;
 
@@ -67,7 +45,7 @@ var MapMarker = GObject.registerClass({
         params.longitude = this.place.location.longitude;
         params.selectable = true;
 
-        super._init(params);
+        super(params);
 
         this.connect('notify::size', this._translateMarkerPosition.bind(this));
         if (this._mapView) {
@@ -208,8 +186,8 @@ var MapMarker = GObject.registerClass({
     get bubble() {
         if (this._bubble === undefined && this._hasBubble()) {
             if (this._place.name) {
-                this._bubble = new MapBubble.MapBubble({ place: this._place,
-                                                         mapView: this._mapView });
+                this._bubble = new MapBubble({ place: this._place,
+                                               mapView: this._mapView });
             }
         }
 
@@ -371,7 +349,7 @@ var MapMarker = GObject.registerClass({
 
     get walker() {
         if (this._walker === undefined)
-            this._walker = new MapWalker.MapWalker(this.place, this._mapView);
+            this._walker = new MapWalker(this.place, this._mapView);
 
         return this._walker;
     }
@@ -412,4 +390,28 @@ var MapMarker = GObject.registerClass({
             }
         }
     }
+}
+
+GObject.registerClass({
+    Implements: [Champlain.Exportable],
+    Abstract: true,
+    Signals: {
+        'gone-to': { }
+    },
+    Properties: {
+        'surface': GObject.ParamSpec.override('surface',
+                                              Champlain.Exportable),
+        'view-latitude': GObject.ParamSpec.double('view-latitude', '', '',
+                                                  GObject.ParamFlags.READABLE |
+                                                  GObject.ParamFlags.WRITABLE,
+                                                  -90, 90, 0),
+        'view-longitude': GObject.ParamSpec.double('view-longitude', '', '',
+                                                   GObject.ParamFlags.READABLE |
+                                                   GObject.ParamFlags.WRITABLE,
+                                                   -180, 180, 0),
+        'view-zoom-level': GObject.ParamSpec.int('view-zoom-level', '', '',
+                                                 GObject.ParamFlags.READABLE |
+                                                 GObject.ParamFlags.WRITABLE,
+                                                 0, 20, 3)
+    }
 });
diff --git a/src/mapView.js b/src/mapView.js
index 103a40d3..1e30104c 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -19,58 +19,44 @@
  * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
  */
 
-const Champlain = imports.gi.Champlain;
-const Clutter = imports.gi.Clutter;
-const GObject = imports.gi.GObject;
-const Geocode = imports.gi.GeocodeGlib;
-const Gio = imports.gi.Gio;
-const Gtk = imports.gi.Gtk;
-const GtkChamplain = imports.gi.GtkChamplain;
-const Hdy = imports.gi.Handy;
+import Champlain from 'gi://Champlain';
+import Clutter from 'gi://Clutter';
+import GObject from 'gi://GObject';
+import GeocodeGlib from 'gi://GeocodeGlib';
+import Gio from 'gi://Gio';
+import Gtk from 'gi://Gtk';
+import GtkChamplain from 'gi://GtkChamplain';
+import Handy from 'gi://Handy';
 const Mainloop = imports.mainloop;
 
-const Application = imports.application;
-const BoundingBox = imports.boundingBox;
-const ContactPlace = imports.contactPlace;
-const Color = imports.color;
-const Geoclue = imports.geoclue;
-const GeoJSONShapeLayer = imports.geoJSONShapeLayer;
-const KmlShapeLayer = imports.kmlShapeLayer;
-const GpxShapeLayer = imports.gpxShapeLayer;
-const Location = imports.location;
-const Maps = imports.gi.GnomeMaps;
-const MapSource = imports.mapSource;
-const MapWalker = imports.mapWalker;
-const Place = imports.place;
-const PlaceMarker = imports.placeMarker;
-const RouteQuery = imports.routeQuery;
-const Service = imports.service;
-const ShapeLayer = imports.shapeLayer;
-const StoredRoute = imports.storedRoute;
-const TransitArrivalMarker = imports.transitArrivalMarker;
-const TransitBoardMarker = imports.transitBoardMarker;
-const TransitWalkMarker = imports.transitWalkMarker;
-const TurnPointMarker = imports.turnPointMarker;
-const UserLocationMarker = imports.userLocationMarker;
-const Utils = imports.utils;
-
-var MapType = {
-    LOCAL: 'MapsLocalSource',
-    STREET: 'MapsStreetSource',
-    AERIAL: 'MapsAerialSource'
-};
+import GnomeMaps from 'gi://GnomeMaps';
+
+import {Application} from './application.js';
+import {BoundingBox} from './boundingBox.js';
+import {ContactPlace} from './contactPlace.js';
+import * as Color from './color.js';
+import * as Geoclue from './geoclue.js';
+import {GeoJSONShapeLayer} from './geoJSONShapeLayer.js';
+import {KmlShapeLayer} from './kmlShapeLayer.js';
+import {GpxShapeLayer} from './gpxShapeLayer.js';
+import {Location} from './location.js';
+import {MapSource} from './mapSource.js';
+import {MapWalker} from './mapWalker.js';
+import {Place} from './place.js';
+import {PlaceMarker} from './placeMarker.js';
+import * as Service from './service.js';
+import {ShapeLayer} from './shapeLayer.js';
+import {StoredRoute} from './storedRoute.js';
+import {TransitArrivalMarker} from './transitArrivalMarker.js';
+import {TransitBoardMarker} from './transitBoardMarker.js';
+import {TransitWalkMarker} from './transitWalkMarker.js';
+import {TurnPointMarker} from './turnPointMarker.js';
+import {UserLocationMarker} from './userLocationMarker.js';
+import * as Utils from './utils.js';
+
 const _LOCATION_STORE_TIMEOUT = 500;
 const MapMinZoom = 2;
 
-/*
- * Due to the mathematics of spherical mericator projection,
- * the map must be truncated at a latitude less than 90 degrees.
- */
-var MAX_LATITUDE = 85.05112;
-var MIN_LATITUDE = -85.05112;
-var MAX_LONGITUDE = 180;
-var MIN_LONGITUDE = -180;
-
 /* threashhold for route color luminance when we consider it more or less
  * as white, and draw an outline on the path */
 const OUTLINE_LUMINANCE_THREASHHOLD = 0.9;
@@ -92,33 +78,22 @@ const DASHED_ROUTE_LINE_GAP_LENGTH = 5;
 // Maximum limit of file size (20 MB) that can be loaded without user confirmation
 const FILE_SIZE_LIMIT_MB = 20;
 
-var MapView = GObject.registerClass({
-    Properties: {
-        // this property is true when the routing sidebar is active
-        'routingOpen': GObject.ParamSpec.boolean('routingOpen',
-                                                  'Routing open',
-                                                  'Routing sidebar open',
-                                                  GObject.ParamFlags.READABLE |
-                                                  GObject.ParamFlags.WRITABLE,
-                                                  false),
-        /* this property is true when a route is being shown on the map */
-        'routeShowing': GObject.ParamSpec.boolean('routeShowing',
-                                                 'Route showing',
-                                                 'Showing a route on the map',
-                                                 GObject.ParamFlags.READABLE |
-                                                 GObject.ParamFlags.WRITABLE,
-                                                 false)
-    },
-    Signals: {
-        'user-location-changed': {},
-        'going-to': {},
-        'going-to-user-location': {},
-        'gone-to-user-location': {},
-        'view-moved': {},
-        'marker-selected': { param_types: [Champlain.Marker] },
-        'map-type-changed': { param_types: [GObject.TYPE_STRING] }
-    },
-}, class MapView extends GtkChamplain.Embed {
+export class MapView extends GtkChamplain.Embed {
+
+    static MapType = {
+        LOCAL: 'MapsLocalSource',
+        STREET: 'MapsStreetSource',
+        AERIAL: 'MapsAerialSource'
+    }
+
+    /*
+     * Due to the mathematics of spherical mericator projection,
+     * the map must be truncated at a latitude less than 90 degrees.
+     */
+    static MAX_LATITUDE = 85.05112;
+    static MIN_LATITUDE = -85.05112;
+    static MAX_LONGITUDE = 180;
+    static MIN_LONGITUDE = -180;
 
     get routingOpen() {
         return this._routingOpen || this._instructionMarkerLayer.visible;
@@ -144,8 +119,8 @@ var MapView = GObject.registerClass({
         this.notify('routeShowing');
     }
 
-    _init(params) {
-        super._init();
+    constructor(params) {
+        super();
 
         let mapType = params.mapType || this._getStoredMapType();
         delete params.mapType;
@@ -208,7 +183,7 @@ var MapView = GObject.registerClass({
 
         // if dark tiles is available, setup handler to switch style
         if (Service.getService().tiles.streetDark) {
-            Hdy.StyleManager.get_default().connect('notify::dark',
+            Handy.StyleManager.get_default().connect('notify::dark',
                                                     this._onDarkChanged.bind(this));
         }
 
@@ -229,7 +204,7 @@ var MapView = GObject.registerClass({
         if (this._mapType === MapType.STREET) {
             let overlay_sources = this.view.get_overlay_sources();
 
-            if (Hdy.StyleManager.get_default().dark)
+            if (Handy.StyleManager.get_default().dark)
                 this.view.map_source = MapSource.createStreetDarkSource();
             else
                 this.view.map_source = MapSource.createStreetSource();
@@ -369,10 +344,10 @@ var MapView = GObject.registerClass({
 
         this._mapType = mapType;
 
-        if (mapType !== MapType.LOCAL) {
+        if (mapType !== MapView.MapType.LOCAL) {
             let tiles = Service.getService().tiles;
 
-            if (mapType === MapType.AERIAL && tiles.aerial) {
+            if (mapType === MapView.MapType.AERIAL && tiles.aerial) {
                 if (tiles.hybridAerial &&
                     Application.settings.get('hybrid-aerial')) {
                     this.view.map_source = MapSource.createHybridAerialSource();
@@ -381,7 +356,7 @@ var MapView = GObject.registerClass({
                 }
             } else {
                 if (tiles.streetDark &&
-                    Hdy.StyleManager.get_default().dark) {
+                    Handy.StyleManager.get_default().dark) {
                     this.view.map_source = MapSource.createStreetDarkSource();
                 } else {
                     this.view.map_source = MapSource.createStreetSource();
@@ -391,7 +366,7 @@ var MapView = GObject.registerClass({
             Application.settings.set('map-type', mapType);
         } else {
             let renderer = new Champlain.ImageRenderer();
-            let source = new Maps.FileTileSource({
+            let source = new GnomeMaps.FileTileSource({
                 path: Utils.getBufferText(Application.application.local_tile_path),
                 renderer: renderer,
                 tile_size: Application.application.local_tile_size || 512
@@ -404,7 +379,7 @@ var MapView = GObject.registerClass({
                 let [lat, lon] = this.view.world.get_center();
                 this.view.center_on(lat, lon);
             } catch(e) {
-                this.setMapType(MapType.STREET);
+                this.setMapType(MapView.MapType.STREET);
                 Application.application.local_tile_path = false;
                 Utils.showDialog(e.message, Gtk.MessageType.ERROR, this._mainWindow);
             }
@@ -478,7 +453,7 @@ var MapView = GObject.registerClass({
     }
 
     _loadShapeLayers(files) {
-        let bbox = new BoundingBox.BoundingBox();
+        let bbox = new BoundingBox();
         this._remainingFilesToLoad = files.length;
 
         files.forEach((file) => {
@@ -515,14 +490,14 @@ var MapView = GObject.registerClass({
 
     goToGeoURI(uri) {
         try {
-            let location = new Location.Location({ heading: -1 });
+            let location = new Location({ heading: -1 });
             location.set_from_uri(uri);
 
-            let place = new Place.Place({ location: location,
-                                          name: location.description,
-                                          store: false });
-            let marker = new PlaceMarker.PlaceMarker({ place: place,
-                                                       mapView: this });
+            let place = new Place({ location: location,
+                                    name: location.description,
+                                    store: false });
+            let marker = new PlaceMarker({ place: place,
+                                           mapView: this });
             this._placeLayer.add_marker(marker);
             marker.goToAndSelect(true);
         } catch(e) {
@@ -535,8 +510,8 @@ var MapView = GObject.registerClass({
     goToHttpURL(url) {
         Place.parseHttpURL(url, (place, error) => {
             if (place) {
-                let marker = new PlaceMarker.PlaceMarker({ place: place,
-                                                           mapView: this });
+                let marker = new PlaceMarker({ place: place,
+                                               mapView: this });
 
                 this._placeLayer.add_marker(marker);
                 marker.goToAndSelect(true);
@@ -561,11 +536,11 @@ var MapView = GObject.registerClass({
         let lon = this.view.longitude > 0 ?
                   this.view.longitude - 180 : this.view.longitude + 180;
         let place =
-            new Place.Place({ location: new Location.Location({ latitude: lat,
-                                                                longitude: lon }),
-                              initialZoom: this.view.zoom_level });
+            new Place({ location: new Location({ latitude: lat,
+                                                 longitude: lon }),
+                        initialZoom: this.view.zoom_level });
 
-        new MapWalker.MapWalker(place, this).goTo(true);
+        new MapWalker(place, this).goTo(true);
     }
 
     userLocationVisible() {
@@ -586,8 +561,8 @@ var MapView = GObject.registerClass({
 
         if (!this._userLocation) {
             let place = Application.geoclue.place;
-            this._userLocation = new UserLocationMarker.UserLocationMarker({ place: place,
-                                                                             mapView: this });
+            this._userLocation = new UserLocationMarker({ place: place,
+                                                          mapView: this });
             this._userLocationLayer.remove_all();
             this._userLocation.addToLayer(this._userLocationLayer);
         }
@@ -626,17 +601,17 @@ var MapView = GObject.registerClass({
             else
                 Utils.debug('Invalid initial zoom level: ' + zoom);
 
-            if (lat >= MIN_LATITUDE && lat <= MAX_LATITUDE &&
-                lon >= MIN_LONGITUDE && lon <= MAX_LONGITUDE)
+            if (lat >= MapView.MIN_LATITUDE && lat <= MapView.MAX_LATITUDE &&
+                lon >= MapView.MIN_LONGITUDE && lon <= MapView.MAX_LONGITUDE)
                 this.view.center_on(location[0], location[1]);
             else
                 Utils.debug('Invalid initial coordinates: ' + lat + ', ' + lon);
         } else {
             /* bounding box. for backwards compatibility, not used anymore */
-            let bbox = new BoundingBox.BoundingBox({ top: location[0],
-                                                     bottom: location[1],
-                                                     left: location[2],
-                                                     right: location[3] });
+            let bbox = new BoundingBox({ top: location[0],
+                                         bottom: location[1],
+                                         left: location[2],
+                                         right: location[3] });
             this.view.connect("notify::realized", () => {
                 if (this.view.realized)
                     this.gotoBBox(bbox, true);
@@ -651,15 +626,15 @@ var MapView = GObject.registerClass({
         }
 
         let [lon, lat] = bbox.getCenter();
-        let place = new Place.Place({
-            location: new Location.Location({ latitude  : lat,
+        let place = new Place({
+            location: new Location({ latitude  : lat,
                                               longitude : lon }),
-            bounding_box: new Geocode.BoundingBox({ top    : bbox.top,
-                                                    bottom : bbox.bottom,
-                                                    left   : bbox.left,
-                                                    right  : bbox.right })
+            bounding_box: new GeocodeGlib.BoundingBox({ top    : bbox.top,
+                                                        bottom : bbox.bottom,
+                                                        left   : bbox.left,
+                                                        right  : bbox.right })
         });
-        new MapWalker.MapWalker(place, this).goTo(true, linear);
+        new MapWalker(place, this).goTo(true, linear);
     }
 
     getZoomLevelFittingBBox(bbox) {
@@ -697,8 +672,8 @@ var MapView = GObject.registerClass({
         if (turnPoint.isStop())
             return;
 
-        this._turnPointMarker = new TurnPointMarker.TurnPointMarker({ turnPoint: turnPoint,
-                                                                      mapView: this });
+        this._turnPointMarker = new TurnPointMarker({ turnPoint: turnPoint,
+                                                      mapView: this });
         this._instructionMarkerLayer.add_marker(this._turnPointMarker);
         this._turnPointMarker.goTo();
     }
@@ -707,9 +682,9 @@ var MapView = GObject.registerClass({
         if (this._turnPointMarker)
             this._turnPointMarker.destroy();
 
-        this._turnPointMarker = new TurnPointMarker.TurnPointMarker({ transitStop: transitStop,
-                                                                      transitLeg: transitLeg,
-                                                                      mapView: this });
+        this._turnPointMarker = new TurnPointMarker({ transitStop: transitStop,
+                                                      transitLeg: transitLeg,
+                                                      mapView: this });
         this._instructionMarkerLayer.add_marker(this._turnPointMarker);
         this._turnPointMarker.goTo();
     }
@@ -721,14 +696,14 @@ var MapView = GObject.registerClass({
 
         this._placeLayer.remove_all();
         places.forEach((p) => {
-            let place = new ContactPlace.ContactPlace({ place: p,
-                                                        contact: contact });
-            let marker = new PlaceMarker.PlaceMarker({ place: place,
-                                                       mapView: this });
+            let place = new ContactPlace({ place: p,
+                                           contact: contact });
+            let marker = new PlaceMarker({ place: place,
+                                           mapView: this });
             this._placeLayer.add_marker(marker);
         });
 
-        new MapWalker.MapWalker(places[0], this).goTo(true);
+        new MapWalker(places[0], this).goTo(true);
     }
 
     _showStoredRoute(stored) {
@@ -759,14 +734,14 @@ var MapView = GObject.registerClass({
     showPlace(place, animation) {
         this._placeLayer.remove_all();
 
-        if (place instanceof StoredRoute.StoredRoute) {
+        if (place instanceof StoredRoute) {
             this._showStoredRoute(place);
             return;
         }
 
         this.routingOpen = false;
-        let placeMarker = new PlaceMarker.PlaceMarker({ place: place,
-                                                        mapView: this });
+        let placeMarker = new PlaceMarker({ place: place,
+                                            mapView: this });
 
         this._placeLayer.add_marker(placeMarker);
         placeMarker.goToAndSelect(animation);
@@ -799,9 +774,9 @@ var MapView = GObject.registerClass({
         route.turnPoints.forEach((turnPoint) => {
             if (turnPoint.isStop()) {
                 let queryPoint = query.filledPoints[pointIndex];
-                let destinationMarker = new TurnPointMarker.TurnPointMarker({ turnPoint: turnPoint,
-                                                                              queryPoint: queryPoint,
-                                                                              mapView: this });
+                let destinationMarker = new TurnPointMarker({ turnPoint: turnPoint,
+                                                              queryPoint: queryPoint,
+                                                              mapView: this });
                 this._instructionMarkerLayer.add_marker(destinationMarker);
                 pointIndex++;
             }
@@ -869,12 +844,12 @@ var MapView = GObject.registerClass({
             /* add start marker */
             let start;
             if (!leg.transit) {
-                start = new TransitWalkMarker.TransitWalkMarker({ leg: leg,
-                                                                  previousLeg: previousLeg,
-                                                                  mapView: this });
+                start = new TransitWalkMarker({ leg: leg,
+                                                previousLeg: previousLeg,
+                                                mapView: this });
             } else {
-                start = new TransitBoardMarker.TransitBoardMarker({ leg: leg,
-                                                                    mapView: this });
+                start = new TransitBoardMarker({ leg: leg,
+                                                 mapView: this });
             }
 
             this._instructionMarkerLayer.add_marker(start);
@@ -882,8 +857,8 @@ var MapView = GObject.registerClass({
 
         /* add arrival marker */
         let lastLeg = itinerary.legs.last();
-        let arrival = new TransitArrivalMarker.TransitArrivalMarker({ leg: lastLeg,
-                                                                      mapView: this });
+        let arrival = new TransitArrivalMarker({ leg: lastLeg,
+                                                 mapView: this });
         this._instructionMarkerLayer.add_marker(arrival);
 
         this.routingOpen = true;
@@ -907,4 +882,32 @@ var MapView = GObject.registerClass({
     onSetMarkerSelected(selectedMarker) {
         this.emit('marker-selected', selectedMarker);
     }
-});
+}
+
+GObject.registerClass({
+    Properties: {
+        // this property is true when the routing sidebar is active
+        'routingOpen': GObject.ParamSpec.boolean('routingOpen',
+                                                  'Routing open',
+                                                  'Routing sidebar open',
+                                                  GObject.ParamFlags.READABLE |
+                                                  GObject.ParamFlags.WRITABLE,
+                                                  false),
+        /* this property is true when a route is being shown on the map */
+        'routeShowing': GObject.ParamSpec.boolean('routeShowing',
+                                                 'Route showing',
+                                                 'Showing a route on the map',
+                                                 GObject.ParamFlags.READABLE |
+                                                 GObject.ParamFlags.WRITABLE,
+                                                 false)
+    },
+    Signals: {
+        'user-location-changed': {},
+        'going-to': {},
+        'going-to-user-location': {},
+        'gone-to-user-location': {},
+        'view-moved': {},
+        'marker-selected': { param_types: [Champlain.Marker] },
+        'map-type-changed': { param_types: [GObject.TYPE_STRING] }
+    },
+}, MapView);
diff --git a/src/mapWalker.js b/src/mapWalker.js
index dcef258c..b6e9a421 100644
--- a/src/mapWalker.js
+++ b/src/mapWalker.js
@@ -21,38 +21,34 @@
  *         Damián Nohales <damiannohales gmail com>
  */
 
-const Clutter = imports.gi.Clutter;
-const GObject = imports.gi.GObject;
+import Clutter from 'gi://Clutter';
+import GObject from 'gi://GObject';
 
-const BoundingBox = imports.boundingBox;
-const Location = imports.location;
-const PlaceZoom = imports.placeZoom;
-const Utils = imports.utils;
+import {BoundingBox} from './boundingBox.js';
+import {Location} from './location.js';
+import * as PlaceZoom from './placeZoom.js';
+import * as Utils from './utils.js';
 
 const _MAX_DISTANCE = 19850; // half of Earth's circumference (km)
 const _MIN_ANIMATION_DURATION = 2000; // msec
 const _MAX_ANIMATION_DURATION = 5000; // msec
 
-var MapWalker = GObject.registerClass({
-    Signals: {
-        'gone-to': { }
-    }
-}, class MapWalker extends GObject.Object {
+export class MapWalker extends GObject.Object {
 
-    _init(place, mapView) {
+    constructor(place, mapView) {
         this.place = place;
         this._mapView = mapView;
         this._view = mapView.view;
         this._boundingBox = this._createBoundingBox(this.place);
-        super._init();
+        super();
     }
 
     _createBoundingBox(place) {
         if (place.bounding_box !== null) {
-            return new BoundingBox.BoundingBox({ top: place.bounding_box.top,
-                                                 bottom: place.bounding_box.bottom,
-                                                 left: place.bounding_box.left,
-                                                 right: place.bounding_box.right });
+            return new BoundingBox({ top: place.bounding_box.top,
+                                     bottom: place.bounding_box.bottom,
+                                     left: place.bounding_box.left,
+                                     right: place.bounding_box.right });
         } else {
             return null;
         }
@@ -100,8 +96,8 @@ var MapWalker = GObject.registerClass({
             return;
         }
 
-        let fromLocation = new Location.Location({ latitude: this._view.get_center_latitude(),
-                                                   longitude: this._view.get_center_longitude() });
+        let fromLocation = new Location({ latitude: this._view.get_center_latitude(),
+                                          longitude: this._view.get_center_longitude() });
         this._updateGoToDuration(fromLocation);
 
         if (linear) {
@@ -143,10 +139,10 @@ var MapWalker = GObject.registerClass({
 
             visibleBox.extend(fromLocation.latitude, fromLocation.longitude);
         } else {
-            visibleBox = new BoundingBox.BoundingBox({ left:   180,
-                                                       right: -180,
-                                                       bottom:  90,
-                                                       top:    -90 });
+            visibleBox = new BoundingBox({ left:   180,
+                                           right: -180,
+                                           bottom:  90,
+                                           top:    -90 });
 
             [fromLocation, this.place.location].forEach((location) => {
                 visibleBox.left   = Math.min(visibleBox.left,   location.longitude);
@@ -195,4 +191,10 @@ var MapWalker = GObject.registerClass({
         // ensure_visible as 'goto' journeys with its own duration.
         this._view.goto_animation_duration = duration / 2;
     }
-});
+}
+
+GObject.registerClass({
+    Signals: {
+        'gone-to': { }
+    }
+}, MapWalker);
diff --git a/src/org.gnome.Maps.in b/src/org.gnome.Maps.in
index 1cd74738..133656e8 100755
--- a/src/org.gnome.Maps.in
+++ b/src/org.gnome.Maps.in
@@ -1,5 +1,11 @@
 #!@GJS@
-imports.package.start({ name: "gnome-maps",
-                        version: "@PACKAGE_VERSION@",
-                        prefix: "@prefix@",
-                        libdir: "@libdir@" });
+imports.package.init({ name: "gnome-maps",
+                       version: "@PACKAGE_VERSION@",
+                       prefix: "@prefix@",
+                       libdir: "@libdir@" });
+
+import(`resource:///org/gnome/Maps@suffix@/js/main.js`).catch(error => {
+    console.error(error);
+    imports.system.exit(1);
+});
+
diff --git a/src/org.gnome.Maps.src.gresource.xml.in b/src/org.gnome.Maps.src.gresource.xml.in
index 1f3b93d7..06414a1f 100644
--- a/src/org.gnome.Maps.src.gresource.xml.in
+++ b/src/org.gnome.Maps.src.gresource.xml.in
@@ -116,5 +116,17 @@
     <file>transitplugins/opendataCH.js</file>
     <file>transitplugins/openTripPlanner.js</file>
     <file>transitplugins/resrobot.js</file>
+
+    <file alias="addressTest.js">../tests/addressTest.js</file>
+    <file alias="boundingBoxTest.js">../tests/boundingBoxTest.js</file>
+    <file alias="colorTest.js">../tests/colorTest.js</file>
+    <file alias="osmNamesTest.js">../tests/osmNamesTest.js</file>
+    <file alias="placeIconsTest.js">../tests/placeIconsTest.js</file>
+    <file alias="placeZoomTest.js">../tests/placeZoomTest.js</file>
+    <file alias="timeTest.js">../tests/timeTest.js</file>
+    <file alias="translationsTest.js">../tests/translationsTest.js</file>
+    <file alias="urisTest.js">../tests/urisTest.js</file>
+    <file alias="utilsTest.js">../tests/utilsTest.js</file>
+    <file alias="wikipediaTest.js">../tests/wikipediaTest.js</file>
   </gresource>
 </gresources>
diff --git a/src/osmAccountDialog.js b/src/osmAccountDialog.js
index 21c63fe3..ff31a2a3 100644
--- a/src/osmAccountDialog.js
+++ b/src/osmAccountDialog.js
@@ -20,36 +20,24 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
 
-const Application = imports.application;
-const Utils = imports.utils;
+import {Application} from './application.js';
+import * as Utils from './utils.js';
 
-var Response = {
-    SIGNED_IN: 0
-};
+export class OSMAccountDialog extends Gtk.Dialog {
 
-var OSMAccountDialog = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/osm-account-dialog.ui',
-    InternalChildren: ['stack',
-                       'signInButton',
-                       'signInSpinner',
-                       'verificationEntry',
-                       'verifyButton',
-                       'errorLabel',
-                       'signedInUserLabel',
-                       'signOutButton'],
-}, class OSMAccountDialog extends Gtk.Dialog {
+    static Response = { SIGNED_IN: 0 };
 
-    _init(params) {
+    constructor(params) {
         /* This is a construct-only property and cannot be set by GtkBuilder */
         params.use_header_bar = true;
 
         this._closeOnSignIn = params.closeOnSignIn;
         delete params.closeOnSignIn;
 
-        super._init(params);
+        super(params);
 
         this._signInButton.connect('clicked',
                                    this._onSignInButtonClicked.bind(this));
@@ -174,4 +162,16 @@ var OSMAccountDialog = GObject.registerClass({
         this._signInButton.sensitive= true;
         this._stack.visible_child_name = 'sign-in';
     }
-});
+}
+
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/osm-account-dialog.ui',
+    InternalChildren: ['stack',
+                       'signInButton',
+                       'signInSpinner',
+                       'verificationEntry',
+                       'verifyButton',
+                       'errorLabel',
+                       'signedInUserLabel',
+                       'signOutButton'],
+}, OSMAccountDialog);
diff --git a/src/osmConnection.js b/src/osmConnection.js
index f20e8600..09768927 100644
--- a/src/osmConnection.js
+++ b/src/osmConnection.js
@@ -20,16 +20,16 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const _ = imports.gettext.gettext;
+//const _ = imports.gettext.gettext;
 
-const Maps = imports.gi.GnomeMaps;
+import GnomeMaps from 'gi://GnomeMaps';
 
-const Gio = imports.gi.Gio;
-const Rest = imports.gi.Rest;
-const Secret = imports.gi.Secret;
-const Soup = imports.gi.Soup;
+import Gio from 'gi://Gio';
+import Rest from 'gi://Rest';
+import Secret from 'gi://Secret';
+import Soup from 'gi://Soup';
 
-const Utils = imports.utils;
+import * as Utils from './utils.js';
 
 const BASE_URL = 'https://api.openstreetmap.org/api';
 const API_VERSION = '0.6';
@@ -46,7 +46,7 @@ const SECRET_SCHEMA = new Secret.Schema("org.gnome.Maps",
     }
 );
 
-var OSMConnection = class OSMConnection {
+export class OSMConnection {
 
     constructor() {
         this._session = new Soup.Session({ user_agent : 'gnome-maps/' + pkg.version });
@@ -55,7 +55,7 @@ var OSMConnection = class OSMConnection {
         this._callProxy = Rest.OAuthProxy.new(CONSUMER_KEY, CONSUMER_SECRET,
                                               BASE_URL + '/' + API_VERSION,
                                               false);
-        Maps.osm_init();
+        GnomeMaps.osm_init();
     }
 
     getOSMObject(type, id, callback, cancellable) {
@@ -74,8 +74,8 @@ var OSMConnection = class OSMConnection {
             }
 
             try {
-                let object = Maps.osm_parse (message.response_body.data,
-                                             message.response_body.length);
+                let object = GnomeMaps.osm_parse (message.response_body.data,
+                                                  message.response_body.length);
                 callback(true, message.status_code, object, type, null);
             } catch (e) {
                 Utils.debug(e);
@@ -121,10 +121,10 @@ var OSMConnection = class OSMConnection {
 
     _doOpenChangeset(comment, callback) {
         let changeset =
-            Maps.OSMChangeset.new(comment, 'gnome-maps ' + pkg.version);
+            GnomeMaps.OSMChangeset.new(comment, 'gnome-maps ' + pkg.version);
         let xml = changeset.serialize();
 
-        let call = Maps.OSMOAuthProxyCall.new(this._callProxy, xml);
+        let call = GnomeMaps.OSMOAuthProxyCall.new(this._callProxy, xml);
         call.set_method('PUT');
         call.set_function('/changeset/create');
 
@@ -146,7 +146,7 @@ var OSMConnection = class OSMConnection {
         object.changeset = changeset;
 
         let xml = object.serialize();
-        let call = Maps.OSMOAuthProxyCall.new(this._callProxy, xml);
+        let call = GnomeMaps.OSMOAuthProxyCall.new(this._callProxy, xml);
 
         call.set_method('PUT');
         call.set_function(this._getCreateOrUpdateFunction(object, type));
@@ -168,7 +168,7 @@ var OSMConnection = class OSMConnection {
         object.changeset = changeset;
 
         let xml = object.serialize();
-        let call = Maps.OSMOAuthProxyCall.new(this._callProxy, xml);
+        let call = GnomeMaps.OSMOAuthProxyCall.new(this._callProxy, xml);
 
         call.set_method('DELETE');
         call.set_function(this._getDeleteFunction(object, type));
@@ -274,7 +274,7 @@ var OSMConnection = class OSMConnection {
         switch (call.get_status_code()) {
             case Soup.Status.OK:
                 try {
-                    callback(Maps.osm_parse_user_details(call.get_payload()));
+                    callback(GnomeMaps.osm_parse_user_details(call.get_payload()));
                 } catch (e) {
                     Utils.debug('Error parsing user details: ' + e.message);
                     callback(null);
@@ -339,32 +339,32 @@ var OSMConnection = class OSMConnection {
     _onPasswordCleared(source, result) {
         Secret.password_clear_finish(result);
     }
-};
 
-/*
- * Gets a status message (usually for an error case)
- * to show for a given OSM server response.
- */
-function getStatusMessage(statusCode) {
-    switch (statusCode) {
-    case Soup.Status.IO_ERROR:
-    case Soup.Status.UNAUTHORIZED:
-        /* setting the status in session.cancel_message still seems
-           to always give status IO_ERROR */
-        return _("Incorrect user name or password");
-    case Soup.Status.OK:
-        return _("Success");
-    case Soup.Status.BAD_REQUEST:
-        return _("Bad request");
-    case Soup.Status.NOT_FOUND:
-        return _("Object not found");
-    case Soup.Status.CONFLICT:
-        return _("Conflict, someone else has just modified the object");
-    case Soup.Status.GONE:
-        return _("Object has been deleted");
-    case Soup.Status.PRECONDITION_FAILED:
-        return _("Way or relation refers to non-existing children");
-    default:
-        return null;
+    /*
+     * Gets a status message (usually for an error case)
+     * to show for a given OSM server response.
+     */
+    static getStatusMessage(statusCode) {
+        switch (statusCode) {
+        case Soup.Status.IO_ERROR:
+        case Soup.Status.UNAUTHORIZED:
+            /* setting the status in session.cancel_message still seems
+               to always give status IO_ERROR */
+            return _("Incorrect user name or password");
+        case Soup.Status.OK:
+            return _("Success");
+        case Soup.Status.BAD_REQUEST:
+            return _("Bad request");
+        case Soup.Status.NOT_FOUND:
+            return _("Object not found");
+        case Soup.Status.CONFLICT:
+            return _("Conflict, someone else has just modified the object");
+        case Soup.Status.GONE:
+            return _("Object has been deleted");
+        case Soup.Status.PRECONDITION_FAILED:
+            return _("Way or relation refers to non-existing children");
+        default:
+            return null;
+        }
     }
 }
diff --git a/src/osmEdit.js b/src/osmEdit.js
index bd3d6256..32ff2e81 100644
--- a/src/osmEdit.js
+++ b/src/osmEdit.js
@@ -20,16 +20,16 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const Application = imports.application;
-const OSMAccountDialog = imports.osmAccountDialog;
-const OSMEditDialog = imports.osmEditDialog;
-const OSMConnection = imports.osmConnection;
-const Utils = imports.utils;
+import {Application} from './application.js';
+import {OSMAccountDialog} from './osmAccountDialog.js';
+import {OSMEditDialog} from './osmEditDialog.js';
+import {OSMConnection} from './osmConnection.js';
+import * as Utils from './utils.js';
 
-/* minimum zoom level at which to offer adding a location */
-var MIN_ADD_LOCATION_ZOOM_LEVEL = 16;
+export class OSMEdit {
 
-var OSMEdit = class OSMEdit {
+    // minimum zoom level at which to offer adding a location
+    static get MIN_ADD_LOCATION_ZOOM_LEVEL() { return 16};
 
     constructor() {
         this._osmConnection = new OSMConnection.OSMConnection();
@@ -191,4 +191,4 @@ var OSMEdit = class OSMEdit {
     get username() {
         return this._username;
     }
-};
+}
diff --git a/src/osmEditDialog.js b/src/osmEditDialog.js
index 7b28d051..2ee25481 100644
--- a/src/osmEditDialog.js
+++ b/src/osmEditDialog.js
@@ -20,30 +20,25 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const _ = imports.gettext.gettext;
-
-const Geocode = imports.gi.GeocodeGlib;
-const Gio = imports.gi.Gio;
-const GLib = imports.gi.GLib;
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
-const Soup = imports.gi.Soup;
-
-const Application = imports.application;
-const Maps = imports.gi.GnomeMaps;
-const OSMConnection = imports.osmConnection;
-const OSMTypes = imports.osmTypes;
-const OSMTypeSearchEntry = imports.osmTypeSearchEntry;
-const OSMUtils = imports.osmUtils;
-const Utils = imports.utils;
-const Wikipedia = imports.wikipedia;
-
-var Response = {
-    UPLOADED: 0,
-    DELETED: 1,
-    CANCELLED: 2,
-    ERROR: 3
-};
+import gettext from 'gettext';
+
+const _ = gettext.gettext;
+
+import GeocodeGlib from 'gi://GeocodeGlib';
+import Gio from 'gi://Gio';
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
+import Soup from 'gi://Soup';
+
+import {Application} from './application.js';
+import GnomeMaps from 'gi://GnomeMaps';
+import {OSMConnection} from './osmConnection.js';
+import * as OSMTypes from './osmTypes.js';
+import {OSMTypeSearchEntry} from './osmTypeSearchEntry.js';
+import * as OSMUtils from './osmUtils.js';
+import * as Utils from './utils.js';
+import * as Wikipedia from './wikipedia.js';
 
 /*
  * enumeration representing
@@ -146,7 +141,7 @@ const OSM_FIELDS = [
         name: _("Phone"),
         tag: 'phone',
         type: EditFieldType.TEXT,
-        rewriteFunc: this._osmPhoneRewriteFunc,
+        rewriteFunc: _osmPhoneRewriteFunc,
         hint: _("Phone number. Use the international format, " +
                 "starting with a + sign. Beware of local privacy " +
                 "laws, especially for private phone numbers.")
@@ -156,7 +151,7 @@ const OSM_FIELDS = [
         tag: 'email',
         type: EditFieldType.TEXT,
         validate: Utils.isValidEmail,
-        rewriteFunc: this._osmEmailRewriteFunc,
+        rewriteFunc: _osmEmailRewriteFunc,
         validateError: _("This is not a valid e-mail address. Make sure to not include the mailto: protocol 
prefix."),
         hint: _("Contact e-mail address for inquiries. " +
                 "Add only email addresses that are intended to be publicly used.")
@@ -166,7 +161,7 @@ const OSM_FIELDS = [
         tag: 'wikipedia',
         type: EditFieldType.TEXT,
         validate: Wikipedia.isValidWikipedia,
-        rewriteFunc: this._osmWikipediaRewriteFunc,
+        rewriteFunc: _osmWikipediaRewriteFunc,
         hint: _("The format used should include the language code " +
                 "and the article title like “en:Article title”.")
     },
@@ -258,15 +253,9 @@ const OSM_FIELDS = [
         hint: _("Information used to inform other mappers about non-obvious information about an element, 
the author’s intent when creating it, or hints for further improvement.")
     }];
 
-const OSMEditAddress = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/osm-edit-address.ui',
-    Children: [ 'street',
-                'number',
-                'post',
-                'city' ],
-}, class OSMEditAddress extends Gtk.Grid {
+export class OSMEditAddress extends Gtk.Grid {
 
-    _init(params) {
+    constructor(params) {
         let street = params.street;
         delete params.street;
 
@@ -279,7 +268,7 @@ const OSMEditAddress = GObject.registerClass({
         let city = params.city;
         delete params.city;
 
-        super._init(params);
+        super(params);
 
         if (street)
             this.street.text = street;
@@ -293,31 +282,26 @@ const OSMEditAddress = GObject.registerClass({
         if (city)
             this.city.text = city;
     }
-});
+}
 
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/osm-edit-address.ui',
+    Children: [ 'street',
+                'number',
+                'post',
+                'city' ],
+}, OSMEditAddress);
 
-var OSMEditDialog = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/osm-edit-dialog.ui',
-    InternalChildren: [ 'cancelButton',
-                        'backButton',
-                        'nextButton',
-                        'stack',
-                        'editorGrid',
-                        'commentTextView',
-                        'addFieldPopoverGrid',
-                        'addFieldButton',
-                        'typeSearchGrid',
-                        'typeLabel',
-                        'typeButton',
-                        'typeValueLabel',
-                        'recentTypesLabel',
-                        'recentTypesListBox',
-                        'hintPopover',
-                        'hintLabel',
-                        'headerBar'],
-}, class OSMEditDialog extends Gtk.Dialog {
+export class OSMEditDialog extends Gtk.Dialog {
 
-    _init(params) {
+    static Response = {
+        UPLOADED: 0,
+        DELETED: 1,
+        CANCELLED: 2,
+        ERROR: 3
+    };
+
+    constructor(params) {
         this._place = params.place;
         delete params.place;
 
@@ -333,7 +317,7 @@ var OSMEditDialog = GObject.registerClass({
         /* This is a construct-only property and cannot be set by GtkBuilder */
         params.use_header_bar = true;
 
-        super._init(params);
+        super(params);
 
         /* I could not get this widget working from within the widget template
          * this results in a segfault. The widget definition is left in-place,
@@ -366,13 +350,13 @@ var OSMEditDialog = GObject.registerClass({
 
             /* the OSMObject ID, version, and changeset ID is unknown for now */
             let newNode =
-                Maps.OSMNode.new(0, 0, 0, this._longitude, this._latitude);
+                GnomeMaps.OSMNode.new(0, 0, 0, this._longitude, this._latitude);
             /* set a placeholder name tag to always get a name entry for new
              * locations */
             newNode.set_tag('name', '');
             this._loadOSMData(newNode);
             this._isEditing = true;
-            this._osmType = Geocode.PlaceOsmType.NODE;
+            this._osmType = GeocodeGlib.PlaceOsmType.NODE;
         } else {
             this._osmType = this._place.osmType;
             Application.osmEdit.fetchObject(this._place,
@@ -904,4 +888,25 @@ var OSMEditDialog = GObject.registerClass({
         this._updateTypeButton();
         this._stack.visible_child_name = 'editor';
     }
-});
+}
+
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/osm-edit-dialog.ui',
+    InternalChildren: [ 'cancelButton',
+                        'backButton',
+                        'nextButton',
+                        'stack',
+                        'editorGrid',
+                        'commentTextView',
+                        'addFieldPopoverGrid',
+                        'addFieldButton',
+                        'typeSearchGrid',
+                        'typeLabel',
+                        'typeButton',
+                        'typeValueLabel',
+                        'recentTypesLabel',
+                        'recentTypesListBox',
+                        'hintPopover',
+                        'hintLabel',
+                        'headerBar'],
+}, OSMEditDialog);
diff --git a/src/osmNames.js b/src/osmNames.js
index 97ac4613..4162134e 100644
--- a/src/osmNames.js
+++ b/src/osmNames.js
@@ -24,7 +24,7 @@
  * See https://wiki.openstreetmap.org/wiki/Multilingual_names
  */
 
-const Utils = imports.utils
+import * as Utils from './utils.js';
 
 /**
  * Mapping writing systems (scripts) to languages (most commonly
@@ -138,7 +138,7 @@ const WRITING_SYSTEMS = [
     }
 ];
 
-function getNameForLanguageAndCountry(tags, language, country) {
+export function getNameForLanguageAndCountry(tags, language, country) {
     let localizedName = _getNameInLanguage(tags, language);
 
     /* for names in Norwegian, the best practice in OSM is to use the
@@ -154,7 +154,7 @@ function getNameForLanguageAndCountry(tags, language, country) {
                                                                  country);
 }
 
-function _getFallbackNameForLanguageAndCountry(tags, language, country) {
+export function _getFallbackNameForLanguageAndCountry(tags, language, country) {
     let intName;
 
     if (_predominantWritingSystemMatchesLanguage(country, language) && tags.name)
diff --git a/src/osmTypeListRow.js b/src/osmTypeListRow.js
index 795d203c..84bb0c48 100644
--- a/src/osmTypeListRow.js
+++ b/src/osmTypeListRow.js
@@ -19,19 +19,16 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
 
-var OSMTypeListRow = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/osm-type-list-row.ui',
-    InternalChildren: [ 'name' ]
-}, class OSMTypeListRow extends Gtk.ListBoxRow {
+export class OSMTypeListRow extends Gtk.ListBoxRow {
 
-    _init(props) {
+    constructor(props) {
         this._type = props.type;
         delete props.type;
 
-        super._init(props);
+        super(props);
 
         this._name.label = this._type.title;
     }
@@ -47,4 +44,9 @@ var OSMTypeListRow = GObject.registerClass({
     get title() {
         return this._type.title;
     }
-});
+}
+
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/osm-type-list-row.ui',
+    InternalChildren: [ 'name' ]
+}, OSMTypeListRow);
diff --git a/src/osmTypePopover.js b/src/osmTypePopover.js
index 664ae721..8d1ce588 100644
--- a/src/osmTypePopover.js
+++ b/src/osmTypePopover.js
@@ -19,26 +19,16 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
 
-const OSMTypeListRow = imports.osmTypeListRow;
-const SearchPopover = imports.searchPopover;
+import {OSMTypeListRow} from './osmTypeListRow.js';
+import {SearchPopover} from './searchPopover.js';
 
-var OSMTypePopover = GObject.registerClass({
-    InternalChildren: ['list'],
-    Template: 'resource:///org/gnome/Maps/ui/osm-type-popover.ui',
-    Signals : {
-        /* signal emitted when selecting a type, indicates OSM key and value
-         * and display title */
-        'selected' : { param_types: [ GObject.TYPE_STRING,
-                                      GObject.TYPE_STRING,
-                                      GObject.TYPE_STRING ] }
-    }
-}, class OSMTypePopover extends SearchPopover.SearchPopover {
+export class OSMTypePopover extends SearchPopover {
 
-    _init(props) {
-        super._init(props);
+    constructor(props) {
+        super(props);
 
         this._list.connect('row-activated', (list, row) => {
             if (row)
@@ -58,4 +48,16 @@ var OSMTypePopover = GObject.registerClass({
                                                       can_focus: true });
         this._list.insert(row, -1);
     }
-});
+}
+
+GObject.registerClass({
+    InternalChildren: ['list'],
+    Template: 'resource:///org/gnome/Maps/ui/osm-type-popover.ui',
+    Signals : {
+        /* signal emitted when selecting a type, indicates OSM key and value
+         * and display title */
+        'selected' : { param_types: [ GObject.TYPE_STRING,
+                                      GObject.TYPE_STRING,
+                                      GObject.TYPE_STRING ] }
+    }
+}, OSMTypePopover);
diff --git a/src/osmTypeSearchEntry.js b/src/osmTypeSearchEntry.js
index eae92355..e48e954d 100644
--- a/src/osmTypeSearchEntry.js
+++ b/src/osmTypeSearchEntry.js
@@ -19,21 +19,19 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
 
-const OSMTypePopover = imports.osmTypePopover;
-const OSMTypes = imports.osmTypes;
-const Utils = imports.utils;
+import {OSMTypePopover} from './osmTypePopover.js';
+import * as OSMTypes from './osmTypes.js';
+import * as Utils from './utils.js';
 
 const MAX_MATCHES = 10;
 
-var OSMTypeSearchEntry = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/osm-type-search-entry.ui'
-}, class OSMTypeSearchEntry extends Gtk.SearchEntry {
+export class OSMTypeSearchEntry extends Gtk.SearchEntry {
 
-    _init(props) {
-        super._init(props);
+    constructor(props) {
+        super(props);
 
         this._popover =
             new OSMTypePopover.OSMTypePopover({relative_to: this});
@@ -72,4 +70,8 @@ var OSMTypeSearchEntry = GObject.registerClass({
             }
         }
     }
-});
+}
+
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/osm-type-search-entry.ui'
+}, OSMTypeSearchEntry);
diff --git a/src/osmUtils.js b/src/osmUtils.js
index 866d063f..66ea6184 100644
--- a/src/osmUtils.js
+++ b/src/osmUtils.js
@@ -20,9 +20,9 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const Soup = imports.gi.Soup;
+import Soup from 'gi://Soup';
 
-const Application = imports.application;
+import {Application} from './application.js';
 
 /*
  * Gets a Wikipedia article in OSM tag format (i.e. lang:Article title)
diff --git a/src/overpass.js b/src/overpass.js
index 2265f24c..eb561c1f 100644
--- a/src/overpass.js
+++ b/src/overpass.js
@@ -18,14 +18,15 @@
  */
 
 const Format = imports.format;
-const Geocode = imports.gi.GeocodeGlib;
-const GObject = imports.gi.GObject;
-const Soup = imports.gi.Soup;
 
-const OSMNames = imports.osmNames;
-const PhotonParser = imports.photonParser;
-const Place = imports.place;
-const Utils = imports.utils;
+import Geocode from 'gi://GeocodeGlib';
+import GObject from 'gi://GObject';
+import Soup from 'gi://Soup';
+
+import * as OSMNames from './osmNames.js';
+import * as PhotonParser from './photonParser.js';
+import {Place} from './place.js';
+import * as Utils from './utils.js';
 
 const _DEFAULT_TIMEOUT = 180;
 const _DEFAULT_MAXSIZE = 536870912;
@@ -36,21 +37,12 @@ const _DEFAULT_OUTPUT_SORT_ORDER = 'qt';
 
 const BASE_URL = 'https://overpass-api.de/api/interpreter';
 
-var Overpass = GObject.registerClass({
-    Properties: {
-        'place': GObject.ParamSpec.object('place',
-                                          'Place',
-                                          'Place with added information',
-                                          GObject.ParamFlags.READABLE |
-                                          GObject.ParamFlags.WRITABLE,
-                                          Geocode.Place)
-    }
-}, class Overpass extends GObject.Object {
+export class Overpass extends GObject.Object {
 
-    _init(params) {
+    constructor(params) {
         params = params || { };
 
-        super._init();
+        super();
 
         // maximum allowed runtime for the query in seconds
         this.timeout = params.timeout || _DEFAULT_TIMEOUT;
@@ -249,4 +241,16 @@ var Overpass = GObject.registerClass({
                                                        this.outputSortOrder,
                                                        this.outputCount ]);
     }
-});
+}
+
+GObject.registerClass({
+    Properties: {
+        'place': GObject.ParamSpec.object('place',
+                                          'Place',
+                                          'Place with added information',
+                                          GObject.ParamFlags.READABLE |
+                                          GObject.ParamFlags.WRITABLE,
+                                          Geocode.Place)
+    }},
+    Overpass
+);
diff --git a/src/photonGeocode.js b/src/photonGeocode.js
index 38d88ca2..159db1f1 100644
--- a/src/photonGeocode.js
+++ b/src/photonGeocode.js
@@ -21,19 +21,19 @@
 
 const Format = imports.format;
 
-const GLib = imports.gi.GLib;
-const Soup = imports.gi.Soup;
+import GLib from 'gi://GLib';
+import Soup from 'gi://Soup';
 
-const Application = imports.application;
-const HTTP = imports.http;
-const PhotonParser = imports.photonParser;
-const Service = imports.service;
-const Utils = imports.utils;
+import {Application} from './application.js';
+import * as HTTP from './http.js';
+import * as PhotonParser from './photonParser.js';
+import * as Service from './service.js';
+import * as Utils from './utils.js';
 
 // HTTP session timeout (in seconds)
 const TIMEOUT = 5;
 
-var PhotonGeocode = class {
+export class PhotonGeocode {
     constructor() {
         this._session =
             new Soup.Session({ user_agent : 'gnome-maps/' + pkg.version,
diff --git a/src/photonParser.js b/src/photonParser.js
index 041b7734..f5c3634e 100644
--- a/src/photonParser.js
+++ b/src/photonParser.js
@@ -19,14 +19,14 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const _ = imports.gettext.gettext;
+//const _ = imports.gettext.gettext;
 
-const Geocode = imports.gi.GeocodeGlib;
+import Geocode from 'gi://GeocodeGlib';
 
-const Address = imports.address;
-const OSMTypes = imports.osmTypes;
-const Place = imports.place;
-const Utils = imports.utils;
+import * as Address from './address.js';
+import * as OSMTypes from './osmTypes.js';
+import {Place} from './place.js';
+import * as Utils from './utils.js';
 
 function parsePlace(latitude, longitude, properties) {
     let location = new Geocode.Location({ latitude:  latitude,
diff --git a/src/place.js b/src/place.js
index b772a46c..62f8050c 100644
--- a/src/place.js
+++ b/src/place.js
@@ -19,18 +19,18 @@
  * Author: Jonas Danielsson <jonas threetimestwo org>
  */
 
-const _ = imports.gettext.gettext;
+//const _ = imports.gettext.gettext;
 
-const Geocode = imports.gi.GeocodeGlib;
-const Gio = imports.gi.Gio;
-const GLib = imports.gi.GLib;
-const GObject = imports.gi.GObject;
+import Geocode from 'gi://GeocodeGlib';
+import Gio from 'gi://Gio';
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
 
-const Location = imports.location;
-const Overpass = imports.overpass;
-const PlaceIcons = imports.placeIcons;
-const URIS = imports.uris;
-const Utils = imports.utils;
+import {Location} from './location.js';
+import {Overpass} from './overpass.js';
+import * as PlaceIcons from './placeIcons.js';
+import * as URIS from './uris.js';
+import * as Utils from './utils.js';
 
 // Matches coordinates string in 'Decimal Degrees' format
 const DECIMAL_COORDINATES_REGEX = (
@@ -44,10 +44,9 @@ const DMS_COORDINATES_REGEX = new RegExp(
     "i"
 );
 
-var Place = GObject.registerClass(
-class Place extends Geocode.Place {
+export class Place extends Geocode.Place {
 
-    _init(params) {
+    constructor(params) {
         this.updateFromTags(params);
 
         delete params.population;
@@ -117,7 +116,7 @@ class Place extends Geocode.Place {
             if (!params[prop])
                 delete params[prop];
 
-        super._init(params);
+        super(params);
     }
 
     /**
@@ -409,7 +408,9 @@ class Place extends Geocode.Place {
             return false;
         }
     }
-});
+}
+
+GObject.registerClass(Place);
 
 Place.fromJSON = function(obj) {
     let props = { };
@@ -500,7 +501,7 @@ let overpass = null;
 /* we can't import Application before the Place class has been defined
  * since it's used via PlaceStore
  */
-const Application = imports.application;
+import {Application} from './application.js';
 
 function parseHttpURL(text, callback) {
     let [type, id] = URIS.parseAsObjectURL(text);
diff --git a/src/placeButtons.js b/src/placeButtons.js
index acbeeb2a..85c8c20c 100644
--- a/src/placeButtons.js
+++ b/src/placeButtons.js
@@ -20,39 +20,26 @@
  */
 
 
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
-
-const Application = imports.application;
-const ContactPlace = imports.contactPlace;
-const OSMAccountDialog = imports.osmAccountDialog;
-const OSMEditDialog = imports.osmEditDialog;
-const OSMUtils = imports.osmUtils;
-const PlaceStore = imports.placeStore;
-const SendToDialog = imports.sendToDialog;
-
-var PlaceButtons = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/place-buttons.ui',
-    InternalChildren: [ 'routeButton',
-                        'sendToButton',
-                        'favoriteButton',
-                        'editButton',
-                        'favoriteButtonImage' ],
-    Signals: {
-        /* Emitted when the Edit dialog is closed, because the place details
-           might have changed and the parent PlaceBar/PlaceView needs
-           refreshing */
-        'place-edited': {}
-    }
-}, class PlaceButtons extends Gtk.Box {
-    _init(params) {
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
+
+import {Application} from './application.js';
+import {ContactPlace} from './contactPlace.js';
+import {OSMAccountDialog} from './osmAccountDialog.js';
+import {OSMEditDialog} from './osmEditDialog.js';
+import * as OSMUtils from './osmUtils.js';
+import {PlaceStore} from './placeStore.js';
+import {SendToDialog} from './sendToDialog.js';
+
+export class PlaceButtons extends Gtk.Box {
+    constructor(params) {
         let place = params.place;
         delete params.place;
 
         this._mapView = params.mapView;
         delete params.mapView;
 
-        super._init(params);
+        super(params);
 
         this._initSignals();
 
@@ -84,10 +71,10 @@ var PlaceButtons = GObject.registerClass({
 
     initSendToButton(button) {
         button.connect('clicked', () => {
-            let dialog = new SendToDialog.SendToDialog({ transient_for: this.get_toplevel(),
-                                                         modal: true,
-                                                         mapView: this._mapView,
-                                                         place: this._place });
+            let dialog = new SendToDialog({ transient_for: this.get_toplevel(),
+                                            modal: true,
+                                            mapView: this._mapView,
+                                            place: this._place });
             dialog.connect('response', () => dialog.destroy());
             dialog.show();
         });
@@ -184,4 +171,19 @@ var PlaceButtons = GObject.registerClass({
             }
         });
     }
-});
+}
+
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/place-buttons.ui',
+    InternalChildren: [ 'routeButton',
+                        'sendToButton',
+                        'favoriteButton',
+                        'editButton',
+                        'favoriteButtonImage' ],
+    Signals: {
+        /* Emitted when the Edit dialog is closed, because the place details
+           might have changed and the parent PlaceBar/PlaceView needs
+           refreshing */
+        'place-edited': {}
+    }
+}, PlaceButtons);
diff --git a/src/placeFormatter.js b/src/placeFormatter.js
index 58dff6d1..8100772f 100644
--- a/src/placeFormatter.js
+++ b/src/placeFormatter.js
@@ -19,11 +19,11 @@
  * Author: Damián Nohales <damiannohales gmail com>
  */
 
-const Geocode = imports.gi.GeocodeGlib;
+import GeocodeGlib from 'gi://GeocodeGlib';
 
-const StoredRoute = imports.storedRoute;
+import {StoredRoute} from './storedRoute.js';
 
-var PlaceFormatter = class PlaceFormatter {
+export class PlaceFormatter {
 
     constructor(place) {
         this._place = place;
@@ -67,24 +67,24 @@ var PlaceFormatter = class PlaceFormatter {
 
     _update() {
         switch (this._place.place_type) {
-        case Geocode.PlaceType.COUNTRY:
+        case GeocodeGlib.PlaceType.COUNTRY:
             if (this._place.country)
                 this._titleProperty = 'country';
 
             this._addRow(['country_code']);
             break;
 
-        case Geocode.PlaceType.STATE:
+        case GeocodeGlib.PlaceType.STATE:
             if (this._place.state)
                 this._titleProperty = 'state';
             break;
 
-        case Geocode.PlaceType.COUNTY:
+        case GeocodeGlib.PlaceType.COUNTY:
             if (this._place.county)
                 this._titleProperty = 'county';
             break;
 
-        case Geocode.PlaceType.TOWN:
+        case GeocodeGlib.PlaceType.TOWN:
             if (this._place.county)
                 this._addRow(['county']);
             else if (this._place.state)
diff --git a/src/placeIcons.js b/src/placeIcons.js
index 66c449f0..9175f298 100644
--- a/src/placeIcons.js
+++ b/src/placeIcons.js
@@ -146,7 +146,7 @@ const TYPE_ICON_MAP = {
 /**
  * Get place icon name suitable for a Place.
  */
-function getIconForPlace(place) {
+export function getIconForPlace(place) {
     return TYPE_ICON_MAP?.[place.osmKey]?.[place.osmValue] ??
            TYPE_ICON_MAP?.[place.osmKey]?.['_'] ?? 'map-marker-symbolic';
 }
diff --git a/src/placeListRow.js b/src/placeListRow.js
index abb40b7d..e7260e12 100644
--- a/src/placeListRow.js
+++ b/src/placeListRow.js
@@ -17,28 +17,20 @@
  * Author: Jonas Danielsson <jonas threetimestwo org>
  */
 
-const GLib = imports.gi.GLib;
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
 
-const ContactPlace = imports.contactPlace;
-const PlaceFormatter = imports.placeFormatter;
-const PlaceStore = imports.placeStore;
-const Utils = imports.utils;
+import {ContactPlace} from './contactPlace.js';
+import {PlaceFormatter} from './placeFormatter.js';
+import {PlaceStore} from './placeStore.js';
+import * as Utils from './utils.js';
 
 var ROW_HEIGHT = 55;
 
-var PlaceListRow = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/place-list-row.ui',
-    InternalChildren: [ 'icon',
-                        'iconStack',
-                        'contactAvatar',
-                        'name',
-                        'details',
-                        'typeIcon' ],
-}, class PlaceListRow extends Gtk.ListBoxRow {
+export class PlaceListRow extends Gtk.ListBoxRow {
 
-    _init(params) {
+    constructor(params) {
         let place = params.place;
         delete params.place;
 
@@ -49,7 +41,7 @@ var PlaceListRow = GObject.registerClass({
         delete params.type;
 
         params.height_request = ROW_HEIGHT;
-        super._init(params);
+        super(params);
         this.update(place, type, searchString);
     }
 
@@ -102,4 +94,14 @@ var PlaceListRow = GObject.registerClass({
         }
         return title;
     }
-});
+}
+
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/place-list-row.ui',
+    InternalChildren: [ 'icon',
+                        'iconStack',
+                        'contactAvatar',
+                        'name',
+                        'details',
+                        'typeIcon' ],
+}, PlaceListRow);
diff --git a/src/placeStore.js b/src/placeStore.js
index 8dd8ed4a..f7589e31 100644
--- a/src/placeStore.js
+++ b/src/placeStore.js
@@ -17,43 +17,42 @@
  * Author: Jonas Danielsson <jonas threetimestwo org>
  */
 
-const GLib = imports.gi.GLib;
-const GObject = imports.gi.GObject;
-const GdkPixbuf = imports.gi.GdkPixbuf;
-const Geocode = imports.gi.GeocodeGlib;
-const Gtk = imports.gi.Gtk;
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
+import GdkPixbuf from 'gi://GdkPixbuf';
+import GeocodeGlib from 'gi://GeocodeGlib';
+import Gtk from 'gi://Gtk';
 
-const ContactPlace = imports.contactPlace;
-const Place = imports.place;
-const StoredRoute = imports.storedRoute;
-const Utils = imports.utils;
+import {ContactPlace} from './contactPlace.js';
+import {Place} from './place.js';
+import {StoredRoute} from './storedRoute.js';
+import * as Utils from './utils.js';
 
 const _PLACES_STORE_FILE = 'maps-places.json';
 const _ICON_SIZE = 20;
 const _ONE_DAY = 1000 * 60 * 60 * 24; // one day in ms
 const _STALE_THRESHOLD = 7; // mark the osm information as stale after a week
 
-var PlaceType = {
-    ANY: -1,
-    RECENT: 0,
-    FAVORITE: 1,
-    CONTACT: 2,
-    RECENT_ROUTE: 3
-};
-
-var Columns = {
-    PLACE_ICON: 0,
-    PLACE: 1,
-    NAME: 2,
-    TYPE: 3,
-    ADDED: 4,
-    LANGUAGE: 5
-};
-
-var PlaceStore = GObject.registerClass(
-class PlaceStore extends Gtk.ListStore {
-
-    _init(params) {
+export class PlaceStore extends Gtk.ListStore {
+
+    static PlaceType = {
+        ANY: -1,
+        RECENT: 0,
+        FAVORITE: 1,
+        CONTACT: 2,
+        RECENT_ROUTE: 3
+    }
+
+    static Columns = {
+        PLACE_ICON: 0,
+        PLACE: 1,
+        NAME: 2,
+        TYPE: 3,
+        ADDED: 4,
+        LANGUAGE: 5
+    }
+
+    constructor(params) {
         this._recentPlacesLimit = params.recentPlacesLimit;
         delete params.recentPlacesLimit;
 
@@ -67,7 +66,7 @@ class PlaceStore extends Gtk.ListStore {
         this._typeTable = {};
         this._language = Utils.getLanguage();
 
-        super._init(params);
+        super(params);
         this.set_column_types([GdkPixbuf.Pixbuf,
                                GObject.TYPE_OBJECT,
                                GObject.TYPE_STRING,
@@ -356,4 +355,6 @@ class PlaceStore extends Gtk.ListStore {
             }
         });
     }
-});
+}
+
+GObject.registerClass(PlaceStore);
diff --git a/src/placeView.js b/src/placeView.js
index 70fca550..56f7f5ab 100644
--- a/src/placeView.js
+++ b/src/placeView.js
@@ -19,26 +19,26 @@
  * Author: Damián Nohales <damiannohales gmail com>
  */
 
-const Geocode = imports.gi.GeocodeGlib;
-const GLib = imports.gi.GLib;
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
-const Pango = imports.gi.Pango;
+import GeocodeGlib from 'gi://GeocodeGlib';
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
+import Pango from 'gi://Pango';
 
 const Format = imports.format;
 
-const Application = imports.application;
-const ContactPlace = imports.contactPlace;
-const Overpass = imports.overpass;
-const Place = imports.place;
-const PlaceIcons = imports.placeIcons;
-const PlaceViewImage = imports.placeViewImage;
-const PlaceButtons = imports.placeButtons;
-const PlaceFormatter = imports.placeFormatter;
-const PlaceStore = imports.placeStore;
-const Translations = imports.translations;
-const Utils = imports.utils;
-const Wikipedia = imports.wikipedia;
+import {Application} from './application.js';
+import {ContactPlace} from './contactPlace.js';
+import {Overpass} from './overpass.js';
+import {Place} from './place.js';
+import * as PlaceIcons from './placeIcons.js';
+import {PlaceViewImage} from './placeViewImage.js';
+import {PlaceButtons} from './placeButtons.js';
+import {PlaceFormatter} from './placeFormatter.js';
+import {PlaceStore} from './placeStore.js';
+import * as Translations from './translations.js';
+import * as Utils from './utils.js';
+import * as Wikipedia from './wikipedia.js';
 
 // maximum dimension of thumbnails to fetch from Wikipedia
 const THUMBNAIL_FETCH_SIZE = 360;
@@ -46,18 +46,9 @@ const THUMBNAIL_FETCH_SIZE = 360;
 // Unicode left-to-right marker
 const LRM = '\u200E';
 
-var PlaceView = GObject.registerClass({
-    Properties: {
-        'overpass-place': GObject.ParamSpec.object('overpass-place',
-                                                   'Overpass Place',
-                                                   'The place as filled in by Overpass',
-                                                   GObject.ParamFlags.READABLE |
-                                                   GObject.ParamFlags.WRITABLE,
-                                                   Geocode.Place)
-    }
-}, class PlaceView extends Gtk.Box {
+export class PlaceView extends Gtk.Box {
 
-    _init(params) {
+    constructor(params) {
         this._place = params.place;
         delete params.place;
 
@@ -69,7 +60,7 @@ var PlaceView = GObject.registerClass({
         this._inlineMode = !!params.inlineMode;
         delete params.inlineMode;
 
-        super._init(params);
+        super(params);
 
         let ui = Utils.getUIObject('place-view', [ 'bubble-main-box',
                                                    'bubble-spinner',
@@ -97,8 +88,8 @@ var PlaceView = GObject.registerClass({
 
         this.add(this._mainStack);
 
-        let placeButtons = new PlaceButtons.PlaceButtons({ place: this._place,
-                                                           mapView: mapView });
+        let placeButtons = new PlaceButtons({ place: this._place,
+                                              mapView: mapView });
         placeButtons.connect('place-edited', this._onPlaceEdited.bind(this));
         ui.placeButtons.add(placeButtons);
 
@@ -120,7 +111,7 @@ var PlaceView = GObject.registerClass({
         }
 
         /* Set up contact avatar */
-        if (this.place instanceof ContactPlace.ContactPlace) {
+        if (this.place instanceof ContactPlace) {
             this._contactAvatar.visible = true;
             Utils.load_icon(this.place.icon, 32, (pixbuf) => {
                 this._contactAvatar.set_image_load_func((size) => Utils.loadAvatar(pixbuf, size));
@@ -137,7 +128,7 @@ var PlaceView = GObject.registerClass({
         if (this.place.isCurrentLocation) {
             this._populate(this.place);
         } else {
-            let overpass = new Overpass.Overpass();
+            let overpass = new Overpass();
 
             /* use a property binding from the Overpass instance to avoid
              * accessing this object after the underlying GObject has
@@ -201,7 +192,7 @@ var PlaceView = GObject.registerClass({
 
     updatePlaceDetails() {
         let place = this.place;
-        let formatter = new PlaceFormatter.PlaceFormatter(place);
+        let formatter = new PlaceFormatter(place);
 
         let address = formatter.rows.map((row) => {
             row = row.map(function(prop) {
@@ -660,4 +651,15 @@ var PlaceView = GObject.registerClass({
     _onPlaceEdited() {
         this._populate(this._place);
     }
-});
+}
+
+GObject.registerClass({
+    Properties: {
+        'overpass-place': GObject.ParamSpec.object('overpass-place',
+                                                   'Overpass Place',
+                                                   'The place as filled in by Overpass',
+                                                   GObject.ParamFlags.READABLE |
+                                                   GObject.ParamFlags.WRITABLE,
+                                                   GeocodeGlib.Place)
+    }
+}, PlaceView);
diff --git a/src/placeViewImage.js b/src/placeViewImage.js
index 56d0c2cb..44670d59 100644
--- a/src/placeViewImage.js
+++ b/src/placeViewImage.js
@@ -19,18 +19,17 @@
  * Author: James Westman <james flyingpimonster net>
  */
 
-const Cairo = imports.cairo;
-const Gdk = imports.gi.Gdk;
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+import Cairo from 'cairo';
+import Gdk from 'gi://Gdk';
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
 
 /* The maximum aspect ratio, after which the image will be cropped vertically */
 const MAX_ASPECT_RATIO = 1;
 
-var PlaceViewImage = GObject.registerClass(
-class PlaceViewImage extends Gtk.DrawingArea {
-    _init(params) {
-        super._init(params);
+export class PlaceViewImage extends Gtk.DrawingArea {
+    constructor(params) {
+        super(params);
 
         this._pixbuf = null;
         this._cached = null;
@@ -98,4 +97,6 @@ class PlaceViewImage extends Gtk.DrawingArea {
             return [0, 0];
         }
     }
-});
+}
+
+GObject.registerClass(PlaceViewImage);
diff --git a/src/placeZoom.js b/src/placeZoom.js
index 0f797269..c895a17a 100644
--- a/src/placeZoom.js
+++ b/src/placeZoom.js
@@ -65,7 +65,7 @@ const TYPE_ZOOM_MAP = {
  * otherwise return undefined, in which case the maximum zoom level
  * (as defined by the map source) could be used.
  */
-function getZoomLevelForPlace(place) {
+export function getZoomLevelForPlace(place) {
     return TYPE_ZOOM_MAP?.[place.osmKey]?.[place.osmValue] ??
            TYPE_ZOOM_MAP?.[place.osmKey]?.['_'];
 }
diff --git a/src/route.js b/src/route.js
index 0ef127fc..a1e37a8d 100644
--- a/src/route.js
+++ b/src/route.js
@@ -19,10 +19,10 @@
  * Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
  */
 
-const GObject = imports.gi.GObject;
+import GObject from 'gi://GObject';
 
-const BoundingBox = imports.boundingBox;
-const Utils = imports.utils;
+import {BoundingBox} from './boundingBox.js';
+import * as Utils from './utils.js';
 
 var TurnPointType = {
     START:            0,
@@ -58,16 +58,10 @@ const LHT_COUNTRIES = new Set(['AG', 'AI', 'AU', 'BB', 'BD', 'BM', 'BN', 'BS',
                                'TO', 'TT', 'TV', 'TZ', 'UG', 'VC', 'VG', 'VI',
                                'WS', 'ZA', 'ZM', 'ZW']);
 
-var Route = GObject.registerClass({
-    Signals: {
-        'update': {},
-        'reset': {},
-        'error': { param_types: [GObject.TYPE_STRING] }
-    }
-}, class Route extends GObject.Object {
+export class Route extends GObject.Object {
 
-    _init() {
-        super._init();
+    constructor() {
+        super();
         this.reset();
     }
 
@@ -101,9 +95,17 @@ var Route = GObject.registerClass({
         }, this);
         return bbox;
     }
-});
+}
+
+GObject.registerClass({
+    Signals: {
+        'update': {},
+        'reset': {},
+        'error': { param_types: [GObject.TYPE_STRING] }
+    }
+}, Route);
 
-var TurnPoint = class TurnPoint {
+export class TurnPoint {
 
     constructor({ coordinate, type, distance, instruction, turnAngle }) {
         this.coordinate = coordinate;
@@ -181,4 +183,4 @@ var TurnPoint = class TurnPoint {
 
         return LHT_COUNTRIES.has(country);
     }
-};
+}
diff --git a/src/routeQuery.js b/src/routeQuery.js
index 3b424ec3..57ed0fbc 100644
--- a/src/routeQuery.js
+++ b/src/routeQuery.js
@@ -19,46 +19,18 @@
  * Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
  */
 
-const GObject = imports.gi.GObject;
-const Geocode = imports.gi.GeocodeGlib;
-
-const Application = imports.application;
-const PlaceStore = imports.placeStore;
-const TransitOptions = imports.transitOptions;
-
-var MAX_QUERY_POINTS = 10;
-
-var Transportation = {
-    CAR:        0,
-    BIKE:       1,
-    PEDESTRIAN: 2,
-    TRANSIT:    3,
-
-    toString: function (transportation) {
-        switch(transportation) {
-        case Transportation.CAR:        return 'car';
-        case Transportation.BIKE:       return 'bike';
-        case Transportation.PEDESTRIAN: return 'foot';
-        case Transportation.TRANSIT:    return 'transit';
-        default:                        return null;
-        }
-    }
-};
+import GObject from 'gi://GObject';
+import GeocodeGlib from 'gi://GeocodeGlib';
 
-var QueryPoint = GObject.registerClass({
-    Properties: {
-        'place': GObject.ParamSpec.object('place',
-                                          '',
-                                          '',
-                                          GObject.ParamFlags.READABLE |
-                                          GObject.ParamFlags.WRITABLE,
-                                          Geocode.Place)
-    }
-}, class QueryPoint extends GObject.Object {
+import {Application} from './application.js';
+import {PlaceStore} from './placeStore.js';
+import {TransitOptions} from './transitOptions.js';
+
+export class QueryPoint extends GObject.Object {
 
-    _init() {
+    constructor() {
         this._place = null;
-        super._init();
+        super();
     }
 
     set place(p) {
@@ -69,33 +41,39 @@ var QueryPoint = GObject.registerClass({
     get place() {
         return this._place;
     }
-});
+}
 
-var RouteQuery = GObject.registerClass({
-    Signals: {
-        'reset': { },
-        'point-added': { param_types: [GObject.TYPE_OBJECT, GObject.TYPE_INT] },
-        'point-removed': { param_types: [GObject.TYPE_OBJECT, GObject.TYPE_INT] },
-        'run': { }
-    },
+GObject.registerClass({
     Properties: {
-        'points': GObject.ParamSpec.object('points',
-                                           '',
-                                           '',
-                                           GObject.ParamFlags.READABLE |
-                                           GObject.ParamFlags.WRITABLE,
-                                           GObject.Object),
-        'transportation': GObject.ParamSpec.int('transportation',
-                                                '',
-                                                '',
-                                                GObject.ParamFlags.READABLE |
-                                                GObject.ParamFlags.WRITABLE,
-                                                Transportation.CAR,
-                                                Transportation.PEDESTRIAN,
-                                                Transportation.CAR,
-                                                Transportation.TRANSIT)
+        'place': GObject.ParamSpec.object('place',
+                                          '',
+                                          '',
+                                          GObject.ParamFlags.READABLE |
+                                          GObject.ParamFlags.WRITABLE,
+                                          GeocodeGlib.Place)
+    }
+}, QueryPoint);
+
+export class RouteQuery extends GObject.Object {
+
+    static MAX_QUERY_POINTS = 10;
+
+    static Transportation = {
+        CAR:        0,
+        BIKE:       1,
+        PEDESTRIAN: 2,
+        TRANSIT:    3,
+
+        toString: function (transportation) {
+            switch(transportation) {
+            case Transportation.CAR:        return 'car';
+            case Transportation.BIKE:       return 'bike';
+            case Transportation.PEDESTRIAN: return 'foot';
+            case Transportation.TRANSIT:    return 'transit';
+            default:                        return null;
+            }
+        }
     }
-}, class RouteQuery extends GObject.Object {
 
     get points() {
         return this._points;
@@ -163,13 +141,13 @@ var RouteQuery = GObject.registerClass({
         this.notify('points');
     }
 
-    _init(args) {
-        super._init(args);
+    constructor(args) {
+        super(args);
         this._points = [];
         this._time = null;
         this._date = null;
         this._arriveBy = false;
-        this._transitOptions = new TransitOptions.TransitOptions();
+        this._transitOptions = new TransitOptions();
         this._initTransportation();
         this.reset();
     }
@@ -251,4 +229,30 @@ var RouteQuery = GObject.registerClass({
         return "\nPoints: " + this.points +
                "\nTransportation: " + this.transportation;
     }
-});
+}
+
+GObject.registerClass({
+    Signals: {
+        'reset': { },
+        'point-added': { param_types: [GObject.TYPE_OBJECT, GObject.TYPE_INT] },
+        'point-removed': { param_types: [GObject.TYPE_OBJECT, GObject.TYPE_INT] },
+        'run': { }
+    },
+    Properties: {
+        'points': GObject.ParamSpec.object('points',
+                                           '',
+                                           '',
+                                           GObject.ParamFlags.READABLE |
+                                           GObject.ParamFlags.WRITABLE,
+                                           GObject.Object),
+        'transportation': GObject.ParamSpec.int('transportation',
+                                                '',
+                                                '',
+                                                GObject.ParamFlags.READABLE |
+                                                GObject.ParamFlags.WRITABLE,
+                                                RouteQuery.Transportation.CAR,
+                                                RouteQuery.Transportation.PEDESTRIAN,
+                                                RouteQuery.Transportation.CAR,
+                                                RouteQuery.Transportation.TRANSIT)
+    }
+}, RouteQuery);
diff --git a/src/searchPopover.js b/src/searchPopover.js
index 64c9f229..cb184b21 100644
--- a/src/searchPopover.js
+++ b/src/searchPopover.js
@@ -20,18 +20,16 @@
  *         Jonas Danielsson <jonas threetimestwo org>
  */
 
-const Gdk = imports.gi.Gdk;
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+import Gdk from 'gi://Gdk';
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
 
 /* Abstract search result popover that progagates keypress events from a
    focus-taking internal widget to the spawning search entry widget */
-var SearchPopover = GObject.registerClass({
-    Abstract: true
-}, class SearchPopover extends Gtk.Popover {
+export class SearchPopover extends Gtk.Popover {
 
-    _init(props) {
-        super._init(props);
+    constructor(props) {
+        super(props);
 
         this._entry = this.relative_to;
 
@@ -110,5 +108,9 @@ var SearchPopover = GObject.registerClass({
             adjustment.clamp_page(allocation.y, allocation.y + allocation.height);
         }
     }
-});
+}
+
+GObject.registerClass({
+    Abstract: true
+}, SearchPopover);
 
diff --git a/src/sendToDialog.js b/src/sendToDialog.js
index 202cb9f7..d526b805 100644
--- a/src/sendToDialog.js
+++ b/src/sendToDialog.js
@@ -17,47 +17,32 @@
  * Author: Jonas Danielson <jonas threetimestwo org>
  */
 
-const Gdk = imports.gi.Gdk;
-const Geocode = imports.gi.GeocodeGlib;
-const Gio = imports.gi.Gio;
-const GLib = imports.gi.GLib;
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
-const GWeather = imports.gi.GWeather;
-const Soup = imports.gi.Soup;
-
-const Application = imports.application;
-const PlaceFormatter = imports.placeFormatter;
-const Utils = imports.utils;
+import Gdk from 'gi://Gdk';
+import GeocodeGlib from 'gi://GeocodeGlib';
+import Gio from 'gi://Gio';
+import GLib from 'gi://GLib';
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
+import GWeather from 'gi://GWeather';
+import Soup from 'gi://Soup';
+
+import {Application} from './application.js';
+import {PlaceFormatter} from './placeFormatter.js';
+import * as Utils from './utils.js';
 
 const _WEATHER_APPID = 'org.gnome.Weather';
 const _CLOCKS_APPID = 'org.gnome.clocks';
 
-var Response = {
-    SUCCESS: 0,
-    CANCEL: 1
-};
-
 const _NUM_VISIBLE = 4;
 
-var SendToDialog = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/send-to-dialog.ui',
-    InternalChildren: [ 'list',
-                        'weatherRow',
-                        'weatherLabel',
-                        'weatherIcon',
-                        'clocksRow',
-                        'clocksLabel',
-                        'clocksIcon',
-                        'cancelButton',
-                        'summaryLabel',
-                        'summaryUrl',
-                        'copyButton',
-                        'emailButton',
-                        'scrolledWindow' ]
-}, class SendToDialog extends Gtk.Dialog {
+export class SendToDialog extends Gtk.Dialog {
 
-    _init(params) {
+    static Response = {
+        SUCCESS: 0,
+        CANCEL: 1
+    };
+
+    constructor(params) {
         this._place = params.place;
         this._location = this._place.location;
         delete params.place;
@@ -66,7 +51,7 @@ var SendToDialog = GObject.registerClass({
         delete params.mapView;
 
         params.use_header_bar = true;
-        super._init(params);
+        super(params);
 
         this._scrolledWindow.min_content_height = 40 * _NUM_VISIBLE;
         this.get_header_bar().subtitle = this._place.name;
@@ -148,7 +133,7 @@ var SendToDialog = GObject.registerClass({
         let place = this._place;
         let lines = [];
 
-        let formatter = new PlaceFormatter.PlaceFormatter(place);
+        let formatter = new PlaceFormatter(place);
 
         if (!place.isCurrentLocation)
             lines.push(formatter.title);
@@ -191,7 +176,7 @@ var SendToDialog = GObject.registerClass({
     }
 
     _emailSummary() {
-        let title = new PlaceFormatter.PlaceFormatter(this._place).title;
+        let title = new PlaceFormatter(this._place).title;
         let summary = "%s\n%s".format(this._getSummary(), this._getOSMURI());
         let uri = 'mailto:?subject=%s&body=%s'.format(Soup.URI.encode(title, null),
                                                       Soup.URI.encode(summary, null));
@@ -238,25 +223,44 @@ var SendToDialog = GObject.registerClass({
                                  new GLib.Variant('v', this._city.serialize()),
                                  timestamp);
         } else if (row instanceof OpenWithRow) {
-            let uri = this._location.to_uri(Geocode.LocationURIScheme.GEO);
+            let uri = this._location.to_uri(GeocodeGlib.LocationURIScheme.GEO);
             row.appinfo.launch_uris([ uri ], this._getAppLaunchContext());
         }
         this.response(Response.SUCCESS);
     }
-});
+}
 
-var OpenWithRow = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/open-with-row.ui',
-    InternalChildren: [ 'label',
-                        'icon' ],
-}, class OpenWithRow extends Gtk.ListBoxRow {
-    _init(params) {
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/send-to-dialog.ui',
+    InternalChildren: [ 'list',
+                        'weatherRow',
+                        'weatherLabel',
+                        'weatherIcon',
+                        'clocksRow',
+                        'clocksLabel',
+                        'clocksIcon',
+                        'cancelButton',
+                        'summaryLabel',
+                        'summaryUrl',
+                        'copyButton',
+                        'emailButton',
+                        'scrolledWindow' ]
+}, SendToDialog);
+
+export class OpenWithRow extends Gtk.ListBoxRow {
+    constructor(params) {
         this.appinfo = params.appinfo;
         delete params.appinfo;
 
-        super._init(params);
+        super(params);
 
         this._label.label = _("Open with %s").format(this.appinfo.get_name());
         this._icon.gicon = this.appinfo.get_icon();
     }
-});
+}
+
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/open-with-row.ui',
+    InternalChildren: [ 'label',
+                        'icon' ],
+}, OpenWithRow);
diff --git a/src/shapeLayer.js b/src/shapeLayer.js
index 7d42c9b4..32da4439 100644
--- a/src/shapeLayer.js
+++ b/src/shapeLayer.js
@@ -17,31 +17,32 @@
  * Author: Hashem Nasarat <hashem riseup net>
  */
 
-const Champlain = imports.gi.Champlain;
-const Gio = imports.gi.Gio;
-const GObject = imports.gi.GObject;
+import Champlain from 'gi://Champlain';
+import Gio from 'gi://Gio';
+import GObject from 'gi://GObject';
 
-const GeoJSONShapeLayer = imports.geoJSONShapeLayer;
-const Utils = imports.utils;
+import {GeoJSONShapeLayer} from './geoJSONShapeLayer.js';
+import * as Utils from './utils.js';
 
-var SUPPORTED_TYPES = [];
+export class ShapeLayer extends GObject.Object {
 
-function newFromFile(file, mapView) {
-    let contentType = Gio.content_type_guess(file.get_uri(), null)[0];
-    for (let layerClass of SUPPORTED_TYPES) {
-        if (layerClass.mimeTypes.indexOf(contentType) > -1) {
-            return layerClass.createInstance({ file: file, mapView: mapView });
+    static mimeTypes = [];
+    static displayName = '';
+
+    static SUPPORTED_TYPES = [];
+
+    static newFromFile(file, mapView) {
+        let contentType = Gio.content_type_guess(file.get_uri(), null)[0];
+        for (let layerClass of SUPPORTED_TYPES) {
+            if (layerClass.mimeTypes.indexOf(contentType) > -1) {
+                return layerClass.createInstance({ file: file, mapView: mapView });
+            }
         }
+        return null;
     }
-    return null;
-}
 
-var ShapeLayer = GObject.registerClass({
-    Abstract: true
-}, class ShapeLayer extends GObject.Object {
-
-    _init(params) {
-        super._init();
+    constructor(params) {
+        super();
         this._visible = true;
         this._mapView = params.mapView;
         this.file = params.file;
@@ -112,7 +113,9 @@ var ShapeLayer = GObject.registerClass({
         this._mapView.view.remove_layer(this._markerLayer);
         this._mapView.view.remove_overlay_source(this._mapSource);
     }
-});
+}
+
+GObject.registerClass({
+    Abstract: true
+}, ShapeLayer);
 
-ShapeLayer.mimeTypes = [];
-ShapeLayer.displayName = '';
diff --git a/src/storedRoute.js b/src/storedRoute.js
index 04763097..ea96f17f 100644
--- a/src/storedRoute.js
+++ b/src/storedRoute.js
@@ -20,20 +20,19 @@
  * Author: Jonas Danielsson <jonas threetimestwo org>
  */
 
-const Champlain = imports.gi.Champlain;
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+import Champlain from 'gi://Champlain';
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
 
-const Place = imports.place;
-const Route = imports.route;
-const RouteQuery = imports.routeQuery;
+import {Place} from './place.js';
+import {Route, TurnPoint} from './route.js';
+import {RouteQuery} from './routeQuery.js';
 
 // directional override markers
 const _RLM = '\u200F';
 const _LRM = '\u200E';
 
-var StoredRoute = GObject.registerClass(
-class StoredRoute extends Place.Place {
+export class StoredRoute extends Place {
 
     _init(params) {
         let route = params.route;
@@ -42,7 +41,7 @@ class StoredRoute extends Place.Place {
         this._transportation = params.transportation;
         delete params.transportation;
 
-        this.route = new Route.Route();
+        this.route = new Route();
         this.route.update({ path: route.path,
                             turnPoints: route.turnPoints,
                             distance: route.distance,
@@ -154,53 +153,55 @@ class StoredRoute extends Place.Place {
                  route: route,
                  places: places };
     }
-});
-
-StoredRoute.fromJSON = function(obj) {
-    let props;
-    let places = [];
-    let route;
-    let transportation = null;
-
-    for (let key in obj) {
-        let prop = obj[key];
-
-        switch(key) {
-        case 'transportation':
-            transportation = prop;
-            break;
-
-        case 'route':
-            route = new Route.Route();
-            prop.path = prop.path.map((coordinate) => {
-                let lat = coordinate.latitude;
-                let lon = coordinate.longitude;
-                return new Champlain.Coordinate({ latitude: lat,
-                                                  longitude: lon });
-            });
-            prop.turnPoints = prop.turnPoints.map((turnPoint) => {
-                let lat = turnPoint.coordinate.latitude;
-                let lon = turnPoint.coordinate.longitude;
-
-                let coordinate = new Champlain.Coordinate({ latitude: lat,
-                                                            longitude: lon });
-
-                return new Route.TurnPoint({
-                    coordinate: coordinate,
-                    type: turnPoint.type,
-                    distance: turnPoint.distance,
-                    instruction: turnPoint.instruction
+
+    static fromJSON(obj) {
+        let props;
+        let places = [];
+        let route;
+        let transportation = null;
+
+        for (let key in obj) {
+            let prop = obj[key];
+
+            switch(key) {
+            case 'transportation':
+                transportation = prop;
+                break;
+
+            case 'route':
+                route = new Route();
+                prop.path = prop.path.map((coordinate) => {
+                    let lat = coordinate.latitude;
+                    let lon = coordinate.longitude;
+                    return new Champlain.Coordinate({ latitude: lat,
+                                                      longitude: lon });
                 });
-            });
-            route.update(prop);
-            break;
+                prop.turnPoints = prop.turnPoints.map((turnPoint) => {
+                    let lat = turnPoint.coordinate.latitude;
+                    let lon = turnPoint.coordinate.longitude;
+
+                    let coordinate = new Champlain.Coordinate({ latitude: lat,
+                                                                longitude: lon });
+
+                    return new TurnPoint({
+                        coordinate: coordinate,
+                        type: turnPoint.type,
+                        distance: turnPoint.distance,
+                        instruction: turnPoint.instruction
+                    });
+                });
+                route.update(prop);
+                break;
 
-        case 'places':
-            prop.forEach((p) => places.push(Place.Place.fromJSON(p)));
-            break;
+            case 'places':
+                prop.forEach((p) => places.push(Place.fromJSON(p)));
+                break;
+            }
         }
+        return new StoredRoute({ transportation: transportation,
+                                 route: route,
+                                 places: places });
     }
-    return new StoredRoute({ transportation: transportation,
-                             route: route,
-                             places: places });
-};
+}
+
+GObject.registerClass(StoredRoute);
diff --git a/src/time.js b/src/time.js
index 0c19400b..b2970cc6 100644
--- a/src/time.js
+++ b/src/time.js
@@ -19,7 +19,7 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const Gio = imports.gi.Gio;
+import Gio from 'gi://Gio';
 
 // allow using :, ., and the ratio symbol to separate hours:mins
 const _DELIMITERS = [':', '.', '\u2236'];
@@ -105,7 +105,7 @@ const _timeFormat12 = new Intl.DateTimeFormat([], { hour:     '2-digit',
  *
  * TODO: maybe try to use some library to get better locale handling,
  * or push for something in GLib */
-function parseTimeString(timeString) {
+export function parseTimeString(timeString) {
     let pmSet = false;
     let hours;
     let mins;
@@ -176,17 +176,22 @@ function parseTimeString(timeString) {
     }
 }
 
-function _is12Hour() {
+let _is12Hour = function() {
     return _clockFormat === '12h';
 }
 
+// for use by unit test mocking only
+export function _setIs12HourFunction(f) {
+    _is12Hour = f;
+}
+
 /**
  * Format a time as HH:mm in either 12 or 24 h
  * format depending on system settings
  * given time in ms since Epoch with an offset in
  * ms relative UTC.
  */
-function formatTimeWithTZOffset(time, offset) {
+export function formatTimeWithTZOffset(time, offset) {
     let utcTimeWithOffset = time + offset;
     let date = new Date();
     let timeFormat = _is12Hour() ? _timeFormat12 : _timeFormat24;
@@ -201,7 +206,7 @@ function formatTimeWithTZOffset(time, offset) {
  * format depending on system settings
  * given hours and minutes values.
  */
-function formatTimeFromHoursAndMins(hours, mins) {
+export function formatTimeFromHoursAndMins(hours, mins) {
     let date = new Date();
     let timeFormat = _is12Hour() ? _timeFormat12 : _timeFormat24;
 
diff --git a/src/transitOptions.js b/src/transitOptions.js
index 0a964eef..12e6067c 100644
--- a/src/transitOptions.js
+++ b/src/transitOptions.js
@@ -19,7 +19,7 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-var TransitOptions = class TransitOptions {
+export class TransitOptions {
 
     constructor() {
         this._showAllTransitTypes = true;
@@ -48,23 +48,23 @@ var TransitOptions = class TransitOptions {
     get transitTypes() {
         return this._transitTypes;
     }
-};
 
-/* return true if the passed in options objects are equal, either both
- * accept any transit type, or both contains the same set of types, otherwise
- * return false
- */
-function equals(first, second) {
-    if (first.showAllTransitTypes && second.showAllTransitTypes) {
-        return true;
-    } else if (first.transitTypes.length !== second.transitTypes.length) {
-        return false;
-    } else {
-        for (let type of first.transitTypes) {
-            if (second.transitTypes.indexOf(type) === -1)
-                return false;
-        }
+    /* return true if the passed in options objects are equal, either both
+     * accept any transit type, or both contains the same set of types, otherwise
+     * return false
+     */
+    static equals(first, second) {
+        if (first.showAllTransitTypes && second.showAllTransitTypes) {
+            return true;
+        } else if (first.transitTypes.length !== second.transitTypes.length) {
+            return false;
+        } else {
+            for (let type of first.transitTypes) {
+                if (second.transitTypes.indexOf(type) === -1)
+                    return false;
+            }
 
-        return true;
+            return true;
+        }
     }
 }
diff --git a/src/translations.js b/src/translations.js
index 417811e4..6106c33d 100644
--- a/src/translations.js
+++ b/src/translations.js
@@ -19,13 +19,15 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const _ = imports.gettext.gettext;
-const C_ = imports.gettext.dgettext;
+import gettext from 'gettext';
 
-const GLib = imports.gi.GLib;
+const _ = gettext.gettext;
+const C_ = gettext.dgettext;
 
-const Time = imports.time;
-const Utils = imports.utils;
+import GLib from 'gi://GLib';
+
+import * as Time from './time.js';
+import * as Utils from './utils.js';
 
 /* Translate an opening time specification tag value.
  * from OSM into a "two-dimensional" (array-of-arrays) grid of human-readable
@@ -47,7 +49,7 @@ const Utils = imports.utils;
  * The definition for the opening_hours tag can be found at:
  * http://wiki.openstreetmap.org/wiki/Key:opening_hours
  */
-function translateOpeningHours(string) {
+export function translateOpeningHours(string) {
     if (string === '24/7' || string === 'Mo-Su 00:00-24:00' ||
         string === '00:00-24:00')
         return [[_("Around the clock")]];
@@ -71,7 +73,7 @@ function translateOpeningHours(string) {
  * Mo-We,Fr 10:00-12:00,13:00-17:00
  * Mo-We,Fr 10:00-12:00, 13:00-17:00
  */
-function _translateOpeningHoursPart(string) {
+export function _translateOpeningHoursPart(string) {
     let splitString = string.split(/\s+/);
     let len = splitString.length;
 
@@ -99,7 +101,7 @@ function _translateOpeningHoursPart(string) {
  * Mo-Fr
  * Mo,We,Th-Fr
  */
-function _translateOpeningHoursDayIntervalList(string) {
+export function _translateOpeningHoursDayIntervalList(string) {
     let splitParts = string.split(',');
     let interval1, interval2, interval3;
 
@@ -146,7 +148,7 @@ function _translateOpeningHoursDayIntervalList(string) {
  * Mo-Fr
  * Tu
  */
-function _translateOpeningHoursDayInterval(string) {
+export function _translateOpeningHoursDayInterval(string) {
     let splitString = string.split('-');
 
     // special case: Mo-Su treated as "every day"
@@ -279,7 +281,7 @@ function _translateOpeningHoursTime(string) {
     }
 }
 
-function translateReligion(string) {
+export function translateReligion(string) {
     switch(string) {
     case 'animist': return _("Animism");
     case 'bahai': return_("Bahá'í");
diff --git a/src/turnPointMarker.js b/src/turnPointMarker.js
index c5e872ee..0646916a 100644
--- a/src/turnPointMarker.js
+++ b/src/turnPointMarker.js
@@ -19,22 +19,21 @@
  * Author: Dario Di Nucci <linkin88mail gmail com>
  */
 
-const Clutter = imports.gi.Clutter;
-const Gdk = imports.gi.Gdk;
-const GObject = imports.gi.GObject;
+import Clutter from 'gi://Clutter';
+import Gdk from 'gi://Gdk';
+import GObject from 'gi://GObject';
 const Mainloop = imports.mainloop;
 
-const Application = imports.application;
-const Color = imports.color;
-const Location = imports.location;
-const MapMarker = imports.mapMarker;
-const Place = imports.place;
-const Utils = imports.utils;
+import {Application} from './application.js';
+import * as Color from './color.js';
+import {Location} from './location.js';
+import {MapMarker} from './mapMarker.js';
+import {Place} from './place.js';
+import * as Utils from './utils.js';
 
-var TurnPointMarker = GObject.registerClass(
-class TurnPointMarker extends MapMarker.MapMarker {
+export class TurnPointMarker extends MapMarker.MapMarker {
 
-    _init(params) {
+    constructor(params) {
         this._queryPoint = params.queryPoint;
         delete params.queryPoint;
 
@@ -58,10 +57,10 @@ class TurnPointMarker extends MapMarker.MapMarker {
             longitude = this._transitStop.coordinate[1];
         }
 
-        params.place = new Place.Place({
-            location: new Location.Location({ latitude: latitude,
-                                              longitude: longitude }) });
-        super._init(params);
+        params.place =
+            new Place({ location: new Location({ latitude: latitude,
+                                                 longitude: longitude }) });
+        super(params);
 
         let actor;
         if (this._queryPoint) {
@@ -114,10 +113,12 @@ class TurnPointMarker extends MapMarker.MapMarker {
 
     _onMarkerDrag() {
         let query = Application.routeQuery;
-        let place = new Place.Place({
-            location: new Location.Location({ latitude: this.latitude.toFixed(5),
-                                              longitude: this.longitude.toFixed(5) }) });
+        let place =
+            new Place({ location: new Location({ latitude: this.latitude.toFixed(5),
+                                                 longitude: this.longitude.toFixed(5) }) });
 
         this._queryPoint.place = place;
     }
-});
+}
+
+GObject.registerClass(TurnPointMarker);
diff --git a/src/uris.js b/src/uris.js
index 6575b222..ca3da33b 100644
--- a/src/uris.js
+++ b/src/uris.js
@@ -19,12 +19,14 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const _ = imports.gettext.gettext;
+import gettext from 'gettext';
+
+import GLib from 'gi://GLib';
+import Soup from 'gi://Soup';
 
-const GLib = imports.gi.GLib;
-const Soup = imports.gi.Soup;
+import * as Utils from './utils.js';
 
-const Utils = imports.utils;
+const _ = imports.gettext.gettext;
 
 // Matches URLs for OpenStreetMap (for addressing objects or coordinates)
 const OSM_URL_REGEX = new RegExp(/https?:\/\/(www\.)?openstreetmap\.org./);
@@ -34,7 +36,7 @@ const OSM_URL_REGEX = new RegExp(/https?:\/\/(www\.)?openstreetmap\.org./);
  * e.g. an openstreetmap.org URL with lat and lon query parameters,
  * returns [lat, lon, optional zoom], otherwise [].
  */
-function parseAsCoordinateURL(url) {
+export function parseAsCoordinateURL(url) {
     if (url.match(OSM_URL_REGEX)) {
         /* it seems #map= is not handle well by parse_params(), so just remove
          * the # as a work-around
@@ -89,7 +91,7 @@ function parseAsCoordinateURL(url) {
  * For URLs addressing a specific OSM object (node, way, or relation),
  * returns [type,id], otherwise [].
  */
-function parseAsObjectURL(url) {
+export function parseAsObjectURL(url) {
     if (url.match(OSM_URL_REGEX)) {
         let uri = GLib.Uri.parse(url, GLib.UriFlags.NONE);
         let path = uri.get_path();
@@ -113,7 +115,7 @@ function parseAsObjectURL(url) {
  * For maps: URIs, return the search query string if a valid URI
  * otherwise null.
  */
-function parseMapsURI(uri) {
+export function parseMapsURI(uri) {
     let path = uri.substring('maps:'.length);
     let [param, value] = Utils.splitAtFirst(path, '=');
 
diff --git a/src/utils.js b/src/utils.js
index 9c8ec3fd..93bcebb0 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -20,21 +20,24 @@
  *         Zeeshan Ali (Khattak) <zeeshanak gnome org>
  */
 
-const _ = imports.gettext.gettext;
-const ngettext = imports.gettext.ngettext;
-
-const GLib = imports.gi.GLib;
-const Gdk = imports.gi.Gdk;
-const GdkPixbuf = imports.gi.GdkPixbuf;
-const Geocode = imports.gi.GeocodeGlib;
-const Gio = imports.gi.Gio;
-const Gtk = imports.gi.Gtk;
-const GWeather = imports.gi.GWeather;
-const Soup = imports.gi.Soup;
+import gettext from 'gettext';
+
+const _ = gettext.gettext;
+const ngettext = gettext.ngettext;
+
+import GLib from 'gi://GLib';
+import Gdk from 'gi://Gdk';
+import GdkPixbuf from 'gi://GdkPixbuf';
+import GeocodeGlib from 'gi://GeocodeGlib';
+import Gio from 'gi://Gio';
+import Gtk from 'gi://Gtk';
+import GWeather from 'gi://GWeather';
+import Soup from 'gi://Soup';
+
 const ByteArray = imports.byteArray;
 
-var METRIC_SYSTEM = 1;
-var IMPERIAL_SYSTEM = 2;
+export const METRIC_SYSTEM = 1;
+export const IMPERIAL_SYSTEM = 2;
 
 //List of locales using imperial system according to glibc locale database
 const IMPERIAL_LOCALES = ['unm_US', 'es_US', 'es_PR', 'en_US', 'yi_US'];
@@ -53,9 +56,14 @@ const _integerTwoDigitFormat =
 let debugInit = false;
 let measurementSystem = null;
 
+// this should only be used by the unit test to hard-set the measurement system
+export function _setMeasurementSystem(m) {
+    measurementSystem = m;
+}
+
 var debugEnabled = false;
 
-function debug(msg) {
+export function debug(msg) {
     if (!debugInit) {
         let env = GLib.getenv('MAPS_DEBUG');
         if (env)
@@ -72,14 +80,14 @@ function debug(msg) {
 }
 
 // Connect to a signal on an object and disconnect on its first emission.
-function once(obj, signal, callback) {
+export function once(obj, signal, callback) {
     let id = obj.connect(signal, function() {
         obj.disconnect(id);
         callback();
     });
 }
 
-function loadStyleSheet(file) {
+export function loadStyleSheet(file) {
     let provider = new Gtk.CssProvider();
     provider.load_from_file(file);
     Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
@@ -87,7 +95,7 @@ function loadStyleSheet(file) {
                                              Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
 }
 
-function addActions(actionMap, entries, settings = null) {
+export function addActions(actionMap, entries, settings = null) {
     for(let name in entries) {
         let entry = entries[name];
         let action = createAction(name, entry, settings);
@@ -99,7 +107,7 @@ function addActions(actionMap, entries, settings = null) {
     }
 }
 
-function setAccelsForActionMap(actionMap, actionName, accels) {
+export function setAccelsForActionMap(actionMap, actionName, accels) {
     let app;
     let prefix;
 
@@ -154,7 +162,7 @@ function _getPlatformData(appId, timestamp) {
     return { 'desktop-startup-id': id };
 }
 
-function activateAction(appId, action, parameter, timestamp) {
+export function activateAction(appId, action, parameter, timestamp) {
     let objectPath = '/' + appId.replace(/\./g, '/');
     let platformData = _getPlatformData(appId, timestamp);
     let wrappedParam = parameter ? [parameter] : [];
@@ -176,13 +184,13 @@ function activateAction(appId, action, parameter, timestamp) {
                           });
 }
 
-function dashedToCamelCase(name) {
+export function dashedToCamelCase(name) {
     return name.replace(/(-.)/g, function(x) {
         return x[1].toUpperCase();
     });
 }
 
-function getUIObject(res, ids) {
+export function getUIObject(res, ids) {
     let builder = new Gtk.Builder();
     builder.add_from_resource('/org/gnome/Maps/ui/' + res + '.ui');
     let ret = {};
@@ -192,7 +200,7 @@ function getUIObject(res, ids) {
     return ret;
 }
 
-function readFile(filename) {
+export function readFile(filename) {
     let status, buffer;
     let file = Gio.File.new_for_path(filename);
     try {
@@ -206,7 +214,7 @@ function readFile(filename) {
         return null;
 }
 
-function writeFile(filename, buffer) {
+export function writeFile(filename, buffer) {
     let file = Gio.File.new_for_path(filename);
     let status;
     try {
@@ -217,7 +225,7 @@ function writeFile(filename, buffer) {
     }
 }
 
-function getMeasurementSystem() {
+export function getMeasurementSystem() {
     if (measurementSystem)
         return measurementSystem;
 
@@ -238,15 +246,15 @@ function getMeasurementSystem() {
 /**
  * Get the highest priority bare lange currently in use.
  */
-function getLanguage() {
+export function getLanguage() {
     let locale = GLib.get_language_names()[0];
     // the last item returned is the "bare" language
     return GLib.get_locale_variants(locale).slice(-1)[0];
 }
 
-function getAccuracyDescription(accuracy) {
+export function getAccuracyDescription(accuracy) {
     switch(accuracy) {
-    case Geocode.LOCATION_ACCURACY_UNKNOWN:
+    case GeocodeGlib.LOCATION_ACCURACY_UNKNOWN:
         /* Translators: Accuracy of user location information */
         return _("Unknown");
     case 0:
@@ -257,7 +265,7 @@ function getAccuracyDescription(accuracy) {
     }
 }
 
-function loadAvatar(pixbuf, size) {
+export function loadAvatar(pixbuf, size) {
     let width = pixbuf.get_width();
     let height = pixbuf.get_height();
     let croppedThumbnail;
@@ -273,7 +281,7 @@ function loadAvatar(pixbuf, size) {
     return croppedThumbnail.scale_simple(size, size, GdkPixbuf.InterpType.BILINEAR);
 }
 
-function load_icon(icon, size, loadCompleteCallback) {
+export function load_icon(icon, size, loadCompleteCallback) {
     if (icon instanceof Gio.FileIcon || icon instanceof Gio.BytesIcon) {
         _load_icon(icon, loadCompleteCallback);
     } else if (icon instanceof Gio.ThemedIcon) {
@@ -307,11 +315,11 @@ function _load_themed_icon(icon, size, loadCompleteCallback) {
     }
 }
 
-function osmTypeToString(osmType) {
+export function osmTypeToString(osmType) {
     switch(osmType) {
-        case Geocode.PlaceOsmType.NODE: return 'node';
-        case Geocode.PlaceOsmType.RELATION: return 'relation';
-        case Geocode.PlaceOsmType.WAY: return 'way';
+        case GeocodeGlib.PlaceOsmType.NODE: return 'node';
+        case GeocodeGlib.PlaceOsmType.RELATION: return 'relation';
+        case GeocodeGlib.PlaceOsmType.WAY: return 'way';
         default: return 'node';
     }
 }
@@ -320,7 +328,7 @@ function osmTypeToString(osmType) {
  * Return a formatted integer number with no
  * fraction, using locale-specific numerals
  */
-function formatLocaleInteger(n) {
+export function formatLocaleInteger(n) {
     return _integerFormat.format(n);
 }
 
@@ -329,11 +337,11 @@ function formatLocaleInteger(n) {
  * fraction, using locale-specific numerals using at least two digits
  * with possible leading 0, suitable for time rendering.
  */
-function formatLocaleIntegerMinimumTwoDigits(n) {
+export function formatLocaleIntegerMinimumTwoDigits(n) {
     return _integerTwoDigitFormat.format(n);
 }
 
-function prettyTime(time) {
+export function prettyTime(time) {
     let seconds = Math.floor(time / 1000);
     let minutes = Math.floor(seconds / 60);
     seconds = seconds % 60;
@@ -371,7 +379,7 @@ function prettyTime(time) {
     }
 }
 
-function prettyDistance(distance, noRound) {
+export function prettyDistance(distance, noRound) {
     if (getMeasurementSystem() === METRIC_SYSTEM) {
         // round to whole meters
         distance = Math.round(distance);
@@ -402,14 +410,14 @@ function prettyDistance(distance, noRound) {
  * to handle estimated values without showing lots of zeros.
  * Other values are formatted in full.
  */
-function prettyPopulation(population) {
+export function prettyPopulation(population) {
     let notation = population >= 1000000 && population % 100000 === 0 ?
                    'compact' : 'standard';
 
     return population.toLocaleString(undefined, { notation: notation });
 }
 
-function uriSchemeSupported(scheme) {
+export function uriSchemeSupported(scheme) {
     let apps = Gio.AppInfo.get_all();
     let prefix = 'x-scheme-handler/';
 
@@ -426,25 +434,25 @@ function uriSchemeSupported(scheme) {
     return false;
 }
 
-function normalizeString(string) {
+export function normalizeString(string) {
     let normalized = GLib.utf8_normalize(string, -1, GLib.NormalizeMode.ALL);
     return normalized.replace(ACCENTS_REGEX, '');
 }
 
-function isUsingDarkThemeVariant() {
+export function isUsingDarkThemeVariant() {
     let gtkSettings = Gtk.Settings.get_default();
 
     return gtkSettings.gtk_application_prefer_dark_theme;
 }
 
-function isUsingHighContrastTheme() {
+export function isUsingHighContrastTheme() {
     let gtkSettings = Gtk.Settings.get_default();
     let themeName = gtkSettings.gtk_theme_name;
 
     return themeName === 'HighContrast' || themeName === 'HighContrastInverse';
 }
 
-function showDialog(msg, type, transientFor) {
+export function showDialog(msg, type, transientFor) {
     let messageDialog =
         new Gtk.MessageDialog({ transient_for: transientFor,
                                 destroy_with_parent: true,
@@ -460,7 +468,7 @@ function showDialog(msg, type, transientFor) {
 /* Gets a string from either a ByteArray or Uint8Array. This is for
 compatibility between two different Gjs versions, see discussion at
 https://gitlab.gnome.org/GNOME/gnome-maps/merge_requests/19 */
-function getBufferText(buffer) {
+export function getBufferText(buffer) {
     if (buffer instanceof Uint8Array) {
         return ByteArray.toString(buffer);
     } else {
@@ -468,14 +476,14 @@ function getBufferText(buffer) {
     }
 }
 
-function getCountryCodeForCoordinates(lat, lon) {
+export function getCountryCodeForCoordinates(lat, lon) {
     let location = GWeather.Location.new_detached('', null, lat, lon);
 
     return location.get_country();
 }
 
 /* Determines whether a URI is valid and its scheme is HTTP or HTTPS. */
-function isValidWebsite(website) {
+export function isValidWebsite(website) {
     try {
         GLib.Uri.is_valid(website, GLib.UriFlags.NONE);
     } catch(e) {
@@ -485,7 +493,7 @@ function isValidWebsite(website) {
 }
 
 /* Determine whether a string is a valid e-mail address. */
-function isValidEmail(email) {
+export function isValidEmail(email) {
     // if it starts with 'mailto:', it's probably a mistake copy-pasting a URI
     if (email.startsWith('mailto:'))
         return false;
@@ -496,14 +504,14 @@ function isValidEmail(email) {
 /* Return string with first character in upper case according the rules
  * determined by the current locale
  */
-function firstToLocaleUpperCase(str) {
+export function firstToLocaleUpperCase(str) {
     return str[0].toLocaleUpperCase() + str.substring(1);
 }
 
 /* Splits string at first occurance of a character, leaving remaining
  * occurances of the separator in the second part
  */
-function splitAtFirst(string, separator) {
+export function splitAtFirst(string, separator) {
     let [first, ...rest] = string.split(separator);
 
     if (rest.length > 0) {
diff --git a/src/wikipedia.js b/src/wikipedia.js
index daf3dc44..4629d06d 100644
--- a/src/wikipedia.js
+++ b/src/wikipedia.js
@@ -19,13 +19,13 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const GdkPixbuf = imports.gi.GdkPixbuf;
-const Gio = imports.gi.Gio;
-const GLib = imports.gi.GLib;
-const Soup = imports.gi.Soup;
+import GdkPixbuf from 'gi://GdkPixbuf';
+import Gio from 'gi://Gio';
+import GLib from 'gi://GLib';
+import Soup from 'gi://Soup';
 
 const Format = imports.format;
-const Utils = imports.utils;
+import * as Utils from './utils.js';
 
 /**
  * Regex matching editions of Wikipedia, e.g. "en", "arz", pt-BR", "simple".
@@ -45,16 +45,16 @@ function _getSoupSession() {
 let _thumbnailCache = {};
 let _metadataCache = {};
 
-function getLanguage(wiki) {
+export function getLanguage(wiki) {
     return wiki.split(':')[0];
 }
 
-function getArticle(wiki) {
+export function getArticle(wiki) {
     return Soup.uri_encode(wiki.replace(/ /g, '_').split(':').splice(1).join(':'),
                            '\'');
 }
 
-function getHtmlEntityEncodedArticle(wiki) {
+export function getHtmlEntityEncodedArticle(wiki) {
     return GLib.markup_escape_text(wiki.split(':').splice(1).join(':'), -1);
 }
 
@@ -62,7 +62,7 @@ function getHtmlEntityEncodedArticle(wiki) {
  * Determine if a Wikipedia reference tag is valid
  * (of the form "lang:Article title")
  */
-function isValidWikipedia(wiki) {
+export function isValidWikipedia(wiki) {
     let parts = wiki.split(':');
 
     if (parts.length < 2)
@@ -86,7 +86,7 @@ function isValidWikipedia(wiki) {
  * Calls @thumbnailCb with the Gdk.Pixbuf of the icon when successful, otherwise
  * null.
  */
-function fetchArticleInfo(wiki, size, metadataCb, thumbnailCb) {
+export function fetchArticleInfo(wiki, size, metadataCb, thumbnailCb) {
     let lang = getLanguage(wiki);
     let title = getHtmlEntityEncodedArticle(wiki);
     let uri = Format.vprintf('https://%s.wikipedia.org/w/api.php', [ lang ]);
diff --git a/src/zoomInDialog.js b/src/zoomInDialog.js
index 16bb9c99..a5559742 100644
--- a/src/zoomInDialog.js
+++ b/src/zoomInDialog.js
@@ -20,18 +20,14 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
 
-const OSMEdit = imports.osmEdit;
+import {OSMEdit} from './osmEdit.js';
 
-var ZoomInDialog = GObject.registerClass({
-    Template: 'resource:///org/gnome/Maps/ui/zoom-in-dialog.ui',
-    InternalChildren: [ 'cancelButton',
-                        'zoomInButton'],
-}, class ZoomInDialog extends Gtk.Dialog {
+export class ZoomInDialog extends Gtk.Dialog {
 
-    _init(params) {
+    constructor(params) {
         this._latitude = params.latitude;
         delete params.latitude;
         this._longitude = params.longitude;
@@ -42,7 +38,7 @@ var ZoomInDialog = GObject.registerClass({
         /* This is a construct-only property and cannot be set by GtkBuilder */
         params.use_header_bar = true;
 
-        super._init(params);
+        super(params);
 
         this._zoomInButton.connect('clicked', () => this._onZoomIn());
         this._cancelButton.connect('clicked', () => this._onCancel());
@@ -59,4 +55,10 @@ var ZoomInDialog = GObject.registerClass({
     _onCancel() {
         this.response(Gtk.ResponseType.CANCEL);
     }
-});
\ No newline at end of file
+}
+
+GObject.registerClass({
+    Template: 'resource:///org/gnome/Maps/ui/zoom-in-dialog.ui',
+    InternalChildren: [ 'cancelButton',
+                        'zoomInButton'],
+}, ZoomInDialog);
diff --git a/tests/addressTest.js b/tests/addressTest.js
index 811a2cee..32962da2 100644
--- a/tests/addressTest.js
+++ b/tests/addressTest.js
@@ -21,11 +21,7 @@
 
 const JsUnit = imports.jsUnit;
 
-const Address = imports.address;
-
-function main() {
-    streetAddressForCountryCodeTest();
-}
+import * as Address from './address.js';
 
 function streetAddressForCountryCodeTest() {
     // Test known expected address formats for some countries
@@ -57,3 +53,5 @@ function streetAddressForCountryCodeTest() {
                         Address.streetAddressForCountryCode('Some Street',
                                                             '42', 'UT'));
 }
+
+streetAddressForCountryCodeTest();
diff --git a/tests/boundingBoxTest.js b/tests/boundingBoxTest.js
index d8a605e1..707059be 100644
--- a/tests/boundingBoxTest.js
+++ b/tests/boundingBoxTest.js
@@ -21,8 +21,8 @@
 
 const JsUnit = imports.jsUnit;
 
-const BoundingBox = imports.boundingBox;
-const Constants = imports.constants;
+import {BoundingBox} from './boundingBox.js';
+import * as Constants from './constants.js';
 
 function main() {
     constructTest();
@@ -36,8 +36,8 @@ function main() {
 }
 
 function constructTest() {
-    let bbox = new BoundingBox.BoundingBox({ top: 60.0, left: 15.0,
-                                             bottom: 59.0, right: 16.0 });
+    let bbox = new BoundingBox({ top: 60.0, left: 15.0,
+                                 bottom: 59.0, right: 16.0 });
 
     JsUnit.assertEquals(60.0, bbox.top);
     JsUnit.assertEquals(15.0, bbox.left);
@@ -45,7 +45,7 @@ function constructTest() {
     JsUnit.assertEquals(16.0, bbox.right);
 
     // test default values
-    bbox = new BoundingBox.BoundingBox();
+    bbox = new BoundingBox();
 
     JsUnit.assertEquals(Constants.MIN_LATITUDE, bbox.top);
     JsUnit.assertEquals(Constants.MAX_LONGITUDE, bbox.left);
@@ -54,8 +54,8 @@ function constructTest() {
 }
 
 function copyTest() {
-    let bbox = new BoundingBox.BoundingBox({ top: 60.0, left: 15.0,
-                                             bottom: 59.0, right: 16.0 });
+    let bbox = new BoundingBox({ top: 60.0, left: 15.0,
+                                 bottom: 59.0, right: 16.0 });
     let copy = bbox.copy();
 
     // update original box
@@ -72,7 +72,7 @@ function copyTest() {
 }
 
 function setTest() {
-    let bbox = new BoundingBox.BoundingBox();
+    let bbox = new BoundingBox();
 
     bbox.top = 0;
     bbox.left = 0;
@@ -86,8 +86,8 @@ function setTest() {
 }
 
 function getCenterTest() {
-    let bbox = new BoundingBox.BoundingBox({ top: 60.0, left: 15.0,
-                                             bottom: 59.0, right: 16.0 });
+    let bbox = new BoundingBox({ top: 60.0, left: 15.0,
+                                 bottom: 59.0, right: 16.0 });
     let center = bbox.getCenter();
 
     JsUnit.assertTrue(center instanceof Array);
@@ -97,10 +97,10 @@ function getCenterTest() {
 }
 
 function composeTest() {
-    let bbox = new BoundingBox.BoundingBox({ top: 60.0, left: 15.0,
-                                             bottom: 59.0, right: 16.0 });
-    let other = new BoundingBox.BoundingBox({ top: 60.0, left: 14.0,
-                                              bottom: 59.0, right: 15.0 });
+    let bbox = new BoundingBox({ top: 60.0, left: 15.0,
+                                 bottom: 59.0, right: 16.0 });
+    let other = new BoundingBox({ top: 60.0, left: 14.0,
+                                  bottom: 59.0, right: 15.0 });
 
     bbox.compose(other);
 
@@ -111,8 +111,8 @@ function composeTest() {
 }
 
 function extendTest() {
-    let bbox = new BoundingBox.BoundingBox({ top: 60.0, left: 15.0,
-                                             bottom: 59.0, right: 16.0 });
+    let bbox = new BoundingBox({ top: 60.0, left: 15.0,
+                                 bottom: 59.0, right: 16.0 });
 
     bbox.extend(58.0, 14.0);
 
@@ -123,31 +123,33 @@ function extendTest() {
 }
 
 function isValidTest() {
-    let valid = new BoundingBox.BoundingBox({ top: 60.0, left: 15.0,
-                                              bottom: 59.0, right: 16.0 });
+    let valid = new BoundingBox({ top: 60.0, left: 15.0,
+                                  bottom: 59.0, right: 16.0 });
 
     JsUnit.assertTrue(valid.isValid());
 
-    let unset = new BoundingBox.BoundingBox();
+    let unset = new BoundingBox();
 
     JsUnit.assertFalse(unset.isValid());
 
-    let overflowNorth = new BoundingBox.BoundingBox({ top: 100.0, left: 15.0,
-                                                      bottom: 0.0, right: 16.0 });
+    let overflowNorth = new BoundingBox({ top: 100.0, left: 15.0,
+                                          bottom: 0.0, right: 16.0 });
 
     JsUnit.assertFalse(overflowNorth.isValid());
 
-    let flipped = new BoundingBox.BoundingBox({ top: 59.0, left: 16.0,
-                                                bottom: 60.0, right: 15.0 });
+    let flipped = new BoundingBox({ top: 59.0, left: 16.0,
+                                    bottom: 60.0, right: 15.0 });
 
     JsUnit.assertFalse(flipped.isValid());
 }
 
 function coversTest() {
-    let bbox = new BoundingBox.BoundingBox({ top: 60.0, left: 15.0,
-                                             bottom: 59.0, right: 16.0 });
+    let bbox = new BoundingBox({ top: 60.0, left: 15.0,
+                                 bottom: 59.0, right: 16.0 });
 
     JsUnit.assertTrue(bbox.covers(59.5, 15.5));
     JsUnit.assertFalse(bbox.covers(0.0, 0.0));
     JsUnit.assertFalse(bbox.covers(59.0, -180.0));
 }
+
+main();
diff --git a/tests/colorTest.js b/tests/colorTest.js
index 0c231cf1..cc37d1b5 100644
--- a/tests/colorTest.js
+++ b/tests/colorTest.js
@@ -21,14 +21,7 @@
 
 const JsUnit = imports.jsUnit;
 
-const Color = imports.color;
-
-function main() {
-    parseColorTest();
-    relativeLuminanceTest();
-    contrastRatioTest();
-    getContrastingForegroundColorTest();
-}
+import * as Color from './color.js';
 
 function parseColorTest() {
     JsUnit.assertEquals(1.0, Color.parseColor('ff0000', 0));
@@ -69,3 +62,8 @@ function getContrastingForegroundColorTest() {
     JsUnit.assertEquals('dddddd',
                         Color.getContrastingForegroundColor('000088', 'dddddd'));
 }
+
+parseColorTest();
+relativeLuminanceTest();
+contrastRatioTest();
+getContrastingForegroundColorTest();
diff --git a/tests/meson.build b/tests/meson.build
index 51a600f0..8c2fbd1a 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -2,6 +2,14 @@ tests = ['addressTest', 'boundingBoxTest', 'colorTest', 'osmNamesTest',
          'placeIconsTest', 'placeZoomTest', 'timeTest', 'translationsTest',
          'utilsTest', 'urisTest', 'wikipediaTest']
 
+# suffix for source resources (so we get /org/gnome/Maps or
+# /org/gnome/Maps/Devel, depending on the profile)
+if (get_option('profile') == 'development')
+       suffix = '/Devel'
+else
+       suffix = ''
+endif
+
 foreach test : tests
   script_conf = configuration_data()
   script_conf.set('GJS', gjs.path())
@@ -9,6 +17,7 @@ foreach test : tests
   script_conf.set('libdir', libdir)
   script_conf.set('prefix', prefix)
   script_conf.set('name', test)
+  script_conf.set('suffix', suffix)
   configure_file(
     input: 'test.in',
     output: test,
@@ -18,11 +27,27 @@ foreach test : tests
   )
 endforeach
 
+sources_conf = configuration_data()
+sources_conf.set('suffix', suffix)
+
+# generate combined GResource with source files and tests to use ES modules
+gnome.compile_resources(
+  'test.src',
+  configure_file(
+       input: '../src/org.gnome.Maps.src.gresource.xml.in',
+       output: 'test.src.gresource.xml',
+       configuration: sources_conf
+  ),
+  gresource_bundle: true,
+  install: true,
+  install_dir: meson.build_root(),
+  source_dir: ['../src', '../src/geojson-vt']
+)
+
 foreach test : tests
   test(test, gjs,
-       args: ['-I', meson.source_root() + '/src/', '-I',
-              meson.source_root() + '/tests/',
-              'tests/@0@'.format(test)],
+       args: ['tests/@0@'.format(test),
+              join_paths(meson.build_root(), 'tests', 'test.src.gresource')],
        env:  ['LANG=en_US.utf8', 'LC_ALL=en_US.utf8']
   )
 endforeach
diff --git a/tests/osmNamesTest.js b/tests/osmNamesTest.js
index 172688e8..5a5044b2 100644
--- a/tests/osmNamesTest.js
+++ b/tests/osmNamesTest.js
@@ -19,10 +19,10 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-pkg.require({ 'Gdk': '3.0',
-              'Gtk': '3.0' });
+import 'gi://Gdk?version=3.0';
+import 'gi://Gtk?version=3.0';
 
-const OSMNames = imports.osmNames;
+import * as OSMNames from './osmNames.js';
 
 const JsUnit = imports.jsUnit;
 
@@ -59,18 +59,18 @@ const TAGS4 = { 'name': 'Uppsala',
                 'name:sv': 'Uppsala',
                 'name:yi': 'אופסאלא'};
 
-function main() {
-    JsUnit.assertEquals('Name in language', 'Namn',
-                        OSMNames.getNameForLanguageAndCountry(TAGS1, 'sv', 'GB'));
-    JsUnit.assertEquals('Fallback when language not localized', 'Name',
-                        OSMNames.getNameForLanguageAndCountry(TAGS1, 'fi', 'GB'));
-    JsUnit.assertEquals('Legacy Japanese romanization tag', 'Shin Ōsaka',
-                        OSMNames.getNameForLanguageAndCountry(TAGS2, 'sv', 'JP'));
-    JsUnit.assertEquals('Japanese romanization tag', 'Shin Ōsaka',
-                        OSMNames.getNameForLanguageAndCountry(TAGS3, 'sv', 'JP'));
-    JsUnit.assertEquals('Explicit English', 'Shin-Osaka',
-                        OSMNames.getNameForLanguageAndCountry(TAGS3, 'en', 'JP'));
-    JsUnit.assertEquals('Available tag in similar alphabeth', 'Уппсала',
-                        OSMNames.getNameForLanguageAndCountry(TAGS4, 'uk', 'SE'));
-}
+JsUnit.assertEquals('Name in language', 'Namn',
+                    OSMNames.getNameForLanguageAndCountry(TAGS1, 'sv', 'GB'));
+JsUnit.assertEquals('Fallback when language not localized', 'Name',
+                    OSMNames.getNameForLanguageAndCountry(TAGS1, 'fi', 'GB'));
+JsUnit.assertEquals('Legacy Japanese romanization tag', 'Shin Ōsaka',
+                    OSMNames.getNameForLanguageAndCountry(TAGS2, 'sv', 'JP'));
+JsUnit.assertEquals('Japanese romanization tag', 'Shin Ōsaka',
+                    OSMNames.getNameForLanguageAndCountry(TAGS3, 'sv', 'JP'));
+JsUnit.assertEquals('Explicit English', 'Shin-Osaka',
+                    OSMNames.getNameForLanguageAndCountry(TAGS3, 'en', 'JP'));
+JsUnit.assertEquals('Available tag in similar alphabeth', 'Уппсала',
+                    OSMNames.getNameForLanguageAndCountry(TAGS4, 'uk', 'SE'));
+
+
 
diff --git a/tests/placeIconsTest.js b/tests/placeIconsTest.js
index 076f1a94..6394149d 100644
--- a/tests/placeIconsTest.js
+++ b/tests/placeIconsTest.js
@@ -20,7 +20,7 @@
  */
 const JsUnit = imports.jsUnit;
 
-const PlaceIcons = imports.placeIcons;
+import * as PlaceIcons from './placeIcons.js';
 
 /* use a minimal mock of Place, since Place throught dependencies requires
  * the GResources to be setup, so it can't easily be used from tests
@@ -40,11 +40,6 @@ class MockedPlace {
     }
 }
 
-function main() {
-    testKnownTypes();
-    testDefaultIcon();
-}
-
 // test some known place type → icon mappings
 function testKnownTypes() {
     let p1 = new MockedPlace({ osmKey: 'amenity', osmValue: 'restaurant' });
@@ -71,3 +66,6 @@ function testDefaultIcon() {
     JsUnit.assertEquals('map-marker-symbolic', PlaceIcons.getIconForPlace(p2));
     JsUnit.assertEquals('map-marker-symbolic', PlaceIcons.getIconForPlace(p3));
 }
+
+testKnownTypes();
+testDefaultIcon();
diff --git a/tests/placeZoomTest.js b/tests/placeZoomTest.js
index b99a16e8..27b147cd 100644
--- a/tests/placeZoomTest.js
+++ b/tests/placeZoomTest.js
@@ -20,27 +20,22 @@
  */
 const JsUnit = imports.jsUnit;
 
-const PlaceZoom = imports.placeZoom;
+import * as PlaceZoom from './placeZoom.js';
 
-function main() {
-    placeZoomTest();
-}
+// specific place types
+JsUnit.assertEquals(17,
+                    PlaceZoom.getZoomLevelForPlace({ osmKey:   'shop',
+                                                     osmValue: 'supermarket' }));
+JsUnit.assertEquals(4,
+                    PlaceZoom.getZoomLevelForPlace({ osmKey:   'place',
+                                                     osmValue: 'continent' }));
 
-function placeZoomTest() {
-    // specific place types
-    JsUnit.assertEquals(17,
-                        PlaceZoom.getZoomLevelForPlace({ osmKey:   'shop',
-                                                         osmValue: 'supermarket' }));
-    JsUnit.assertEquals(4,
-                        PlaceZoom.getZoomLevelForPlace({ osmKey:   'place',
-                                                         osmValue: 'continent' }));
+// fallback for for OSM key
+JsUnit.assertEquals(17,
+                    PlaceZoom.getZoomLevelForPlace({ osmKey:   'place',
+                                                     osmValue: 'other' }));
 
-    // fallback for for OSM key
-    JsUnit.assertEquals(17,
-                        PlaceZoom.getZoomLevelForPlace({ osmKey:   'place',
-                                                         osmValue: 'other' }));
+// undefined for not defined type
+JsUnit.assertUndefined(PlaceZoom.getZoomLevelForPlace({ osmKey:   'type',
+                                                        osmValue: 'other' }));
 
-    // undefined for not defined type
-    JsUnit.assertUndefined(PlaceZoom.getZoomLevelForPlace({ osmKey:   'type',
-                                                            osmValue: 'other' }));
-}
diff --git a/tests/test.in b/tests/test.in
index 1f3aeabe..a2ef7bc0 100644
--- a/tests/test.in
+++ b/tests/test.in
@@ -1,6 +1,20 @@
 #!@GJS@
+const Gio = imports.gi.Gio;
+
 imports.package.init({ name: "@name@",
                        version: "@PACKAGE_VERSION@",
                        prefix: "@prefix@",
                        libdir: "@libdir@" });
-imports.package.run(imports.@name@);
+
+log('program name: ' + imports.system.programInvocationName);
+log('ARG: ' + imports.system.programArgs);
+
+// manually load GResource from build tree for the generated test scripts
+let resource = Gio.Resource.load(imports.system.programArgs[0]);
+
+resource._register();
+
+import(`resource:///org/gnome/Maps@suffix@/js/@name@.js`).catch(error => {
+    console.error(error);
+    imports.system.exit(1);
+});
diff --git a/tests/timeTest.js b/tests/timeTest.js
index a2ea6c18..96803f2f 100644
--- a/tests/timeTest.js
+++ b/tests/timeTest.js
@@ -21,16 +21,11 @@
 
 const JsUnit = imports.jsUnit;
 
-const Time = imports.time;
-
-function main() {
-  formatTimeWithTZOffsetTest();
-  formatTimeFromHoursAndMinsTest();
-}
+import * as Time from './time.js';
 
 function formatTimeWithTZOffsetTest() {
     // mock to always use 24 hour format
-    Time._is12Hour = function () { return false; };
+    Time._setIs12HourFunction(() => { return false; });
 
     JsUnit.assertEquals('22:54',
                         Time.formatTimeWithTZOffset(1607982864000, 3600000));
@@ -38,7 +33,7 @@ function formatTimeWithTZOffsetTest() {
                         Time.formatTimeWithTZOffset(1607982864000, 0));
 
     // mock to always use 12 hour format
-    Time._is12Hour = function () { return true; };
+    Time._setIs12HourFunction(() => { return true; });
 
     JsUnit.assertEquals('10:54 PM',
                         Time.formatTimeWithTZOffset(1607982864000, 3600000));
@@ -46,16 +41,19 @@ function formatTimeWithTZOffsetTest() {
 
 function formatTimeFromHoursAndMinsTest() {
     // mock to always use 24 hour format
-    Time._is12Hour = function () { return false; };
+    Time._setIs12HourFunction(() => { return false; });
 
     JsUnit.assertEquals('12:34', Time.formatTimeFromHoursAndMins(12, 34));
     JsUnit.assertEquals('00:00', Time.formatTimeFromHoursAndMins(24, 0));
     JsUnit.assertEquals('12:01', Time.formatTimeFromHoursAndMins(12, 1));
 
     // mock to always use 12 hour format
-    Time._is12Hour = function () { return true; };
+    Time._setIs12HourFunction(() => { return true; });
 
     JsUnit.assertEquals('12:34 PM', Time.formatTimeFromHoursAndMins(12, 34));
     JsUnit.assertEquals('12:00 AM', Time.formatTimeFromHoursAndMins(24, 0));
     JsUnit.assertEquals('12:01 PM', Time.formatTimeFromHoursAndMins(12, 1));
 }
+
+formatTimeWithTZOffsetTest();
+formatTimeFromHoursAndMinsTest();
diff --git a/tests/translationsTest.js b/tests/translationsTest.js
index bd99a6b4..422c1b5e 100644
--- a/tests/translationsTest.js
+++ b/tests/translationsTest.js
@@ -19,13 +19,13 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-pkg.require({ 'Gdk': '3.0',
-              'Gtk': '3.0' });
+import 'gi://Gdk?version=3.0';
+import 'gi://Gtk?version=3.0';
 
 const JsUnit = imports.jsUnit;
 
-const Time = imports.time;
-const Translations = imports.translations;
+import * as Time from './time.js';
+import * as Translations from './translations.js';
 
 // sample with 3 components, one day-range, two single days, single time ranges
 const SAMPLE1 = 'Mo-Fr 09:00-18:00; Sa 10:00-15:00; Su 12:00-15:00';
@@ -56,179 +56,174 @@ const SAMPLE10 = 'Mo-Fr 09:00-12:00, 13:00-18:00; Sa,Su 10:00-14:00';
 pkg.initGettext();
 pkg.initFormat();
 
-function main() {
-  translateOpeningHoursTest();
-}
-
-function translateOpeningHoursTest() {
-    // mock to use 24-hour clock format
-    Time._is12Hour = function () { return false; };
-
-    let translated = Translations.translateOpeningHours(SAMPLE1);
-    JsUnit.assertEquals(3, translated.length);
-    JsUnit.assertEquals(2, translated[0].length);
-    JsUnit.assertEquals('Mon-Fri', translated[0][0]);
-    JsUnit.assertEquals('09:00-18:00', translated[0][1]);
-    JsUnit.assertEquals(2, translated[1].length);
-    JsUnit.assertEquals('Sat', translated[1][0]);
-    JsUnit.assertEquals('10:00-15:00', translated[1][1]);
-    JsUnit.assertEquals(2, translated[2].length);
-    JsUnit.assertEquals('Sun', translated[2][0]);
-    JsUnit.assertEquals('12:00-15:00', translated[2][1]);
-
-    translated = Translations.translateOpeningHours(SAMPLE2);
-    JsUnit.assertEquals(2, translated.length);
-    JsUnit.assertEquals(2, translated[0].length);
-    JsUnit.assertEquals('Mon-Fri', translated[0][0]);
-    JsUnit.assertEquals('09:00-12:00, 13:00-18:00', translated[0][1]);
-    JsUnit.assertEquals(2, translated[1].length);
-    JsUnit.assertEquals('Sat,Sun', translated[1][0]);
-    JsUnit.assertEquals('10:00-14:00', translated[1][1]);
-
-    translated = Translations.translateOpeningHours(SAMPLE3);
-    JsUnit.assertEquals(1, translated.length);
-    JsUnit.assertEquals(1, translated[0].length);
-    JsUnit.assertEquals('From sunrise to sunset', translated[0][0]);
-
-    translated = Translations.translateOpeningHours(SAMPLE4);
-    JsUnit.assertEquals(1, translated.length);
-    JsUnit.assertEquals(1, translated[0].length);
-    JsUnit.assertEquals('Around the clock', translated[0][0]);
-
-    translated = Translations.translateOpeningHours(SAMPLE5);
-    JsUnit.assertEquals(1, translated.length);
-    JsUnit.assertEquals(1, translated[0].length);
-    JsUnit.assertEquals('Around the clock', translated[0][0]);
-
-    translated = Translations.translateOpeningHours(SAMPLE6);
-    JsUnit.assertEquals(3, translated.length);
-    JsUnit.assertEquals(2, translated[0].length);
-    JsUnit.assertEquals('Mon-Fri', translated[0][0]);
-    JsUnit.assertEquals('09:00-18:00', translated[0][1]);
-    JsUnit.assertEquals(2, translated[1].length);
-    JsUnit.assertEquals('Sat', translated[1][0]);
-    JsUnit.assertEquals('10:00-15:00', translated[1][1]);
-    JsUnit.assertEquals(2, translated[2].length);
-    JsUnit.assertEquals('Sun', translated[2][0]);
-    JsUnit.assertEquals('not open', translated[2][1]);
-
-    translated = Translations.translateOpeningHours(SAMPLE7);
-    JsUnit.assertEquals(2, translated.length);
-    JsUnit.assertEquals(2, translated[0].length);
-    JsUnit.assertEquals('Mon-Fri', translated[0][0]);
-    JsUnit.assertEquals('09:00-12:00, 13:00-18:00', translated[0][1]);
-    JsUnit.assertEquals(2, translated[1].length);
-    JsUnit.assertEquals('Sat,Sun', translated[1][0]);
-    JsUnit.assertEquals('10:00-14:00', translated[1][1]);
-
-    translated = Translations.translateOpeningHours(SAMPLE8);
-    JsUnit.assertEquals(3, translated.length);
-    JsUnit.assertEquals(2, translated[0].length);
-    JsUnit.assertEquals('Mon-Fri', translated[0][0]);
-    JsUnit.assertEquals('09:00-12:00, 13:00-18:00', translated[0][1]);
-    JsUnit.assertEquals(2, translated[1].length);
-    JsUnit.assertEquals('Sat,Sun', translated[1][0]);
-    JsUnit.assertEquals('10:00-14:00', translated[1][1]);
-    JsUnit.assertEquals(2, translated[2].length);
-    JsUnit.assertEquals('Public holidays', translated[2][0]);
-    JsUnit.assertEquals('not open', translated[2][1]);
-
-    translated = Translations.translateOpeningHours(SAMPLE9);
-    JsUnit.assertEquals(3, translated.length);
-    JsUnit.assertEquals(2, translated[0].length);
-    JsUnit.assertEquals('Mon-Fri', translated[0][0]);
-    JsUnit.assertEquals('09:00-12:00, 13:00-18:00', translated[0][1]);
-    JsUnit.assertEquals(2, translated[1].length);
-    JsUnit.assertEquals('Sat,Sun', translated[1][0]);
-    JsUnit.assertEquals('10:00-14:00', translated[1][1]);
-    JsUnit.assertEquals(2, translated[2].length);
-    JsUnit.assertEquals('School holidays', translated[2][0]);
-    JsUnit.assertEquals('not open', translated[2][1]);
-
-    translated = Translations.translateOpeningHours(SAMPLE10);
-    JsUnit.assertEquals(2, translated.length);
-    JsUnit.assertEquals(2, translated[0].length);
-    JsUnit.assertEquals('Mon-Fri', translated[0][0]);
-    JsUnit.assertEquals('09:00-12:00, 13:00-18:00', translated[0][1]);
-    JsUnit.assertEquals(2, translated[1].length);
-    JsUnit.assertEquals('Sat,Sun', translated[1][0]);
-    JsUnit.assertEquals('10:00-14:00', translated[1][1]);
-
-    // mock to always use 12-hour clock format
-    Time._is12Hour = function () { return true; };
-
-    translated = Translations.translateOpeningHours(SAMPLE1);
-    JsUnit.assertEquals(3, translated.length);
-    JsUnit.assertEquals(2, translated[0].length);
-    JsUnit.assertEquals('Mon-Fri', translated[0][0]);
-    JsUnit.assertEquals(2, translated[1].length);
-    JsUnit.assertEquals('Sat', translated[1][0]);
-    JsUnit.assertEquals(2, translated[2].length);
-    JsUnit.assertEquals('Sun', translated[2][0]);
-
-    translated = Translations.translateOpeningHours(SAMPLE2);
-    JsUnit.assertEquals(2, translated.length);
-    JsUnit.assertEquals(2, translated[0].length);
-    JsUnit.assertEquals('Mon-Fri', translated[0][0]);
-    JsUnit.assertEquals(2, translated[1].length);
-    JsUnit.assertEquals('Sat,Sun', translated[1][0]);
-
-    translated = Translations.translateOpeningHours(SAMPLE3);
-    JsUnit.assertEquals(1, translated.length);
-    JsUnit.assertEquals(1, translated[0].length);
-    JsUnit.assertEquals('From sunrise to sunset', translated[0][0]);
-
-    translated = Translations.translateOpeningHours(SAMPLE4);
-    JsUnit.assertEquals(1, translated.length);
-    JsUnit.assertEquals(1, translated[0].length);
-    JsUnit.assertEquals('Around the clock', translated[0][0]);
-
-    translated = Translations.translateOpeningHours(SAMPLE5);
-    JsUnit.assertEquals(1, translated.length);
-    JsUnit.assertEquals(1, translated[0].length);
-    JsUnit.assertEquals('Around the clock', translated[0][0]);
-
-    translated = Translations.translateOpeningHours(SAMPLE6);
-    JsUnit.assertEquals(3, translated.length);
-    JsUnit.assertEquals(2, translated[0].length);
-    JsUnit.assertEquals('Mon-Fri', translated[0][0]);
-    JsUnit.assertEquals(2, translated[1].length);
-    JsUnit.assertEquals('Sat', translated[1][0]);
-    JsUnit.assertEquals(2, translated[2].length);
-    JsUnit.assertEquals('Sun', translated[2][0]);
-    JsUnit.assertEquals('not open', translated[2][1]);
-
-    translated = Translations.translateOpeningHours(SAMPLE7);
-    JsUnit.assertEquals(2, translated.length);
-    JsUnit.assertEquals(2, translated[0].length);
-    JsUnit.assertEquals('Mon-Fri', translated[0][0]);
-    JsUnit.assertEquals(2, translated[1].length);
-    JsUnit.assertEquals('Sat,Sun', translated[1][0]);
-
-    translated = Translations.translateOpeningHours(SAMPLE8);
-    JsUnit.assertEquals(3, translated.length);
-    JsUnit.assertEquals(2, translated[0].length);
-    JsUnit.assertEquals('Mon-Fri', translated[0][0]);
-    JsUnit.assertEquals(2, translated[1].length);
-    JsUnit.assertEquals('Sat,Sun', translated[1][0]);
-    JsUnit.assertEquals(2, translated[2].length);
-    JsUnit.assertEquals('Public holidays', translated[2][0]);
-    JsUnit.assertEquals('not open', translated[2][1]);
-
-    translated = Translations.translateOpeningHours(SAMPLE9);
-    JsUnit.assertEquals(3, translated.length);
-    JsUnit.assertEquals(2, translated[0].length);
-    JsUnit.assertEquals('Mon-Fri', translated[0][0]);
-    JsUnit.assertEquals(2, translated[1].length);
-    JsUnit.assertEquals('Sat,Sun', translated[1][0]);
-    JsUnit.assertEquals(2, translated[2].length);
-    JsUnit.assertEquals('School holidays', translated[2][0]);
-    JsUnit.assertEquals('not open', translated[2][1]);
-
-    translated = Translations.translateOpeningHours(SAMPLE10);
-    JsUnit.assertEquals(2, translated.length);
-    JsUnit.assertEquals(2, translated[0].length);
-    JsUnit.assertEquals('Mon-Fri', translated[0][0]);
-    JsUnit.assertEquals(2, translated[1].length);
-    JsUnit.assertEquals('Sat,Sun', translated[1][0]);
-}
+// mock to use 24-hour clock format
+Time._setIs12HourFunction(() => { return false; });
+
+let translated = Translations.translateOpeningHours(SAMPLE1);
+JsUnit.assertEquals(3, translated.length);
+JsUnit.assertEquals(2, translated[0].length);
+JsUnit.assertEquals('Mon-Fri', translated[0][0]);
+JsUnit.assertEquals('09:00-18:00', translated[0][1]);
+JsUnit.assertEquals(2, translated[1].length);
+JsUnit.assertEquals('Sat', translated[1][0]);
+JsUnit.assertEquals('10:00-15:00', translated[1][1]);
+JsUnit.assertEquals(2, translated[2].length);
+JsUnit.assertEquals('Sun', translated[2][0]);
+JsUnit.assertEquals('12:00-15:00', translated[2][1]);
+
+translated = Translations.translateOpeningHours(SAMPLE2);
+JsUnit.assertEquals(2, translated.length);
+JsUnit.assertEquals(2, translated[0].length);
+JsUnit.assertEquals('Mon-Fri', translated[0][0]);
+JsUnit.assertEquals('09:00-12:00, 13:00-18:00', translated[0][1]);
+JsUnit.assertEquals(2, translated[1].length);
+JsUnit.assertEquals('Sat,Sun', translated[1][0]);
+JsUnit.assertEquals('10:00-14:00', translated[1][1]);
+
+translated = Translations.translateOpeningHours(SAMPLE3);
+JsUnit.assertEquals(1, translated.length);
+JsUnit.assertEquals(1, translated[0].length);
+JsUnit.assertEquals('From sunrise to sunset', translated[0][0]);
+
+translated = Translations.translateOpeningHours(SAMPLE4);
+JsUnit.assertEquals(1, translated.length);
+JsUnit.assertEquals(1, translated[0].length);
+JsUnit.assertEquals('Around the clock', translated[0][0]);
+
+translated = Translations.translateOpeningHours(SAMPLE5);
+JsUnit.assertEquals(1, translated.length);
+JsUnit.assertEquals(1, translated[0].length);
+JsUnit.assertEquals('Around the clock', translated[0][0]);
+
+translated = Translations.translateOpeningHours(SAMPLE6);
+JsUnit.assertEquals(3, translated.length);
+JsUnit.assertEquals(2, translated[0].length);
+JsUnit.assertEquals('Mon-Fri', translated[0][0]);
+JsUnit.assertEquals('09:00-18:00', translated[0][1]);
+JsUnit.assertEquals(2, translated[1].length);
+JsUnit.assertEquals('Sat', translated[1][0]);
+JsUnit.assertEquals('10:00-15:00', translated[1][1]);
+JsUnit.assertEquals(2, translated[2].length);
+JsUnit.assertEquals('Sun', translated[2][0]);
+JsUnit.assertEquals('not open', translated[2][1]);
+
+translated = Translations.translateOpeningHours(SAMPLE7);
+JsUnit.assertEquals(2, translated.length);
+JsUnit.assertEquals(2, translated[0].length);
+JsUnit.assertEquals('Mon-Fri', translated[0][0]);
+JsUnit.assertEquals('09:00-12:00, 13:00-18:00', translated[0][1]);
+JsUnit.assertEquals(2, translated[1].length);
+JsUnit.assertEquals('Sat,Sun', translated[1][0]);
+JsUnit.assertEquals('10:00-14:00', translated[1][1]);
+
+translated = Translations.translateOpeningHours(SAMPLE8);
+JsUnit.assertEquals(3, translated.length);
+JsUnit.assertEquals(2, translated[0].length);
+JsUnit.assertEquals('Mon-Fri', translated[0][0]);
+JsUnit.assertEquals('09:00-12:00, 13:00-18:00', translated[0][1]);
+JsUnit.assertEquals(2, translated[1].length);
+JsUnit.assertEquals('Sat,Sun', translated[1][0]);
+JsUnit.assertEquals('10:00-14:00', translated[1][1]);
+JsUnit.assertEquals(2, translated[2].length);
+JsUnit.assertEquals('Public holidays', translated[2][0]);
+JsUnit.assertEquals('not open', translated[2][1]);
+
+translated = Translations.translateOpeningHours(SAMPLE9);
+JsUnit.assertEquals(3, translated.length);
+JsUnit.assertEquals(2, translated[0].length);
+JsUnit.assertEquals('Mon-Fri', translated[0][0]);
+JsUnit.assertEquals('09:00-12:00, 13:00-18:00', translated[0][1]);
+JsUnit.assertEquals(2, translated[1].length);
+JsUnit.assertEquals('Sat,Sun', translated[1][0]);
+JsUnit.assertEquals('10:00-14:00', translated[1][1]);
+JsUnit.assertEquals(2, translated[2].length);
+JsUnit.assertEquals('School holidays', translated[2][0]);
+JsUnit.assertEquals('not open', translated[2][1]);
+
+translated = Translations.translateOpeningHours(SAMPLE10);
+JsUnit.assertEquals(2, translated.length);
+JsUnit.assertEquals(2, translated[0].length);
+JsUnit.assertEquals('Mon-Fri', translated[0][0]);
+JsUnit.assertEquals('09:00-12:00, 13:00-18:00', translated[0][1]);
+JsUnit.assertEquals(2, translated[1].length);
+JsUnit.assertEquals('Sat,Sun', translated[1][0]);
+JsUnit.assertEquals('10:00-14:00', translated[1][1]);
+
+// mock to always use 12-hour clock format
+Time._setIs12HourFunction(() => { return true; });
+
+translated = Translations.translateOpeningHours(SAMPLE1);
+JsUnit.assertEquals(3, translated.length);
+JsUnit.assertEquals(2, translated[0].length);
+JsUnit.assertEquals('Mon-Fri', translated[0][0]);
+JsUnit.assertEquals(2, translated[1].length);
+JsUnit.assertEquals('Sat', translated[1][0]);
+JsUnit.assertEquals(2, translated[2].length);
+JsUnit.assertEquals('Sun', translated[2][0]);
+
+translated = Translations.translateOpeningHours(SAMPLE2);
+JsUnit.assertEquals(2, translated.length);
+JsUnit.assertEquals(2, translated[0].length);
+JsUnit.assertEquals('Mon-Fri', translated[0][0]);
+JsUnit.assertEquals(2, translated[1].length);
+JsUnit.assertEquals('Sat,Sun', translated[1][0]);
+
+translated = Translations.translateOpeningHours(SAMPLE3);
+JsUnit.assertEquals(1, translated.length);
+JsUnit.assertEquals(1, translated[0].length);
+JsUnit.assertEquals('From sunrise to sunset', translated[0][0]);
+
+translated = Translations.translateOpeningHours(SAMPLE4);
+JsUnit.assertEquals(1, translated.length);
+JsUnit.assertEquals(1, translated[0].length);
+JsUnit.assertEquals('Around the clock', translated[0][0]);
+
+translated = Translations.translateOpeningHours(SAMPLE5);
+JsUnit.assertEquals(1, translated.length);
+JsUnit.assertEquals(1, translated[0].length);
+JsUnit.assertEquals('Around the clock', translated[0][0]);
+
+translated = Translations.translateOpeningHours(SAMPLE6);
+JsUnit.assertEquals(3, translated.length);
+JsUnit.assertEquals(2, translated[0].length);
+JsUnit.assertEquals('Mon-Fri', translated[0][0]);
+JsUnit.assertEquals(2, translated[1].length);
+JsUnit.assertEquals('Sat', translated[1][0]);
+JsUnit.assertEquals(2, translated[2].length);
+JsUnit.assertEquals('Sun', translated[2][0]);
+JsUnit.assertEquals('not open', translated[2][1]);
+
+translated = Translations.translateOpeningHours(SAMPLE7);
+JsUnit.assertEquals(2, translated.length);
+JsUnit.assertEquals(2, translated[0].length);
+JsUnit.assertEquals('Mon-Fri', translated[0][0]);
+JsUnit.assertEquals(2, translated[1].length);
+JsUnit.assertEquals('Sat,Sun', translated[1][0]);
+
+translated = Translations.translateOpeningHours(SAMPLE8);
+JsUnit.assertEquals(3, translated.length);
+JsUnit.assertEquals(2, translated[0].length);
+JsUnit.assertEquals('Mon-Fri', translated[0][0]);
+JsUnit.assertEquals(2, translated[1].length);
+JsUnit.assertEquals('Sat,Sun', translated[1][0]);
+JsUnit.assertEquals(2, translated[2].length);
+JsUnit.assertEquals('Public holidays', translated[2][0]);
+JsUnit.assertEquals('not open', translated[2][1]);
+
+translated = Translations.translateOpeningHours(SAMPLE9);
+JsUnit.assertEquals(3, translated.length);
+JsUnit.assertEquals(2, translated[0].length);
+JsUnit.assertEquals('Mon-Fri', translated[0][0]);
+JsUnit.assertEquals(2, translated[1].length);
+JsUnit.assertEquals('Sat,Sun', translated[1][0]);
+JsUnit.assertEquals(2, translated[2].length);
+JsUnit.assertEquals('School holidays', translated[2][0]);
+JsUnit.assertEquals('not open', translated[2][1]);
+
+translated = Translations.translateOpeningHours(SAMPLE10);
+JsUnit.assertEquals(2, translated.length);
+JsUnit.assertEquals(2, translated[0].length);
+JsUnit.assertEquals('Mon-Fri', translated[0][0]);
+JsUnit.assertEquals(2, translated[1].length);
+JsUnit.assertEquals('Sat,Sun', translated[1][0]);
+
diff --git a/tests/urisTest.js b/tests/urisTest.js
index 4c08bfb8..f5fe6e86 100644
--- a/tests/urisTest.js
+++ b/tests/urisTest.js
@@ -19,23 +19,17 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-pkg.require({ 'Gdk': '3.0',
-              'Gtk': '3.0',
-              'Soup': '2.4' });
+import 'gi://Gdk?version=3.0';
+import 'gi://Gtk?version=3.0';
+import 'gi://Soup?version=2.4';
 
 const JsUnit = imports.jsUnit;
 
-const URIS = imports.uris;
+import * as URIS from './uris.js';
 
 const OSM_COORD_URL1 =
     'https://www.openstreetmap.org/?lat=39.9882&lon=-78.2409&zoom=14&layers=B000FTF';
 
-function main() {
-    parseAsObjectURLTest();
-    parseAsCoordinateURLTest();
-    parseMapsURITest();
-}
-
 function parseAsObjectURLTest() {
     _assertArrayEquals([], URIS.parseAsObjectURL('https://www.example.com'));
     _assertArrayEquals([], URIS.parseAsObjectURL('https://www.openstreet.org/'));
@@ -81,3 +75,7 @@ function _assertArrayEquals(arr1, arr2) {
     }
 }
 
+parseAsObjectURLTest();
+parseAsCoordinateURLTest();
+parseMapsURITest();
+
diff --git a/tests/utilsTest.js b/tests/utilsTest.js
index 190b3247..af3719e0 100644
--- a/tests/utilsTest.js
+++ b/tests/utilsTest.js
@@ -19,38 +19,37 @@
  * Author: Marcus Lundblad <ml update uu se>
  */
 
-pkg.require({ 'Gdk': '3.0',
-              'Gtk': '3.0' });
-pkg.initFormat();
+import 'gi://Gdk?version=3.0';
+import 'gi://Gtk?version=3.0';
+
+import GeocodeGlib from 'gi://GeocodeGlib';
+import GLib from 'gi://GLib';
 
-const Geocode = imports.gi.GeocodeGlib;
-const GLib = imports.gi.GLib;
+import * as Utils from './utils.js';
 
 const JsUnit = imports.jsUnit;
 
-const Utils = imports.utils;
-
-function main() {
-    osmTypeToStringTest();
-    dashedToCamelCaseTest();
-    getAccuracyDescriptionTest();
-    prettyTimeTest();
-    prettyDistanceTest();
-    prettyPopulationTest();
-    normalizeStringTest();
-    validWebsiteTest();
-    validEmailTest();
-    firstToLocaleUpperCaseTest();
-    splitAtFirstTest();
-}
+pkg.initFormat();
+
+osmTypeToStringTest();
+dashedToCamelCaseTest();
+getAccuracyDescriptionTest();
+prettyTimeTest();
+prettyDistanceTest();
+prettyPopulationTest();
+normalizeStringTest();
+validWebsiteTest();
+validEmailTest();
+firstToLocaleUpperCaseTest();
+splitAtFirstTest();
 
 function osmTypeToStringTest() {
     JsUnit.assertEquals('OSM type node', 'node',
-                        Utils.osmTypeToString(Geocode.PlaceOsmType.NODE));
+                        Utils.osmTypeToString(GeocodeGlib.PlaceOsmType.NODE));
     JsUnit.assertEquals('OSM type way', 'way',
-                        Utils.osmTypeToString(Geocode.PlaceOsmType.WAY));
+                        Utils.osmTypeToString(GeocodeGlib.PlaceOsmType.WAY));
     JsUnit.assertEquals('OSM type relation', 'relation',
-                        Utils.osmTypeToString(Geocode.PlaceOsmType.RELATION));
+                        Utils.osmTypeToString(GeocodeGlib.PlaceOsmType.RELATION));
 }
 
 function dashedToCamelCaseTest() {
@@ -60,7 +59,7 @@ function dashedToCamelCaseTest() {
 
 function getAccuracyDescriptionTest() {
     JsUnit.assertEquals('Unknown',
-                        Utils.getAccuracyDescription(Geocode.LOCATION_ACCURACY_UNKNOWN));
+                        Utils.getAccuracyDescription(GeocodeGlib.LOCATION_ACCURACY_UNKNOWN));
     JsUnit.assertEquals('Exact', Utils.getAccuracyDescription(0));
     // for other distances, the same as prettyDistance()
     JsUnit.assertEquals(Utils.prettyDistance(100),
@@ -82,16 +81,16 @@ function prettyTimeTest() {
 }
 
 function prettyDistanceTest() {
-    // tests with metric system, using override mock function
-    Utils.getMeasurementSystem = function() { return Utils.METRIC_SYSTEM; };
+    // tests with metric system
+    Utils._setMeasurementSystem(Utils.METRIC_SYSTEM);
     JsUnit.assertEquals('1 km', Utils.prettyDistance(1000, false));
     JsUnit.assertEquals('2.4 km', Utils.prettyDistance(2400, false));
     JsUnit.assertEquals('123 m', Utils.prettyDistance(123, false));
     JsUnit.assertEquals('1 km', Utils.prettyDistance(1001, false));
     JsUnit.assertEquals('1,001 m', Utils.prettyDistance(1001, true));
 
-    // tests with imperial system, using override mock function
-    Utils.getMeasurementSystem = function() { return Utils.IMPERIAL_SYSTEM; };
+    // tests with imperial system
+    Utils._setMeasurementSystem(Utils.IMPERIAL_SYSTEM);
     JsUnit.assertEquals('1 mi', Utils.prettyDistance(1609, false));
     JsUnit.assertEquals('2.4 mi', Utils.prettyDistance(3900, false));
     JsUnit.assertEquals('0.3 mi', Utils.prettyDistance(440, false));
@@ -150,3 +149,4 @@ function splitAtFirstTest() {
     _assertPair('q', 'Query=more', Utils.splitAtFirst('q=Query=more', '='));
     JsUnit.assertEquals(1, Utils.splitAtFirst('noseparator', '=').length);
 }
+
diff --git a/tests/wikipediaTest.js b/tests/wikipediaTest.js
index 145c3cfa..72d55178 100644
--- a/tests/wikipediaTest.js
+++ b/tests/wikipediaTest.js
@@ -18,27 +18,23 @@
  *
  * Author: Marcus Lundblad <ml update uu se>
  */
-const JsUnit = imports.jsUnit;
 
-pkg.require({ 'Gdk':  '3.0',
-              'Gtk':  '3.0',
-              'Soup': '2.4' });
+import 'gi://Gdk?version=3.0';
+import 'gi://Gtk?version=3.0';
+import 'gi://Soup?version=2.4';
+
+import * as Wikipedia from './wikipedia.js';
 
-const Wikipedia = imports.wikipedia;
+const JsUnit = imports.jsUnit;
 
-function main() {
-    isValidWikipediaTest();
-}
 
-function isValidWikipediaTest() {
-    // valid references
-    JsUnit.assertTrue(Wikipedia.isValidWikipedia('en:Test article'));
-    JsUnit.assertTrue(Wikipedia.isValidWikipedia('en:Test article:with colon'));
-    JsUnit.assertTrue(Wikipedia.isValidWikipedia('arz:ويكيبيديا مصرى'));
-    JsUnit.assertTrue(Wikipedia.isValidWikipedia('simple:Article'));
-    JsUnit.assertTrue(Wikipedia.isValidWikipedia('zh-yue:粵文維基百科'));
+// valid references
+JsUnit.assertTrue(Wikipedia.isValidWikipedia('en:Test article'));
+JsUnit.assertTrue(Wikipedia.isValidWikipedia('en:Test article:with colon'));
+JsUnit.assertTrue(Wikipedia.isValidWikipedia('arz:ويكيبيديا مصرى'));
+JsUnit.assertTrue(Wikipedia.isValidWikipedia('simple:Article'));
+JsUnit.assertTrue(Wikipedia.isValidWikipedia('zh-yue:粵文維基百科'));
 
-    // invalid references
-    JsUnit.assertFalse(Wikipedia.isValidWikipedia('https://en.wikipedia.org/wiki/Article'));
-    JsUnit.assertFalse(Wikipedia.isValidWikipedia('Article with no edition'));
-}
+// invalid references
+JsUnit.assertFalse(Wikipedia.isValidWikipedia('https://en.wikipedia.org/wiki/Article'));
+JsUnit.assertFalse(Wikipedia.isValidWikipedia('Article with no edition'));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]