Repository navigation
refactor: use module.registerHooks for the gi: ESM loader - #486
Merged
Merged
Conversation
Switch the `gi:` scheme loader from `module.register` (async hooks on a separate loader thread, loaded by URL) to `module.registerHooks` (synchronous, in-thread hooks passed directly as functions). Since registerHooks takes the hook functions rather than a module URL, the whole implementation now lives in register.mjs and the separate hooks.mjs file (plus its `./hooks` package export, which was unused) is removed. The resolve and load hooks are now synchronous, as registerHooks requires; the synthetic `gi.require` module emitted by `load` is unchanged. Bumps the minimum from Node >= 20.6 (module.register) to Node >= 22.15 (module.registerHooks); node-gtk v4 already targets Node 22/24/26. Co-Authored-By: Claude Opus 4.8 <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.
Switches the
gi:scheme ESM loader frommodule.registertomodule.registerHooks.What
lib/esm/register.mjs— callsregisterHooks({ resolve, load })with the hook functions directly. BecauseregisterHookstakes functions (not a module URL) and runs them synchronously, in-thread, the whole implementation is consolidated here.lib/esm/hooks.mjs— removed. It only needed to be a separate URL-loaded file for the oldregister(url)mechanism. Theresolve/loadhooks are now synchronous (asregisterHooksrequires) and module-private.package.json— dropped the now-dead./hooksexport (undocumented and unused; existed solely for URL-based registration).doc/importing.md— minimum bumped from Node ≥ 20.6 (module.register) to Node ≥ 22.15 (module.registerHooks). node-gtk v4 already targets Node 22/24/26.The synthetic
gi.requiremodule emitted byloadis unchanged, so runtime behavior ofgi:imports is identical.Verified locally
All import paths pass against the consolidated file:
import GLib from 'gi:GLib-2.0'via--import node-gtk/registertests/esm__gi_import.jsrunner (exit 0)import 'node-gtk/register'+ dynamic importgi:GLibNote
Removing the
./hooksexport is a (dead) public-API change — it was never documented and nothing importednode-gtk/hooks.🤖 Generated with Claude Code