Open
Conversation
- Added ESM implementation research summary detailing testing evidence and technical findings. - Created test suite for pure ESM modules in `test/test-50-esm-pure`, including: - README.md outlining the problem with ESM packages. - main.js to run tests and package ESM modules. - test-x-index.js to validate ESM module loading. - package.json and package-lock.json for dependencies. - Developed test suite for UUID v10+ in `test/test-50-uuid-v10`, including: - README.md explaining the test objectives. - main.js to execute tests and validate outputs. - test-x-index.js to test various UUID functionalities. - Established a strategy for transforming ESM to CJS using Babel to ensure compatibility with existing pkg infrastructure.
- Created lib/resolver.ts with ESM-aware resolution using resolve.exports - Enhanced lib/follow.ts to try ESM resolution first for non-relative imports - Fixed package.json inclusion for ESM packages with exports field - Added synthetic 'main' field to package.json when only exports exists - Ensures all discovered package.json files are included in snapshot - Both test-50-esm-pure (nanoid) and test-50-uuid-v10 now pass - No regressions in existing tests This completes Sprint 2 of the ESM implementation plan.
robertsLando
commented
Dec 11, 2025
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.
This pull request introduces enhanced support for ECMAScript Modules (ESM) in the Node.js packaging workflow, ensuring that ESM modules are correctly resolved, transformed, and included in the package output. The changes add ESM-aware module resolution, automatic transformation of ESM code to CommonJS for bytecode compilation, and improved handling of
package.jsonfiles for ESM packages. Documentation and dependencies are updated to reflect these improvements.ESM Support and Module Resolution:
lib/resolver.tsthat handles package.json "exports" fields and resolves modules according to ESM rules, falling back to CommonJS resolution if needed.lib/follow.tsto use the new ESM resolver for non-relative module specifiers, including logic to ensure relatedpackage.jsonfiles are included and patched with syntheticmainfields when necessary. [1] [2] [3]ESM Detection and Transformation:
lib/common.tsto detect ESM files and packages by inspecting file extensions and the nearestpackage.json"type" field.lib/esm-transformer.tsto transform ESM code to CommonJS using Babel, enabling ESM modules to be compiled to bytecode.lib/walker.tsto patchpackage.jsonfiles for ESM packages and transform ESM.jsfiles to CommonJS before bytecode compilation. [1] [2] [3] [4]Documentation and Dependency Updates:
.github/copilot-instructions.mdto document the newplans/directory and clarify that Yarn is used for package management. [1] [2]package.json, including Babel plugins andresolve.exports. [1] [2] [3]