Skip to content

NET-1457: Define explicit "exports" for SDK #3117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025

Conversation

mondoreale
Copy link
Contributor

Summary

We've encountered a strange behaviour where if you run node script.js and it's a esm script then node's module resolver will try to import the cjs sdk and not the esm one.

Since we're targeting newer node versions anyway, it'd seem important to prioritise "exports" field over "main"/"module". In this PR I populate "exports" field but also keep the legacy fields for good measure (won't hurt).

IIRC the SDK is the only package that distinguishes between require and import exports.

Changes

Add an explicit "exports" field into SDK's package.json.

Limitations and future improvements

In the future we may consider using the "exports" field exclusively, and drop "main" and "module". We target newer tools after all, and the legacy fields are mainly for older envs.

Checklist before requesting a review

  • Is this a breaking change? If it is, be clear in summary.
  • Read through code myself one more time.
  • Make sure any and all TODO comments left behind are meant to be left in.
  • Has reasonable passing test coverage?
  • Updated changelog if applicable.
  • Updated documentation if applicable.

@mondoreale mondoreale requested review from harbu and teogeb May 13, 2025 10:06
Copy link

linear bot commented May 13, 2025

@github-actions github-actions bot added the sdk label May 13, 2025
@mondoreale mondoreale changed the title Define explicit "exports" for SDK NET-1457: Define explicit "exports" for SDK May 13, 2025
@harbu harbu self-requested a review May 13, 2025 13:11
@mondoreale mondoreale merged commit f4ee2e6 into main May 16, 2025
24 checks passed
@mondoreale mondoreale deleted the net-1457-streamrsdk-rc-version-packaging branch May 16, 2025 09:21
jtakalai pushed a commit that referenced this pull request May 20, 2025
## Summary

We've encountered a strange behaviour where if you run `node script.js`
and it's a esm script then node's module resolver will try to import the
cjs sdk and not the esm one.

Since we're targeting newer node versions anyway, it'd seem important to
prioritise "exports" field over "main"/"module". In this PR I populate
"exports" field but also keep the legacy fields for good measure (won't
hurt).

IIRC the SDK is the only package that distinguishes between _require_
and _import_ exports.

## Changes

Add an explicit "exports" field into SDK's package.json.

## Limitations and future improvements

In the future we may consider using the "exports" field exclusively, and
drop "main" and "module". We target newer tools after all, and the
legacy fields are mainly for older envs.

## Checklist before requesting a review

- [x] Is this a breaking change? If it is, be clear in summary.
- [x] Read through code myself one more time.
- [x] Make sure any and all `TODO` comments left behind are meant to be
left in.
- [x] Has reasonable passing test coverage?
- [x] Updated changelog if applicable.
- [x] Updated documentation if applicable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants