Skip to content

Commit

Permalink
Added RNW VNext implementation
Browse files Browse the repository at this point in the history
* Updated bundle command
* Added RNW VNext page, issue microsoft#2376
  • Loading branch information
jonthysell committed May 21, 2019
1 parent 5bc0cc1 commit 7111f39
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 2 deletions.
3 changes: 3 additions & 0 deletions apps/PerfCompare/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Don't commit bundles
*ReactAssets*
*Bundle*
2 changes: 1 addition & 1 deletion apps/PerfCompare/PerfCompare/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void Button_Click(object sender, RoutedEventArgs e)
}
else if (sender == rnwcppBtn)
{

rootFrame.Navigate(typeof(ReactNativeVNextPage));
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions apps/PerfCompare/PerfCompare/PerfCompare.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,16 @@
<Compile Include="ReactNativeCurrentPage.xaml.cs">
<DependentUpon>ReactNativeCurrentPage.xaml</DependentUpon>
</Compile>
<Compile Include="ReactNativeVNextPage.xaml.cs">
<DependentUpon>ReactNativeVNextPage.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<None Include="app.json" />
<None Include="bundle.cmd" />
<None Include="PerfCompare_TemporaryKey.pfx" />
<Content Include="images\blueuser.png" />
<Content Include="images\reduser.png" />
Expand All @@ -138,6 +142,9 @@
<Content Include="ReactAssets\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Bundle\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
Expand All @@ -156,6 +163,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ReactNativeVNextPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
Expand Down
17 changes: 17 additions & 0 deletions apps/PerfCompare/PerfCompare/ReactNativeVNextPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Page
x:Class="PerfCompare.ReactNativeVNextPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PerfCompare"
xmlns:rn="using:react.uwp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
Loaded="Page_Loaded">

<Grid>
<rn:ReactControl x:Name="RootElement" />
</Grid>

</Page>
51 changes: 51 additions & 0 deletions apps/PerfCompare/PerfCompare/ReactNativeVNextPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

using react.uwp;

namespace PerfCompare
{
public sealed partial class ReactNativeVNextPage : Page
{
private IInstance _instance;

const string JSFILENAME = "index.uwp";
const string JSCOMPONENTNAME = "PerfCompareRN";

public ReactNativeVNextPage()
{
this.InitializeComponent();
LoadReact();
}

private void LoadReact()
{
_instance = Instance.Create(JSFILENAME);

_instance.Start(new InstanceSettings()
{
UseWebDebugger = false,
UseLiveReload = false,
});

RootElement.Instance = _instance;
RootElement.InitialProps = "{}";
RootElement.JsComponentName = JSCOMPONENTNAME;

RootElement.StartRender();
}

private async void Page_Loaded(object sender, RoutedEventArgs e)
{
await Dispatcher.RunIdleAsync((args) =>
{
App.PerfStats.Stop();
App.ShowStats();
});
}
}
}
23 changes: 22 additions & 1 deletion apps/PerfCompare/PerfCompare/bundle.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ setlocal
set AppName=PerfCompareRN

set AppRoot=%~dp0

echo Building index.windows.bundle

set CurrentRoot=%AppRoot%..\..\..\current
set VNextRoot=%AppRoot%..\..\..\current

pushd %CurrentRoot%

Expand All @@ -22,4 +24,23 @@ rmdir /s /q %AppName%

popd

echo Building index.uwp.bundle

set VNextRoot=%AppRoot%..\..\..\vnext

pushd %VNextRoot%

rmdir /s /q %AppName%
mkdir %AppName%

xcopy /q %AppRoot%images\* %AppName%\images\
xcopy /q %AppRoot%app.json %AppName%\
xcopy /q %AppRoot%index.js %AppName%\

call react-native bundle --platform uwp --entry-file %AppName%\index.js --bundle-output %AppRoot%Bundle\index.uwp.bundle --assets-dest %AppRoot%Bundle

rmdir /s /q %AppName%

popd

endlocal

0 comments on commit 7111f39

Please sign in to comment.