Skip to content

Commit

Permalink
fix: "[BABEL] Note: The code generator has deoptimised the styling of…
Browse files Browse the repository at this point in the history
… ... as it exceeds the max of 500KB" by not letting react-native source code get through babel reanimated
  • Loading branch information
zetavg committed Sep 9, 2024
1 parent 43324b6 commit a5d97d0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/vxrn/src/plugins/babelReanimated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ const REANIMATED_AUTOWORKLETIZATION_KEYWORDS = [
*/
const REANIMATED_REGEX = new RegExp(REANIMATED_AUTOWORKLETIZATION_KEYWORDS.join('|'))

const REANIMATED_IGNORED_PATHS = [
// React and React Native libraries are not likely to use reanimated.
// This can also avoid the "[BABEL] Note: The code generator has deoptimised the styling of ... as it exceeds the max of 500KB" warning since the react-native source code also contains `useAnimatedProps`.
'react-native-prebuilt/vendor',
'node_modules/.vxrn/react-native',
]

const REANIMATED_IGNORED_PATHS_REGEX = new RegExp(
REANIMATED_IGNORED_PATHS.map((s) => s.replace(/\//g, '/')).join('|')
)

async function babelReanimated(input: string, filename: string) {
return await new Promise<string>((res, rej) => {
babel.transform(
Expand All @@ -52,7 +63,7 @@ export function getBabelReanimatedPlugin(): Plugin {
return
}

if (REANIMATED_REGEX.test(code)) {
if (!REANIMATED_IGNORED_PATHS_REGEX.test(id) && REANIMATED_REGEX.test(code)) {
const out = await babelReanimated(code, id)
return out
}
Expand Down

0 comments on commit a5d97d0

Please sign in to comment.