|
29 | 29 | run: | |
30 | 30 | yarn build |
31 | 31 | # yarn build rewrites package.json "exports" from ./src to ./dist |
32 | | - # for publishing. The dist/ files use ESM syntax that requires |
33 | | - # babel-register (only wired up in src/index.js). When the test |
34 | | - # project loads react-native-macos as a dependency via symlink, |
35 | | - # require('@react-native/community-cli-plugin') resolves to |
36 | | - # dist/index.js which fails to load, silently preventing the |
37 | | - # macos platform from being registered. Restore src exports so |
38 | | - # the monorepo's babel-register entry point is used. |
| 32 | + # for publishing. Restore the original exports so that any |
| 33 | + # monorepo tooling that still runs from source continues to work. |
39 | 34 | git checkout -- packages/*/package.json |
40 | 35 |
|
41 | 36 | - name: Build react-native-macos-init |
|
61 | 56 | working-directory: ${{ runner.temp }}/testcli |
62 | 57 | run: | |
63 | 58 | set -eox pipefail |
64 | | - npm install ${{ github.workspace }}/packages/react-native |
| 59 | + # --install-links copies the package instead of symlinking it. |
| 60 | + # Without this, Node follows the symlink's real path back to the |
| 61 | + # monorepo for module resolution, causing bundle.js to load a |
| 62 | + # different instance of @react-native/metro-config than the one |
| 63 | + # the user's metro.config.js uses. The setFrameworkDefaults() |
| 64 | + # call (which registers the "macos" platform) then targets the |
| 65 | + # wrong instance, and xcodebuild fails with "Invalid platform". |
| 66 | + npm install --install-links ${{ github.workspace }}/packages/react-native |
65 | 67 |
|
66 | 68 | - name: Apply macOS template |
67 | 69 | working-directory: ${{ runner.temp }}/testcli |
|
70 | 72 | node ${{ github.workspace }}/packages/react-native-macos-init/bin.js --verbose --overwrite --prerelease |
71 | 73 | pod install --project-directory=macos |
72 | 74 |
|
73 | | - - name: Debug config |
74 | | - working-directory: ${{ runner.temp }}/testcli |
75 | | - run: | |
76 | | - set -eox pipefail |
77 | | - echo "=== node_modules/react-native-macos symlink ===" |
78 | | - ls -la node_modules/react-native-macos |
79 | | - echo "=== community-cli-plugin exports ===" |
80 | | - node -e "console.log(require('${{ github.workspace }}/packages/community-cli-plugin/package.json').exports)" |
81 | | - echo "=== community-cli-plugin resolve ===" |
82 | | - node -e "console.log(require.resolve('@react-native/community-cli-plugin', {paths: [require.resolve('react-native-macos')]}))" |
83 | | - echo "=== cli.js config platforms ===" |
84 | | - node node_modules/react-native-macos/cli.js config 2>&1 | node -e "const d=JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')); console.log('platforms:', Object.keys(d.platforms))" |
85 | | - echo "=== direct config load ===" |
86 | | - node -e "process.chdir('${{ runner.temp }}/testcli'); const c = require('${{ github.workspace }}/packages/react-native/react-native.config.js'); console.log('platforms:', Object.keys(c.platforms))" |
87 | | -
|
88 | 75 | - name: Build macOS app |
89 | 76 | working-directory: ${{ runner.temp }}/testcli |
90 | 77 | run: | |
|
0 commit comments