Skip to content

fix(node): support module-sync export condition#34599

Merged
littledivy merged 4 commits into
mainfrom
orch/divybot-350
May 31, 2026
Merged

fix(node): support module-sync export condition#34599
littledivy merged 4 commits into
mainfrom
orch/divybot-350

Conversation

@divybot

@divybot divybot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Closes denoland/orchid#350
Fixes #29970

Summary

  • add module-sync to the default npm package export conditions for both import and require resolution
  • include module-sync in CJS analyzer require-style re-export resolution
  • add npm spec coverage for a package whose module-sync conditional export appears before node for both import and createRequire()

Testing

  • cargo fmt --check
  • cargo test -p node_resolver

Notes

  • Attempted cargo test specs::npm::module_sync_condition -- --no-capture, but the filtered spec target was killed during the first full CLI test binary build before reaching the test phase.

@littledivy littledivy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does require(esm) match the module-sync export?

@littledivy littledivy changed the title feat(node): support module-sync export condition fix(node): support module-sync export condition May 31, 2026
@divybot

divybot commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

Yes. I added a direct resolver unit test for that case: test_module_sync_condition_matches_import_and_require now resolves the same conditional export object in both ResolutionMode::Import and ResolutionMode::Require, with module-sync and node branches, and asserts both modes select ./sync.mjs.

Re-ran:

  • cargo fmt --check
  • cargo test -p node_resolver

@divybot

divybot commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

Pushed a fix for the CI failures. The spec was also importing module-sync-pkg/nested, which Deno rejected as an undeclared package subpath dependency in debug spec runs. I trimmed the fixture to assert the root package import and createRequire() path; the direct resolver unit test still covers both import and require selecting module-sync.

Re-ran locally:

  • cargo fmt --check
  • cargo test -p node_resolver

I also attempted the filtered spec locally, but stopped it during the first full CLI test-target build after confirming the CI failure source from logs.

@divybot

divybot commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

Pushed a follow-up fix for the debug spec failure: the local module-sync-pkg fixture now has a root package.json dependency declaration, so bare package validation accepts module-sync-pkg while still resolving from the fixture node_modules package.

Re-ran locally:

  • cargo fmt --check
  • cargo test -p node_resolver

I also attempted the focused spec locally, but stopped it while it was still in the first full specs_tests compile.

@littledivy
littledivy merged commit 0d99a42 into main May 31, 2026
136 checks passed
@littledivy
littledivy deleted the orch/divybot-350 branch May 31, 2026 12:26
@bartlomieju

Copy link
Copy Markdown
Member

@divybot please open a PR in the docs repo updating relevant sections about this new export condition

littledivy added a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
Closes denoland/orchid#350
Fixes denoland#29970

## Summary
- add `module-sync` to the default npm package export conditions for
both import and require resolution
- include `module-sync` in CJS analyzer require-style re-export
resolution
- add npm spec coverage for a package whose `module-sync` conditional
export appears before `node` for both import and `createRequire()`

## Testing
- `cargo fmt --check`
- `cargo test -p node_resolver`

## Notes
- Attempted `cargo test specs::npm::module_sync_condition --
--no-capture`, but the filtered spec target was killed during the first
full CLI test binary build before reaching the test phase.

---------

Co-authored-by: divybot <[email protected]>
Co-authored-by: Divy Srivastava <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for module-sync conditional export

3 participants