diff --git a/with-tv/README.md b/with-tv/README.md index 09a2bce3..f7462d35 100644 --- a/with-tv/README.md +++ b/with-tv/README.md @@ -22,3 +22,7 @@ npx expo prebuild yarn ios # Build for Apple TV yarn android # Build for Android TV ``` + +#### TV specific file extensions + +This project contains an [example Metro configuration](./metro.config.js) that allows Metro to resolve application source files with TV-specific code, indicated by specific file extensions (`*.ios.tv.tsx`, `*.android.tv.tsx`, `*.tv.tsx`). This config is not enabled by default, since it will impact bundling performance, but is available for developers who need this capability. diff --git a/with-tv/metro.config.js b/with-tv/metro.config.js new file mode 100644 index 00000000..3680a0c1 --- /dev/null +++ b/with-tv/metro.config.js @@ -0,0 +1,24 @@ +// Learn more https://docs.expo.io/guides/customizing-metro +const { getDefaultConfig } = require('expo/metro-config'); + +const config = getDefaultConfig(__dirname); + +// When enabled, the optional code below will allow Metro to resolve +// and bundle source files with TV-specific extensions +// (e.g., *.ios.tv.tsx, *.android.tv.tsx, *.tv.tsx) +// +// Metro will still resolve source files with standard extensions +// as usual if TV-specific files are not found for a module. +// +/* +if (process.env?.EXPO_TV === '1') { + const originalSourceExts = config.resolver.sourceExts; + const tvSourceExts = [ + ...originalSourceExts.map((e) => `tv.${e}`), + ...originalSourceExts, + ]; + config.resolver.sourceExts = tvSourceExts; +} + */ + +module.exports = config; diff --git a/with-tv/package.json b/with-tv/package.json index fc44fba4..718a9656 100644 --- a/with-tv/package.json +++ b/with-tv/package.json @@ -3,12 +3,12 @@ "version": "1.0.0", "dependencies": { "@react-native-tvos/config-tv": "~0.0.4", - "expo": "^50.0.0-preview.4", - "expo-splash-screen": "~0.26.0", - "expo-status-bar": "~1.11.0", + "expo": "^50.0.0", + "expo-splash-screen": "~0.26.3", + "expo-status-bar": "~1.11.1", "react": "18.2.0", "react-dom": "18.2.0", - "react-native": "npm:react-native-tvos@~0.73.1-0" + "react-native": "npm:react-native-tvos@^0.73.1-3" }, "devDependencies": { "@babel/core": "~7.20.0",