Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds support for the new module_type field on resolution results to follow Node’s ESM_FILE_FORMAT rules.
- Expose
ModuleTypein CJS, browser, and main entrypoints - Add fixtures for ESM/CJS package.json type detection
- Update Rust example to print and toggle the new
module_type
Reviewed Changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| napi/resolver.wasi.cjs | Export ModuleType from the native N-API binding |
| napi/resolver.wasi-browser.js | Export ModuleType from the browser shim |
| napi/index.js | Export ModuleType in the main entrypoint |
| fixtures/pnpm/package.json | Reorder devDependencies and add decimal.js, mathjs, minimatch |
| fixtures/misc/module-type/esm/package.json | Add fixture with "type": "module" |
| fixtures/misc/module-type/cjs/package.json | Add fixture with "type": "commonjs" |
| examples/resolver.rs | Print module_type in example and switch to CJS mode |
Comments suppressed due to low confidence (2)
napi/index.js:388
- Add unit tests to verify the new
module_typeresolution in key scenarios (e.g.,.mjs,.cjs, and.jswith package.jsontype) to ensure correct behavior.
module.exports.ModuleType = nativeBinding.ModuleType
fixtures/pnpm/package.json:13
- [nitpick] The devDependencies list order is inconsistent; consider sorting entries alphabetically for easier diffs and maintenance.
"minimatch": "10.0.1"
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #535 +/- ##
==========================================
+ Coverage 93.84% 93.89% +0.04%
==========================================
Files 13 13
Lines 2829 2867 +38
==========================================
+ Hits 2655 2692 +37
- Misses 174 175 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #535 will not alter performanceComparing Summary
|
34014b1 to
99f88ea
Compare
…om the spec fixes #527
99f88ea to
a377881
Compare
Merged
1 task
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.
resolves #527
fixes #508
This PR adds a new
module_typeoption and also to the returned result.Node.js will treat the following as ES modules:
Node.js will treat the following as CommonJS:
See
ESM_FILE_FORMATin https://nodejs.org/docs/latest/api/esm.html#resolution-algorithm-specification