Skip to content

Commit a11e9e4

Browse files
committed
🐛 Fix an issue with local miniapps on RN<60
1 parent 6ec1abb commit a11e9e4

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

ern-composite-gen/src/generateComposite.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,21 @@ async function generateFullComposite(
174174
// To know the version to install, we will just have a peak to one of
175175
// the miniapps, given that react native version is aligned across all.
176176
const pJson = await readPackageJson(localMiniAppsPaths[0])
177+
const miniAppRnVersion = pJson.dependencies['react-native']
177178
extraJsDependencies.push(
178-
PackagePath.fromString(
179-
`react-native@${pJson.dependencies['react-native']}`
180-
)
179+
PackagePath.fromString(`react-native@${miniAppRnVersion}`)
181180
)
181+
// If the version of RN < 0.60.0 we also need to add react dependency
182+
// to the composite as it needs to be local to the bundler root for
183+
// some reason (probably haste related).
184+
// Otherwise bundling will fail to locate some react modules and throw
185+
// 'Unable to resolve module ...' errors.
186+
if (semver.lte(miniAppRnVersion, '0.60.0')) {
187+
extraJsDependencies.push(
188+
PackagePath.fromString(`react@${pJson.dependencies.react}`)
189+
)
190+
}
191+
182192
// Also add latest version of the bridge
183193
extraJsDependencies.push(
184194
PackagePath.fromString(`react-native-electrode-bridge`)

0 commit comments

Comments
 (0)