@@ -687,6 +687,52 @@ describe("checkReactNativeProject — Babel plugin order", () => {
687687 ) . toContain ( "rn-react-compiler-plugin-first" ) ;
688688 } ) ;
689689
690+ it ( "falls back to a lower-priority static Babel config" , ( ) => {
691+ const projectDirectory = makeProjectDirectory ( ) ;
692+ writePackageJson ( projectDirectory , {
693+ name : "rn-app" ,
694+ dependencies : { "react-native" : "0.82.0" } ,
695+ } ) ;
696+ writeFile ( projectDirectory , "babel.config.js" , `module.exports = { plugins: [` ) ;
697+ writeFile (
698+ projectDirectory ,
699+ "babel.config.cjs" ,
700+ `module.exports = { plugins: ['other-plugin', 'babel-plugin-react-compiler'] };` ,
701+ ) ;
702+
703+ expect (
704+ rulesOf ( checkReactNativeProject ( projectDirectory , buildRnProject ( projectDirectory ) ) ) ,
705+ ) . toContain ( "rn-react-compiler-plugin-first" ) ;
706+ } ) ;
707+
708+ it ( "falls back to a static package.json Babel config" , ( ) => {
709+ const projectDirectory = makeProjectDirectory ( ) ;
710+ writePackageJson ( projectDirectory , {
711+ name : "rn-app" ,
712+ dependencies : { "react-native" : "0.82.0" } ,
713+ babel : { plugins : [ "other-plugin" , "babel-plugin-react-compiler" ] } ,
714+ } ) ;
715+ writeFile ( projectDirectory , "babel.config.js" , `module.exports = getConfig();` ) ;
716+
717+ expect (
718+ rulesOf ( checkReactNativeProject ( projectDirectory , buildRnProject ( projectDirectory ) ) ) ,
719+ ) . toContain ( "rn-react-compiler-plugin-first" ) ;
720+ } ) ;
721+
722+ it ( "keeps the first statically readable Babel config authoritative" , ( ) => {
723+ const projectDirectory = makeProjectDirectory ( ) ;
724+ writePackageJson ( projectDirectory , {
725+ name : "rn-app" ,
726+ dependencies : { "react-native" : "0.82.0" } ,
727+ babel : { plugins : [ "other-plugin" , "babel-plugin-react-compiler" ] } ,
728+ } ) ;
729+ writeFile ( projectDirectory , "babel.config.js" , `module.exports = { plugins: [] };` ) ;
730+
731+ expect (
732+ rulesOf ( checkReactNativeProject ( projectDirectory , buildRnProject ( projectDirectory ) ) ) ,
733+ ) . not . toContain ( "rn-react-compiler-plugin-first" ) ;
734+ } ) ;
735+
690736 it ( "does NOT infer plugin order from a dynamic plugin array" , ( ) => {
691737 const projectDirectory = makeProjectDirectory ( ) ;
692738 writePackageJson ( projectDirectory , {
@@ -901,4 +947,49 @@ describe("checkReactNativeProject — Android release shrinking", () => {
901947 ) . not . toContain ( "rn-android-release-shrinking-disabled" ) ;
902948 } ) ;
903949
950+ it . each ( [
951+ [ "missing" , `android { buildTypes { debug { minifyEnabled false } } }` ] ,
952+ [
953+ "ambiguous" ,
954+ `android { buildTypes { release { minifyEnabled true } release { minifyEnabled false } } }` ,
955+ ] ,
956+ ] ) ( "falls back after a %s release block" , ( _caseName , groovyBuildContents ) => {
957+ const projectDirectory = makeProjectDirectory ( ) ;
958+ writePackageJson ( projectDirectory , {
959+ name : "rn-app" ,
960+ dependencies : { "react-native" : "0.82.0" } ,
961+ } ) ;
962+ writeFile ( projectDirectory , "android/app/build.gradle" , groovyBuildContents ) ;
963+ writeFile (
964+ projectDirectory ,
965+ "android/app/build.gradle.kts" ,
966+ `android { buildTypes { getByName("release") { isMinifyEnabled = false } } }` ,
967+ ) ;
968+
969+ expect (
970+ rulesOf ( checkReactNativeProject ( projectDirectory , buildRnProject ( projectDirectory ) ) ) ,
971+ ) . toContain ( "rn-android-release-shrinking-disabled" ) ;
972+ } ) ;
973+
974+ it ( "keeps the first statically readable Gradle file authoritative" , ( ) => {
975+ const projectDirectory = makeProjectDirectory ( ) ;
976+ writePackageJson ( projectDirectory , {
977+ name : "rn-app" ,
978+ dependencies : { "react-native" : "0.82.0" } ,
979+ } ) ;
980+ writeFile (
981+ projectDirectory ,
982+ "android/app/build.gradle" ,
983+ `android { buildTypes { release { minifyEnabled true } } }` ,
984+ ) ;
985+ writeFile (
986+ projectDirectory ,
987+ "android/app/build.gradle.kts" ,
988+ `android { buildTypes { getByName("release") { isMinifyEnabled = false } } }` ,
989+ ) ;
990+
991+ expect (
992+ rulesOf ( checkReactNativeProject ( projectDirectory , buildRnProject ( projectDirectory ) ) ) ,
993+ ) . not . toContain ( "rn-android-release-shrinking-disabled" ) ;
994+ } ) ;
904995} ) ;
0 commit comments