Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows support on v2 master #324

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions examples/mobile/metro.config.windows.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/
const fs = require('fs');
const path = require('path');
const blacklist = require('metro-config/src/defaults/blacklist');

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

module.exports = {
projectRoot: __dirname,
watchFolders: [
path.resolve(__dirname, '../../node_modules'),
path.resolve(__dirname, '../../packages/core/build'),
path.resolve(__dirname, '../../packages/storage-legacy/build'),
],
resolver: {
extraNodeModules: {
// Redirect react-native to react-native-windows
'react-native': rnwPath,
'react-native-windows': rnwPath,
},
// Include the macos platform in addition to the defaults because the fork includes macos, but doesn't declare it
platforms: ['ios', 'android', 'windesktop', 'windows', 'web', 'macos'],
// Since there are multiple copies of react-native, we need to ensure that metro only sees one of them
// This should go in RN 0.61 when haste is removed
blacklistRE: blacklist([
new RegExp(
`${(path.resolve(rnPath) + path.sep).replace(/[/\\]/g, '/')}.*`,
),
new RegExp(
`${(path.resolve(__dirname, '../..', 'node_modules/react-native') + path.sep).replace(/[/\\]/g, '/')}.*`,
),

// This stops "react-native run-windows" from causing the metro server to crash if its already running
new RegExp(
`${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`,
)
]),
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
8 changes: 5 additions & 3 deletions examples/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
"private": true,
"scripts": {
"start": "react-native start",
"start:windows": "react-native start --use-react-native-windows",
"android": "react-native run-android",
"ios": "react-native run-ios",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"jsc-android": "^241213.1.0",
"react": "16.8.6",
"react-native": "0.60.3"
"react": "16.9.0",
"react-native": "0.61.5"
},
"devDependencies": {
"@babel/core": "7.5.4",
Expand All @@ -23,7 +24,8 @@
"eslint": "5.16.0",
"jest": "24.8.0",
"metro-react-native-babel-preset": "0.55.0",
"react-test-renderer": "16.8.6"
"react-test-renderer": "16.9.0",
"react-native-windows": "0.61.0"
},
"jest": {
"preset": "react-native"
Expand Down
26 changes: 26 additions & 0 deletions examples/mobile/react-native.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* This cli config is needed for the coexistance of react-native and other
* out-of-tree implementations such react-native-windows.
* The following issue is tracked by
* https://github.com/react-native-community/discussions-and-proposals/issues/182
*
* The work-around involves having a metro.config.js for each out-of-tree
* platform, i.e. metro.config.js for react-native and
* metro.config.windows.js for react-native-windows.
* This react-native.config.js looks for a --use-react-native-windows
* switch and when present pushes --config=metro.config.windows.js
* and specifies reactNativePath: 'node_modules/react-native-windows'.
* The metro.config.js has to blacklist 'node_modules/react-native-windows',
* and conversely metro.config.windows.js has to blacklist 'node_modules/react-native'.
*/
'use strict';

const windowsSwitch = '--use-react-native-windows';

if (process.argv.includes(windowsSwitch)) {
process.argv = process.argv.filter(arg => arg !== windowsSwitch);
process.argv.push('--config=./metro.config.windows.js');
module.exports = {
reactNativePath: 'node_modules/react-native-windows',
};
}
92 changes: 92 additions & 0 deletions examples/mobile/windows/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
*AppPackages*
*BundleArtifacts*

#OS junk files
[Tt]humbs.db
*.DS_Store

#Visual Studio files
*.[Oo]bj
*.user
*.aps
*.pch
*.vspscc
*.vssscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.[Cc]ache
*.ilk
*.log
*.lib
*.sbr
*.sdf
*.opensdf
*.opendb
*.unsuccessfulbuild
ipch/
[Oo]bj/
[Bb]in
[Dd]ebug*/
[Rr]elease*/
Ankh.NoLoad

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb

#MonoDevelop
*.pidb
*.userprefs

#Tooling
_ReSharper*/
*.resharper
[Tt]est[Rr]esult*
*.sass-cache

#Project files
[Bb]uild/

#Subversion files
.svn

# Office Temp Files
~$*

# vim Temp Files
*~

#NuGet
packages/
*.nupkg

#ncrunch
*ncrunch*
*crunch*.local.xml

# visual studio database projects
*.dbmdl

#Test files
*.testsettings

#Other files
*.DotSettings
.vs/
*project.lock.json

#Files generated by the VS build
**/Generated Files/**

Loading