-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breaking: Remove Expo SDK 51 config, switch to app.config.ts #462
Changes from 13 commits
c39362d
08e5933
1f5114f
5285bc0
046310f
e517f2e
4eba886
c1dab94
1ef7305
a263039
b51e448
c305cdd
ab38f32
722d8ce
d0dc9db
135ab51
42491bb
dad5d73
abc0e43
aac3141
d3caa1d
f9a3a41
f8cdd74
c23acfc
758ed1f
3ee4cbc
de6c878
78bb7ef
ca81b51
67a1833
decbd22
a6a2863
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,13 +1,13 @@ | ||||||||||||||||
// Enable Expo non-default options for performance: | ||||||||||||||||
// | ||||||||||||||||
// 1. app.json - Enable New Architecture for iOS and Android | ||||||||||||||||
// - https://docs.expo.dev/guides/new-architecture/ | ||||||||||||||||
// 1. app.json - Convert to app.config.ts | ||||||||||||||||
// - https://docs.expo.dev/workflow/configuration/ | ||||||||||||||||
// 2. .env.development, .env.production, eas.json - Enable the new Metro resolver available starting in Expo SDK 51 | ||||||||||||||||
// - https://github.com/EvanBacon/pillar-valley/commit/ede321ef7addc67e4047624aedb3e92af3cb5060 | ||||||||||||||||
// - https://archive.ph/MG03E | ||||||||||||||||
// | ||||||||||||||||
// TODO: Remove when Expo enables New Architecture and new Metro resolver by default | ||||||||||||||||
import { readFile, writeFile } from 'node:fs/promises'; | ||||||||||||||||
import { readFile, unlink, writeFile } from 'node:fs/promises'; | ||||||||||||||||
import isPlainObject from 'is-plain-obj'; | ||||||||||||||||
|
||||||||||||||||
const appFilePath = 'app.json'; | ||||||||||||||||
|
@@ -19,28 +19,24 @@ if (!isPlainObject(appJson) || !isPlainObject(appJson.expo)) { | |||||||||||||||
); | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
appJson.expo.experiments ||= {}; | ||||||||||||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- Set to empty object in previous line, if falsy | ||||||||||||||||
appJson.expo.experiments.typedRoutes = true; | ||||||||||||||||
|
||||||||||||||||
appJson.expo.plugins = [ | ||||||||||||||||
[ | ||||||||||||||||
'expo-build-properties', | ||||||||||||||||
{ | ||||||||||||||||
ios: { | ||||||||||||||||
newArchEnabled: true, | ||||||||||||||||
}, | ||||||||||||||||
android: { | ||||||||||||||||
newArchEnabled: true, | ||||||||||||||||
}, | ||||||||||||||||
}, | ||||||||||||||||
], | ||||||||||||||||
]; | ||||||||||||||||
|
||||||||||||||||
await writeFile(appFilePath, JSON.stringify(appJson, null, 2), 'utf8'); | ||||||||||||||||
console.log( | ||||||||||||||||
'✅ Enabled New Architecture and typedRoutes experiment in app.json', | ||||||||||||||||
); | ||||||||||||||||
const expoConfig = | ||||||||||||||||
`import { ExpoConfig } from "expo/config"; | ||||||||||||||||
|
||||||||||||||||
const config: ExpoConfig = ${JSON.stringify(appJson.expo, null, 2) | ||||||||||||||||
.replace(/"([^"]+)":/g, '$1:') | ||||||||||||||||
.replace(/"(.*?)"/g, `'$1'`) | ||||||||||||||||
.replace(/([}\]])(\s*[}\]])/g, '$1,$2') | ||||||||||||||||
.replace(/}(\s+\])/g, '},$1') | ||||||||||||||||
.replace(/(?<!,)(\n\s*[}\]])/g, ',$1')}; | ||||||||||||||||
|
||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. switch to Prettier for this, don't write our own home-grown formatting code Prettier is installed in eslint-config-upleveled/bin/install.js Lines 157 to 163 in 0e66443
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can run the Prettier with This command runs local Prettier and formats the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's use the Prettier API since we're already executing JS There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To use Prettier, ESLint needs to be installed first. However, the current Command Line Cheatsheet places the ESLint installation as the final step (step 4). Since we require Prettier to format Changing the order of steps in the cheatsheet is not an option. Potential solutions without creating a CLI:
The best solution right now seems to be using the Reverted and used Update: Also tested with a echo -e "import { type ExpoConfig } from \"expo/config\";\n\nconst config: ExpoConfig = {\n name: '$(\jq -r '.expo.name' app.json)',\n slug: '$(\jq -r '.expo.slug' app.json)',\n version: '1.0.0',\n orientation: 'portrait',\n icon: './assets/images/icon.png',\n scheme: 'myapp',\n userInterfaceStyle: 'automatic',\n newArchEnabled: true,\n ios: {\n supportsTablet: true,\n },\n android: {\n adaptiveIcon: {\n foregroundImage: './assets/images/adaptive-icon.png',\n backgroundColor: '#ffffff',\n },\n },\n web: {\n bundler: 'metro',\n output: 'static',\n favicon: './assets/images/favicon.png',\n },\n plugins: [\n 'expo-router',\n [\n 'expo-splash-screen',\n {\n image: './assets/images/splash-icon.png',\n imageWidth: 200,\n resizeMode: 'contain',\n backgroundColor: '#ffffff',\n },\n ],\n ],\n experiments: {\n typedRoutes: true,\n },\n};\n\nexport default config;" > app.config.ts
rm app.json There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We came to the solution to add Prettier in the |
||||||||||||||||
export default config; | ||||||||||||||||
`.trim() + '\n'; | ||||||||||||||||
|
||||||||||||||||
await writeFile('app.config.ts', expoConfig, 'utf8'); | ||||||||||||||||
console.log('✅ Converted app.json to app.config.ts'); | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since we're taking over converting to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||
|
||||||||||||||||
await unlink(appFilePath); | ||||||||||||||||
console.log('✅ Deleted app.json'); | ||||||||||||||||
|
||||||||||||||||
await writeFile('.env.development', 'EXPO_USE_FAST_RESOLVER=1', 'utf8'); | ||||||||||||||||
console.log('✅ Enabled new Metro resolver in .env.development'); | ||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ProchaLu is this equivalent with the new setting you mentioned comes by default:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still the possibility to add the specific iOS / Android
newArchEnabled
settings, but we want to use thenewArchEnabled = true
in both.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, that doesn't mention that it's the same as
expo-build-properties
anywhere, but it's probably the same, so let's stick with thatif you can easily verify that the app is running in the New Architecture, that would be a helpful additional step
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the docs from "Enable the New Architecture in an existing project":
SDK 52:
SDK 51:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok good, that's probably enough proof, thanks!