Add support for GJS (GNOME JavaScript) module system #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements comprehensive support for the GJS (GNOME JavaScript) runtime, enabling
use-mto work seamlessly in GNOME JavaScript environments. GJS is the JavaScript runtime used by GNOME Shell, Maps, Characters, Sound Recorder, and many other GNOME applications.Key Features Added
typeof imports !== 'undefined'gjsresolver with support for:gi://protocol for GObject introspection libraries (e.g.,gi://GLib,gi://Gtk?version=4.0)Code Changes
Core Implementation
use.mjsanduse.cjs: Added GJS resolver and runtime detection logicExamples
examples/gjs/example.mjs: Modern ES modules example for GJSexamples/gjs/legacy-example.js: Legacy imports object exampleexamples/gjs/test-local.mjs: Local implementation testTests
tests/gjs-support.test.mjs: Comprehensive test suite for GJS functionalitytests/gjs-support.test.cjs: CommonJS version of test suiteDocumentation
README.md: Added GJS section with usage examples and feature descriptionsUsage Examples
Modern GJS with ES Modules
Legacy GJS with imports object
Test Results
Technical Implementation Details
The GJS resolver handles three types of modules:
gi://protocol): Uses the legacyimports.giobject with version supportRuntime detection uses the presence of the global
importsobject, which is unique to GJS environments.Test Plan
Fixes #29
🤖 Generated with Claude Code