feat(exports): Add support for react-native conditional exports#284
feat(exports): Add support for react-native conditional exports#284xgtz421 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Why is this necessary? |
EnglishThank you for the question! This PR addresses a critical issue in React Native 0.84+ where the Metro bundler's new package resolution logic breaks backward The Problem:
Why not just disable
The Solution: 中文感谢提问!这个 PR 解决了 React Native 0.84+ 中一个关键的向后兼容性问题——Metro bundler 的新包解析逻辑破坏了对 tslib 的支持。 问题描述:
为什么不直接禁用
|
|
I don't understand why this is a problem with |
|
You're right — this is not a tslib issue. The root cause is that Metro bundler doesn't enable the "import" condition by default when resolving package exports, so it falls back to the CJS entry. Under Hermes's ESM interop, the named exports then become undefined. I've worked around this on our side by redirecting tslib to tslib.es6.mjs in our Metro config. Sorry for the noise, and thanks for taking the time to explain. |
In the exports field of package.json, a react-native conditional export has been added for the "." entry, pointing to ./modules/index.d.ts (types) and ./tslib.es6.mjs (default).