Add support for GJS (GNOME JavaScript) module system#34
Open
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #29
This commit implements comprehensive support for the GJS runtime, enabling use-m to work seamlessly in GNOME JavaScript environments. Key features: - Runtime detection via `typeof imports !== 'undefined'` - GJS-specific resolver with gi:// protocol support for GObject introspection - Support for GJS built-in modules (cairo, system, byteArray, etc.) - Built-in module emulation for console and url in GJS environment - Legacy imports object integration - Modern ES modules support in GJS Changes: - Added gjs resolver to handle gi:// URLs and GJS built-ins - Updated runtime detection logic in both use.mjs and use.cjs - Extended supportedBuiltins with GJS environment support - Added comprehensive test coverage for GJS functionality - Created examples for both modern and legacy GJS usage - Updated documentation with GJS usage examples Fixes #29 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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