[ReactNative] allow running JS app server for Android from fbobjc

This commit is contained in:
Philipp von Weitershausen 2015-04-14 08:52:40 -07:00
parent 39da8034dd
commit 241e263e5e
2 changed files with 28 additions and 15 deletions

View File

@ -18,26 +18,35 @@ var sharedBlacklist = [
'node_modules/react-tools/src/event/EventPropagators.js' 'node_modules/react-tools/src/event/EventPropagators.js'
]; ];
var webBlacklist = [ var platformBlacklists = {
'.ios.js' web: [
]; '.ios.js'
],
var iosBlacklist = [ ios: [
'node_modules/react-tools/src/browser/ui/React.js', 'node_modules/react-tools/src/browser/ui/React.js',
'node_modules/react-tools/src/browser/eventPlugins/ResponderEventPlugin.js', 'node_modules/react-tools/src/browser/eventPlugins/ResponderEventPlugin.js',
// 'node_modules/react-tools/src/vendor/core/ExecutionEnvironment.js', // 'node_modules/react-tools/src/vendor/core/ExecutionEnvironment.js',
'.web.js', '.web.js',
'.android.js', '.android.js',
]; ],
android: [
'node_modules/react-tools/src/browser/ui/React.js',
'node_modules/react-tools/src/browser/eventPlugins/ResponderEventPlugin.js',
'node_modules/react-tools/src/browser/ReactTextComponent.js',
// 'node_modules/react-tools/src/vendor/core/ExecutionEnvironment.js',
'.web.js',
'.ios.js',
],
};
function escapeRegExp(str) { function escapeRegExp(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
} }
function blacklist(isWeb, additionalBlacklist) { function blacklist(platform, additionalBlacklist) {
return new RegExp('(' + return new RegExp('(' +
(additionalBlacklist || []).concat(sharedBlacklist) (additionalBlacklist || []).concat(sharedBlacklist)
.concat(isWeb ? webBlacklist : iosBlacklist) .concat(platformBlacklists[platform] || [])
.map(escapeRegExp) .map(escapeRegExp)
.join('|') + .join('|') +
')$' ')$'

View File

@ -42,6 +42,10 @@ var options = parseCommandLine([{
}, { }, {
command: 'assetRoots', command: 'assetRoots',
description: 'specify the root directories of app assets' description: 'specify the root directories of app assets'
}, {
command: 'platform',
default: 'ios',
description: 'Specify the platform-specific blacklist (ios, android, web).'
}, { }, {
command: 'skipflow', command: 'skipflow',
description: 'Disable flow checks' description: 'Disable flow checks'
@ -192,7 +196,7 @@ function statusPageMiddleware(req, res, next) {
function getAppMiddleware(options) { function getAppMiddleware(options) {
return ReactPackager.middleware({ return ReactPackager.middleware({
projectRoots: options.projectRoots, projectRoots: options.projectRoots,
blacklistRE: blacklist(false), blacklistRE: blacklist(options.platform),
cacheVersion: '2', cacheVersion: '2',
transformModulePath: require.resolve('./transformer.js'), transformModulePath: require.resolve('./transformer.js'),
assetRoots: options.assetRoots, assetRoots: options.assetRoots,
@ -200,7 +204,7 @@ function getAppMiddleware(options) {
} }
function runServer( function runServer(
options, /* {[]string projectRoot, bool web} */ options,
readyCallback readyCallback
) { ) {
var app = connect() var app = connect()