From 62d7cd643d2671d4f67edea4bd22e4dd43882dd2 Mon Sep 17 00:00:00 2001 From: Philipp von Weitershausen Date: Tue, 14 Apr 2015 08:52:40 -0700 Subject: [PATCH] [ReactNative] allow running JS app server for Android from fbobjc --- packager/blacklist.js | 35 ++++++++++++++++++++++------------- packager/packager.js | 8 ++++++-- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/packager/blacklist.js b/packager/blacklist.js index b5ba41852..9bfeda509 100644 --- a/packager/blacklist.js +++ b/packager/blacklist.js @@ -18,26 +18,35 @@ var sharedBlacklist = [ 'node_modules/react-tools/src/event/EventPropagators.js' ]; -var webBlacklist = [ - '.ios.js' -]; - -var iosBlacklist = [ - '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', -]; +var platformBlacklists = { + web: [ + '.ios.js' + ], + 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('|') + ')$' diff --git a/packager/packager.js b/packager/packager.js index b098f0a31..23da3a78c 100644 --- a/packager/packager.js +++ b/packager/packager.js @@ -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()