fix: add `react-native` to `byDependency`
Summary
Add react-native to byDependency in getResolveOptions. This fixes an issue with importing react-strict-dom when enablePackageExports is on. (Turning on enablePackageExports is what react-strict-dom recommends, and is the new metro default.)
Fixes #1183. There's additional discussion there.
Test plan
🦋 Changeset detected
Latest commit: 635f06b24b024d8ea179dce73d4e9f3aafddf543
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 6 packages
| Name | Type |
|---|---|
| @callstack/repack | Patch |
| @callstack/repack-plugin-expo-modules | Patch |
| @callstack/repack-plugin-nativewind | Patch |
| @callstack/repack-plugin-reanimated | Patch |
| @callstack/repack-dev-server | Patch |
| @callstack/repack-init | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| repack-website | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jul 23, 2025 0:12am |
looks like the resolver compat tests are also failing
looks like the resolver compat tests are also failing
Whoops. I'll try to get this fixed.
Looks like they're related to the "web" platform:
● with package exports resolution enabled › conditional exports › unstable_conditionsByPlatform › should resolve "browser" condition for `web` platform when configured
Anything I should know around that? I don't see a lot of platform web code in there already. Should I use preferNativePlatform, or _platform or some combination of those?
looks like the resolver compat tests are also failing
Whoops. I'll try to get this fixed.
Looks like they're related to the "web" platform:
● with package exports resolution enabled › conditional exports › unstable_conditionsByPlatform › should resolve "browser" condition for `web` platform when configuredAnything I should know around that? I don't see a lot of platform
webcode in there already. Should I usepreferNativePlatform, or_platformor some combination of those?
I've had a look at the tests and it looks like it's just a matter of a setup - the tests were failing because react-native condition was injected in places where it shouldn't have been.
in tests/metro-compat/resolver/resolve.ts change the following:
diff --git a/tests/metro-compat/resolver/resolve.ts b/tests/metro-compat/resolver/resolve.ts
index 1b3c105d1..064b07081 100644
--- a/tests/metro-compat/resolver/resolve.ts
+++ b/tests/metro-compat/resolver/resolve.ts
@@ -149,13 +149,9 @@ export function resolve(
// this is equivalent to "byDependency" configuration in rspack/webpack
// enhanced-resolve does not use "byDependency" configuration
if (metroContext.isESMImport) {
- resolveOptions.conditionNames?.push(
- ...resolutionPreset.byDependency.esm.conditionNames
- );
+ resolveOptions.conditionNames?.push('import');
} else {
- resolveOptions.conditionNames?.push(
- ...resolutionPreset.byDependency.commonjs.conditionNames
- );
+ resolveOptions.conditionNames?.push('require');
}
const resolve = enhancedResolve.create.sync(resolveOptions);
in tests/metro-compat/resolver/resolve.ts change the following:
Ok, I applied your fix, thanks!
I was trying to understand if that was really good enough or not, but I guess it is. Should I also be adding a test somewhere for this case, since I don't think anything existing is covering it?
in tests/metro-compat/resolver/resolve.ts change the following:
Ok, I applied your fix, thanks!
I was trying to understand if that was really good enough or not, but I guess it is. Should I also be adding a test somewhere for this case, since I don't think anything existing is covering it?
hey, sorry for my delayed reply
I've been working on setting up resolver cases test package along side existing metro compat tests, I'll try to get that merged and you will be able to add a test case there that will cover it 👍
@tringenbach please update the branch with newest main and then you can adjust the newly added resolver test cases which this PR fixes. The tests are already there so just removing .fails should do it :) (unless you want to add some more, then feel free to do so!)
@tringenbach let me know if you need clarification on something if needed, happy to help and drive this to the end 👍
@tringenbach please update the branch with newest main and then you can adjust the newly added resolver test cases which this PR fixes. The tests are already there so just removing
.failsshould do it :) (unless you want to add some more, then feel free to do so!)
Sorry, somehow I missed this message. I'll do that!
@tringenbach thank you for your work on this 🚀