feat: add ESM support via Node.js loader hooks#148
Merged
ilearnio merged 1 commit intoilearnio:masterfrom Feb 2, 2026
Merged
Conversation
- Add register.mjs as ESM entry point for --import flag - Add esm-loader.mjs with resolve hooks for _moduleAliases and _moduleDirectories - Support Node 22.15+ (registerHooks) and Node 18.19+ (register) APIs - Add exports field to package.json for dual CJS/ESM support - Add ESM test suite (13 tests) with fixtures - Update CI to test Node 18/20/22 with ESM - Update README with ESM usage documentation Closes ilearnio#59 Closes ilearnio#113
Owner
|
Great job! This is very much needed 🔥 |
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
_moduleAliasesand_moduleDirectoriesfrom package.json in ESMregisterHooks()for Node 22.15+,register()for Node 18.19+Usage
Changes
register.mjs- ESM entry point with version detectionesm-loader.mjs- Core resolve hooks implementationpackage.json- Addedexportsfield for dual CJS/ESM supportREADME.md- ESM documentation section.github/workflows/node.js.yml- CI for Node 18/20/22Test Plan
isPathMatchesAliasandresolveAlias(11 tests)--importflag (2 tests)_moduleAliasesand_moduleDirectoriesCloses #59
Closes #113