[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 320605e5af
commit 62d7cd643d
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'
];
var webBlacklist = [
var platformBlacklists = {
web: [
'.ios.js'
];
var iosBlacklist = [
],
ios: [
'node_modules/react-tools/src/browser/ui/React.js',
'node_modules/react-tools/src/browser/eventPlugins/ResponderEventPlugin.js',
// 'node_modules/react-tools/src/vendor/core/ExecutionEnvironment.js',
'.web.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) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
}
function blacklist(isWeb, additionalBlacklist) {
function blacklist(platform, additionalBlacklist) {
return new RegExp('(' +
(additionalBlacklist || []).concat(sharedBlacklist)
.concat(isWeb ? webBlacklist : iosBlacklist)
.concat(platformBlacklists[platform] || [])
.map(escapeRegExp)
.join('|') +
')$'

View File

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