docs: Use ESM in HACKING guide

We now use standard ES modules for imports instead of gjs' legacy
system. The documentation should reflect that.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2868>
This commit is contained in:
Florian Müllner 2023-08-07 17:05:46 +02:00 committed by Marge Bot
parent 477011a364
commit 88cbc85cde

View File

@ -74,18 +74,18 @@ gobject-introspection or modules added by gjs itself.
The second block of imports should contain only "application imports". These The second block of imports should contain only "application imports". These
are the JS code that is in the gnome-shell codebase, are the JS code that is in the gnome-shell codebase,
e.g. `imports.ui.popupMenu`. e.g. `'./popupMenu.js'`.
Each import block should be sorted alphabetically. Don't import modules you Each import block should be sorted alphabetically. Don't import modules you
don't use. don't use.
```javascript ```javascript
const GLib = imports.gi.GLib; import GLib from 'gi://GLib';
const Gio = imports.gi.Gio; import Gio from 'gi://Gio';
const St = imports.gi.St; import St from 'gi://St';
const Main = imports.ui.main; import * as Main from './main.js';
const Params = imports.misc.params; import * as Params from '../misc/params.js';
const Util = imports.misc.util; import * as Util from '../misc/util.js';
``` ```
The alphabetical ordering should be done independently of the location of the The alphabetical ordering should be done independently of the location of the
location. Never reference `imports` in actual code. location. Never reference `imports` in actual code.
@ -259,7 +259,7 @@ notation.
A more realistic example would be connecting to a signal on a method of a A more realistic example would be connecting to a signal on a method of a
prototype: prototype:
```javascript ```javascript
const FnorbLib = imports.fborbLib; import * as FnorbLib from './fborbLib.js';
export class MyClass { export class MyClass {
constructor() { constructor() {