-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugin): enable new architecture by default
release-npm BREAKING CHANGE: New React Native architecture enabled by default. Will require small migration in some cases. Use the "oldArchitecture": true option to keep using the old architecture.
- Loading branch information
Showing
9 changed files
with
88 additions
and
20 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
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,43 @@ | ||
import { readFileSync, writeFileSync } from 'fs' | ||
import { join } from 'path' | ||
|
||
interface Options { | ||
oldArchitecture?: boolean | ||
} | ||
|
||
interface PluginInput { | ||
// Root project path. | ||
projectPath?: string | ||
// Location of /android or /ios folders, either root or inside /.numic. | ||
nativePath?: string | ||
log?: (message: string, type?: 'error' | 'warning') => void | ||
options: Options | ||
// Currently installed React Native version. | ||
version?: string | ||
} | ||
|
||
export default async ({ | ||
nativePath = process.cwd(), | ||
log = console.log, | ||
options = {}, | ||
}: PluginInput) => { | ||
const { oldArchitecture } = options | ||
const gradlePropertiesFilePath = join(nativePath, 'android/gradle.properties') | ||
let gradlePropertiesContents = readFileSync(gradlePropertiesFilePath, 'utf-8') | ||
|
||
// Android requires gradle flag to be set, while iOS requires flag to be set during "pod install". | ||
if (oldArchitecture) { | ||
log('Using old architecture') | ||
gradlePropertiesContents = gradlePropertiesContents.replaceAll( | ||
'newArchEnabled=true', | ||
'newArchEnabled=false', | ||
) | ||
} else { | ||
log('Using new architecture') | ||
gradlePropertiesContents = gradlePropertiesContents.replaceAll( | ||
'newArchEnabled=false', | ||
'newArchEnabled=true', | ||
) | ||
} | ||
writeFileSync(gradlePropertiesFilePath, gradlePropertiesContents) | ||
} |
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
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
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