Skip to content

Conversation

@martinnaj
Copy link
Contributor

@martinnaj martinnaj commented Jul 1, 2025

What:

Add an "exports" field to package.json to provide explicit module resolution paths for both ESM and CommonJS consumers. Also add an explicit "./react-native" export to support React Native's Metro bundler while preserving the existing "react-native" field.

Why:

Currently, importing Downshift in some environments (Node.js native ESM, bundlers) causes issues where users must access .default due to CommonJS interop. Adding "exports" clarifies the entry points and avoids this common pitfall.

Furthermore, React Native support requires the "react-native" field, which is preserved, but adding the "./react-native" export path improves compatibility with native module resolution.

How:

  • Added an "exports" object to package.json with explicit "import" and "require" paths for ".".
  • Added "./react-native" export path pointing to the native CommonJS build.
  • Retained existing "main", "module", and "react-native" fields for backward compatibility.
  • No changes to source code or build output were made.

Checklist:

  • Documentation N/A
  • Tests N/A
  • TypeScript Types N/A
  • Flow Types N/A
  • Ready to be merged

@martinnaj
Copy link
Contributor Author

@silviuaavram Review please

@silviuaavram
Copy link
Collaborator

@martinnaj can you take another look over the comments please? Also, is there any change required for those umd and nativeWeb?

@martinnaj
Copy link
Contributor Author

@silviuaavram Which comments? This shouldn't break anything, just provide better ESM support, there may be a need for react-native users to import using the alias, however that will be based on the transpiler.

@martinnaj
Copy link
Contributor Author

@silviuaavram Please re-review

@martinnaj
Copy link
Contributor Author

@silviuaavram bump

@silviuaavram
Copy link
Collaborator

Looks good @martinnaj ! Thank you for the changes, they should be really helpful! Could we also add a default option to the "."? Afterwards we should be good to merge this.

"default": "./dist/downshift.esm.js"

@martinnaj
Copy link
Contributor Author

@silviuaavram Done, please merge asap

@silviuaavram silviuaavram merged commit 1743dfd into downshift-js:master Jul 21, 2025
3 checks passed
@github-actions
Copy link

🎉 This PR is included in version 9.0.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

2 participants