Skip to content

Commit 0c820ec

Browse files
authored
Upgrade RNX to target RNW 0.77 (#295)
This PR bumps RNX to target RNW 0.77, with a minimum of RNW 0.72. This PR also resolves such issues that have arisen: * Renamed XAML's `TabIndex` property mapping from `tabIndex` (which conflicts with upstream) to `xamlTabIndex` * Fixed yarn workspaces * Fixed example app metro configs so they can be run * Updated and aligned versions of packages in yarn.lock * Updated workflows with latest GitHub Actions versions for common tasks * Updated workflows to only target support RNW versions for new app testing * Updated workflow nuget restores to use lock files * Updated new app testing to use the new `react-native init-windows` Resolves #287 Resolves #288 ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/react-native-xaml/pull/295)
1 parent cccb9a7 commit 0c820ec

35 files changed

+2330
-9986
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,16 @@ jobs:
2727

2828
call-testcli:
2929
name: Test CLI (VS 2022)
30+
needs: setupcheck
3031
strategy:
3132
fail-fast: false
3233
matrix:
33-
rnwVersion: [ 'v0.73-stable', 'v0.72-stable', 'v0.71-stable'] # test *all* versions that use VS 2022. aka any RNW version >= min in package.json and >= 0.71
34-
useRnwNuGet: [false, true] # test building with both RNW source and RNW NuGet
35-
include:
36-
- rnwVersion: 'v0.73-stable'
37-
rnVersion: '0.73-stable'
38-
- rnwVersion: 'v0.72-stable'
39-
rnVersion: '0.72-stable'
40-
- rnwVersion: 'v0.71-stable'
41-
rnVersion: '0.71-stable'
34+
rnwVersion: ['latest', 'v0.76-stable', 'v0.75-stable', 'v0.72-stable'] # test *key* versions that use VS 2022. aka any RNW version >= 0.72 used by supported partners and/or Active/Maintenance from https://microsoft.github.io/react-native-windows/support
4235
uses: ./.github/workflows/template-testcli.yml
4336
with:
4437
vmImage: windows-2022
4538
rnwVersion: ${{ matrix.rnwVersion }}
46-
useRnwNuGet: ${{ matrix.useRnwNuGet }}
47-
rnVersion: ${{ matrix.rnVersion }}
39+
useRnwWindowsInit: ${{ matrix.rnwVersion == 'v0.72-stable' }}
4840

4941
call-buildnpmpackage:
5042
name: Build NPM Package

.github/workflows/pr.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
name: Setup Check
1010
runs-on: windows-2022
1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
1313

1414
- name: yarn install
1515
run: yarn install
@@ -42,19 +42,12 @@ jobs:
4242
strategy:
4343
fail-fast: true
4444
matrix:
45-
rnwVersion: ['v0.73-stable', 'v0.72-stable'] # test *key* versions that use VS 2022. aka any RNW version >= 0.71 used by supported partners and/or Active/Maintenance from https://microsoft.github.io/react-native-windows/support
46-
useRnwNuGet: [false, true] # test building with both RNW source and RNW NuGet
47-
include:
48-
- rnwVersion: 'v0.73-stable'
49-
rnVersion: '0.73-stable'
50-
- rnwVersion: 'v0.72-stable'
51-
rnVersion: '0.72-stable'
45+
rnwVersion: ['latest', 'v0.76-stable', 'v0.75-stable', 'v0.72-stable'] # test *key* versions that use VS 2022. aka any RNW version >= 0.72 used by supported partners and/or Active/Maintenance from https://microsoft.github.io/react-native-windows/support
5246
uses: ./.github/workflows/template-testcli.yml
5347
with:
5448
vmImage: windows-2022
5549
rnwVersion: ${{ matrix.rnwVersion }}
56-
useRnwNuGet: ${{ matrix.useRnwNuGet }}
57-
rnVersion: ${{ matrix.rnVersion }}
50+
useRnwWindowsInit: ${{ matrix.rnwVersion == 'v0.72-stable' }}
5851

5952
call-buildnpmpackage:
6053
name: Build NPM Package
@@ -82,4 +75,4 @@ jobs:
8275
runs-on: ubuntu-latest
8376
needs: [setupcheck, call-runcodegen, call-testcli, call-buildnpmpackage, call-buildrnx]
8477
steps:
85-
- uses: actions/checkout@v3
78+
- uses: actions/checkout@v4

.github/workflows/publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
needs: call-runcodegen
1818

1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2121

2222
- name: Use Node.js
23-
uses: actions/setup-node@v1
23+
uses: actions/setup-node@v4
2424
with:
2525
node-version: 18
2626
registry-url: https://registry.npmjs.org/
@@ -38,7 +38,7 @@ jobs:
3838
working-directory: package
3939

4040
- name: upload npm logs
41-
uses: actions/upload-artifact@v3
41+
uses: actions/upload-artifact@v4
4242
with:
4343
name: npm-logs
4444
path: /home/runner/.npm/_logs

.github/workflows/template-buildexample.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: Build ${{ inputs.exampleName }}
2222
runs-on: ${{ inputs.vmImage }}
2323
steps:
24-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
2525

2626
- name: yarn install
2727
run: yarn install
@@ -55,7 +55,7 @@ jobs:
5555
working-directory: ${{ inputs.exampleName }}
5656

5757
- name: Upload appx
58-
uses: actions/upload-artifact@v3
58+
uses: actions/upload-artifact@v4
5959
with:
6060
name: ${{ inputs.exampleName }} appx
6161
path: ${{ inputs.exampleName }}\windows\AppPackages\${{ inputs.exampleName }}\${{ inputs.exampleName }}_1.0.0.0_x64_Debug_Test

.github/workflows/template-buildnpmpackage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
name: Build NPM Package
1414
runs-on: ${{ inputs.vmImage }}
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717

1818
- name: yarn install
1919
run: yarn install
@@ -26,7 +26,7 @@ jobs:
2626
working-directory: package
2727

2828
- name: Upload npm package
29-
uses: actions/upload-artifact@v3
29+
uses: actions/upload-artifact@v4
3030
with:
3131
name: RNX npm package
3232
path: package\*.tgz

.github/workflows/template-buildrnx.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
name: Build RNX ${{ inputs.configuration }} ${{ inputs.platform }}
2222
runs-on: ${{ inputs.vmImage }}
2323
steps:
24-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
2525

2626
- name: setup-msbuild
27-
uses: microsoft/setup-msbuild@v1
27+
uses: microsoft/setup-msbuild@v2
2828

2929
- name: yarn install
3030
run: yarn install
@@ -33,21 +33,11 @@ jobs:
3333
run: yarn build
3434

3535
- name: build ReactNativeXaml.sln
36-
run: msbuild /restore /p:RestorePackagesConfig=true package\windows\ReactNativeXaml.sln /p:configuration=${{ inputs.configuration }} /p:platform=${{ inputs.platform }}
36+
run: msbuild /restore /p:RestoreLockedMode=true /p:RestorePackagesConfig=true package\windows\ReactNativeXaml.sln /p:configuration=${{ inputs.configuration }} /p:platform=${{ inputs.platform }}
3737

3838
- name: Upload build output
39-
uses: actions/upload-artifact@v3
39+
uses: actions/upload-artifact@v4
4040
with:
4141
name: RNX ${{ inputs.configuration }} ${{ inputs.platform }} Build Output
4242
path: package\windows\${{ inputs.platform }}\${{ inputs.configuration }}\ReactNativeXaml\*.*
4343
if-no-files-found: error
44-
45-
- if: ${{ inputs.configuration == 'Release' && inputs.platform == 'x64' }}
46-
name: Validate size (Release x64 only)
47-
shell: powershell
48-
run: |
49-
$size = (gci package\windows\x64\Release\ReactNativeXaml\ReactNativeXaml.dll).Length
50-
$size
51-
if ($size -gt 1.5MB) {
52-
throw "DLL is bigger than 1.5MB"
53-
}

.github/workflows/template-runcodegen.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ jobs:
1818
git config --global core.autocrlf false
1919
git config --global core.filemode false
2020
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
2222

2323
- name: yarn install
2424
run: yarn install
2525

2626
- uses: nuget/setup-nuget@v1
2727

2828
- name: NuGet restore
29-
run: nuget restore package\windows\ReactNativeXaml.sln
29+
run: nuget restore -LockedMode package\windows\ReactNativeXaml.sln
3030

3131
- name: run CodeGen
3232
run: yarn codegen

.github/workflows/template-testcli.yml

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@ on:
1111
required: false
1212
default: 'latest'
1313
type: string
14-
useRnwNuGet:
14+
useRnwWindowsInit:
1515
required: false
1616
default: false
1717
type: boolean
18-
rnVersion:
19-
required: false
20-
default: 'latest'
21-
type: string
2218

2319
jobs:
2420
testcli:
25-
name: New RNW@${{ inputs.rnwVersion }} App from ${{ inputs.useRnwNuGet && 'NuGet' || 'Source' }}
21+
name: New RNW@${{ inputs.rnwVersion }} App
2622
runs-on: ${{ inputs.vmImage }}
2723
steps:
28-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
2925

3026
- name: yarn install
3127
run: yarn install
@@ -37,24 +33,47 @@ jobs:
3733
run: yarn link
3834
working-directory: package
3935

40-
- name: create react-native@${{ inputs.rnVersion }} app
41-
run: npx @react-native-community/cli init testrnx --version ${{ inputs.rnVersion }} --skip-install --install-pods false --verbose --skip-git-init true
36+
- name: determine RN versions
37+
run: |
38+
$rnwVersion = & npm show react-native-windows@${{ inputs.rnwVersion }} version
39+
echo "RNW_VERSION=$rnwVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
40+
$rnVersion = & npm show react-native-windows@$rnwVersion peerDependencies.react-native
41+
echo "RN_VERSION=$rnVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
42+
Write-Host "Using react-native-windows@$rnwVersion with react-native@$rnVersion"
43+
44+
- name: create react-native app
45+
run: |
46+
Write-Host "Using react-native@$Env:RN_VERSION"
47+
npx @react-native-community/cli init testrnx --version $Env:RN_VERSION --skip-install --install-pods false --verbose --skip-git-init true
4248
working-directory: ../
4349

4450
- name: yarn install
4551
run: yarn install
4652
working-directory: ../testrnx
4753

48-
- name: add Windows (RNW via ${{ inputs.useRnwNuGet && 'NuGet' || 'Source' }})
49-
run: npx react-native-windows-init --overwrite ${{ inputs.useRnwNuGet && '--experimentalNuGetDependency true' || '' }}
54+
- name: react-native-windows-init
55+
if: ${{ inputs.useRnwWindowsInit }}
56+
run: |
57+
Write-Host "Using react-native-windows@$Env:RNW_VERSION"
58+
npx --yes react-native-windows-init --overwrite --verbose --version $Env:RNW_VERSION
59+
yarn install
5060
working-directory: ../testrnx
5161

52-
- name: link react-native-xaml
53-
run: yarn link react-native-xaml
62+
- name: react-native init-windows
63+
if: ${{ !inputs.useRnwWindowsInit }}
64+
run: |
65+
Write-Host "Using react-native-windows@$Env:RNW_VERSION"
66+
yarn add react-native-windows@$Env:RNW_VERSION
67+
yarn install
68+
npx @react-native-community/cli@latest init-windows --overwrite --logging
69+
yarn install
5470
working-directory: ../testrnx
5571

5672
- name: add react-native-xaml
57-
run: yarn add react-native-xaml
73+
run: |
74+
yarn add react-native-xaml
75+
yarn link react-native-xaml
76+
yarn install
5877
working-directory: ../testrnx
5978

6079
- name: autolink
@@ -64,7 +83,3 @@ jobs:
6483
- name: build app
6584
run: npx @react-native-community/cli run-windows --no-launch --no-deploy --no-packager --logging
6685
working-directory: ../testrnx
67-
68-
- name: test app
69-
run: yarn test
70-
working-directory: ../testrnx
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Upgrade RNX to target RNW 0.77",
4+
"packageName": "react-native-xaml",
5+
"email": "jthysell@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

example/metro.config.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
1+
const MetroConfig = require('@rnx-kit/metro-config');
22

33
const fs = require('fs');
44
const path = require('path');
5-
const exclusionList = require('metro-config/src/defaults/exclusionList');
65

76
const rnwPath = fs.realpathSync(
87
path.resolve(require.resolve('react-native-windows/package.json'), '..'),
98
);
109

10+
//
11+
1112
/**
1213
* Metro configuration
1314
* https://facebook.github.io/metro/docs/configuration
@@ -16,22 +17,19 @@ const rnwPath = fs.realpathSync(
1617
*/
1718

1819
const config = {
20+
//
1921
resolver: {
20-
blockList: exclusionList([
21-
// This stops "react-native run-windows" from causing the metro server to crash if its already running
22+
blockList: MetroConfig.exclusionList([
23+
// This stops "npx @react-native-community/cli run-windows" from causing the metro server to crash if its already running
2224
new RegExp(
2325
`${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`,
2426
),
25-
// This prevents "react-native run-windows" from hitting: EBUSY: resource busy or locked, open msbuild.ProjectImports.zip or other files produced by msbuild
27+
// This prevents "npx @react-native-community/cli run-windows" from hitting: EBUSY: resource busy or locked, open msbuild.ProjectImports.zip or other files produced by msbuild
2628
new RegExp(`${rnwPath}/build/.*`),
2729
new RegExp(`${rnwPath}/target/.*`),
2830
/.*\.ProjectImports\.zip/,
2931
]),
30-
extraNodeModules: {
31-
'react-native-xaml': fs.realpathSync(
32-
path.dirname(require.resolve('react-native-xaml/package.json')),
33-
),
34-
},
32+
//
3533
},
3634
transformer: {
3735
getTransformOptions: async () => ({
@@ -40,9 +38,8 @@ const config = {
4038
inlineRequires: true,
4139
},
4240
}),
43-
// This fixes the 'missing-asset-registry-path` error (see https://github.com/microsoft/react-native-windows/issues/11437)
44-
assetRegistryPath: 'react-native/Libraries/Image/AssetRegistry',
4541
},
42+
projectRoot: __dirname,
4643
};
4744

48-
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
45+
module.exports = MetroConfig.makeMetroConfig(config);

0 commit comments

Comments
 (0)