Skip to content

Add native module registry to global. (Part 2)

Evan Welsh requested to merge native-registry into master

Depends on !453 (merged).

In ESM code to facilitate importing native modules such as system, gi, and others we need direct access to these objects as opposed to relying on imports[name].

This merge preserves the original behavior of imports.system but also adds a native registry slot in the global which can host these objects.

This allows accessing them in C++ like...

gjs_get_native_module_registry(cx)->lookup("gi")
gjs_get_native_module_registry(cx)->lookup("system")
// ... etc

and in internal JS (one ESM is merged)...

import.meta.require('gi');
import.meta.require('system');

which will allow users to import like...

import system from 'system';

Depends on #453.

Edited by Philip Chimento

Merge request reports