|
1 |
| -/** |
2 |
| - * This cli config is needed for the coexistance of react-native and other |
3 |
| - * out-of-tree implementations such react-native-macos. |
4 |
| - * The following issue is tracked by |
5 |
| - * https://github.com/react-native-community/discussions-and-proposals/issues/182 |
6 |
| - * |
7 |
| - * The work-around involves having a metro.config.js for each out-of-tree |
8 |
| - * platform, i.e. metro.config.js for react-native and |
9 |
| - * metro.config.macos.js for react-native-macos. |
10 |
| - * This react-native.config.js looks for a --use-react-native-macos |
11 |
| - * switch and when present pushes --config=metro.config.macos.js |
12 |
| - * and specifies reactNativePath: 'node_modules/react-native-macos'. |
13 |
| - * The metro.config.js has to blacklist 'node_modules/react-native-macos', |
14 |
| - * and conversely metro.config.macos.js has to blacklist 'node_modules/react-native'. |
15 |
| - */ |
16 |
| -'use strict'; |
17 |
| - |
| 1 | +const fs = require('fs'); |
18 | 2 | const path = require('path');
|
| 3 | +const { |
| 4 | + androidManifestPath, |
| 5 | + iosProjectPath, |
| 6 | + windowsProjectPath, |
| 7 | +} = require('react-native-test-app'); |
19 | 8 |
|
20 |
| -const dependencies = { |
21 |
| - '@react-native-async-storage/async-storage': { |
22 |
| - root: __dirname, |
23 |
| - // rn-cli incorrectly resolves node_modules path for the following platforms |
24 |
| - platforms: { |
25 |
| - ios: null, |
26 |
| - macos: null, |
| 9 | +module.exports = { |
| 10 | + dependencies: { |
| 11 | + '@react-native-async-storage/async-storage': { |
| 12 | + root: __dirname, |
| 13 | + // rn-cli incorrectly resolves node_modules path for the following platforms |
| 14 | + platforms: { |
| 15 | + ios: null, |
| 16 | + macos: null, |
| 17 | + }, |
27 | 18 | },
|
28 |
| - }, |
29 |
| - // Suppress warnings about bob not being a proper native module |
30 |
| - '@react-native-community/bob': { |
31 |
| - platforms: { |
32 |
| - android: null, |
33 |
| - ios: null, |
34 |
| - macos: null, |
35 |
| - windows: null, |
| 19 | + // Suppress warnings about bob not being a proper native module |
| 20 | + '@react-native-community/bob': { |
| 21 | + platforms: { |
| 22 | + android: null, |
| 23 | + ios: null, |
| 24 | + macos: null, |
| 25 | + windows: null, |
| 26 | + }, |
| 27 | + }, |
| 28 | + // We don't use Expo in our test apps |
| 29 | + expo: { |
| 30 | + platforms: { |
| 31 | + android: null, |
| 32 | + ios: null, |
| 33 | + macos: null, |
| 34 | + windows: null, |
| 35 | + }, |
36 | 36 | },
|
37 | 37 | },
|
38 |
| - // We don't use Expo in our test apps |
39 |
| - expo: { |
40 |
| - platforms: { |
41 |
| - android: null, |
42 |
| - ios: null, |
43 |
| - macos: null, |
44 |
| - windows: null, |
| 38 | + project: { |
| 39 | + android: { |
| 40 | + sourceDir: path.join('example', 'android'), |
| 41 | + manifestPath: androidManifestPath( |
| 42 | + path.join(__dirname, 'example', 'android') |
| 43 | + ), |
| 44 | + }, |
| 45 | + ios: { |
| 46 | + project: iosProjectPath('example/ios'), |
| 47 | + }, |
| 48 | + windows: fs.existsSync('example/windows/AsyncStorageExample.sln') && { |
| 49 | + sourceDir: path.join('example', 'windows'), |
| 50 | + solutionFile: 'AsyncStorageExample.sln', |
| 51 | + project: windowsProjectPath(path.join(__dirname, 'example', 'windows')), |
45 | 52 | },
|
46 | 53 | },
|
47 | 54 | };
|
48 |
| - |
49 |
| -if ( |
50 |
| - process.argv.includes('--use-react-native-windows') || |
51 |
| - process.argv.includes('autolink-windows') || |
52 |
| - process.argv.includes('run-windows') |
53 |
| -) { |
54 |
| - const sourceDir = path.join('example', 'windows'); |
55 |
| - module.exports = { |
56 |
| - dependencies, |
57 |
| - project: { |
58 |
| - // `@react-native-community/cli` mistakes |
59 |
| - // `windows/ReactNativeAsyncStorage.sln` and |
60 |
| - // `windows/ReactNativeAsyncStorage/ReactNativeAsyncStorage.vcxproj` for |
61 |
| - // being the main project files. We need to help it find the solution file |
62 |
| - // under `example/windows/` and the generated project files in |
63 |
| - // `node_modules/.generated/windows`. |
64 |
| - windows: { |
65 |
| - sourceDir, |
66 |
| - solutionFile: 'AsyncStorageExample.sln', |
67 |
| - project: { |
68 |
| - projectFile: path.relative( |
69 |
| - sourceDir, |
70 |
| - path.join( |
71 |
| - 'node_modules', |
72 |
| - '.generated', |
73 |
| - 'windows', |
74 |
| - 'ReactTestApp', |
75 |
| - 'ReactTestApp.vcxproj' |
76 |
| - ) |
77 |
| - ), |
78 |
| - }, |
79 |
| - }, |
80 |
| - }, |
81 |
| - reactNativePath: path.join('node_modules', 'react-native-windows'), |
82 |
| - }; |
83 |
| -} else { |
84 |
| - module.exports = { dependencies }; |
85 |
| -} |
0 commit comments