forked from software-mansion/react-native-reanimated
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issues with relative paths when bundling web apps (software-mansi…
…on#3922) <!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary Fixes issues when bundling web apps using reanimated due to relative path to `package.json` being wrongly resolved in prebuild reanimated modules. <!-- Explain the motivation for this PR. Include "Fixes #<number>" if applicable. -->
- Loading branch information
Showing
3 changed files
with
36 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { version as jsVersion } from '../../../package.json'; | ||
|
||
/** | ||
* Checks that native and js versions of reanimated match. | ||
*/ | ||
export function checkVersion(): void { | ||
const cppVersion = global._REANIMATED_VERSION_CPP; | ||
const ok = (() => { | ||
if ( | ||
jsVersion.match(/^\d+\.\d+\.\d+$/) && | ||
cppVersion.match(/^\d+\.\d+\.\d+$/) | ||
) { | ||
// x.y.z, compare only major and minor, skip patch | ||
const [jsMajor, jsMinor] = jsVersion.split('.'); | ||
const [cppMajor, cppMinor] = cppVersion.split('.'); | ||
return jsMajor === cppMajor && jsMinor === cppMinor; | ||
} else { | ||
// alpha, beta or rc, compare everything | ||
return jsVersion === cppVersion; | ||
} | ||
})(); | ||
if (!ok) { | ||
console.error( | ||
`[Reanimated] Mismatch between JavaScript part and native part of Reanimated (${jsVersion} vs. ${cppVersion}). Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must downgrade to ${cppVersion} which is bundled into Expo SDK.` | ||
); | ||
// TODO: detect Expo managed workflow | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* eslint-disable @typescript-eslint/no-empty-function */ | ||
/** | ||
* Checks that native and js versions of reanimated match. | ||
* Stubbed for web, where this check is unnecessary. | ||
*/ | ||
export function checkVersion(): void {} |