From 2cf80d481bec4461e1a0749b0f2717205ac2cc16 Mon Sep 17 00:00:00 2001 From: Amjad Masad Date: Mon, 28 Sep 2015 22:40:56 -0700 Subject: [PATCH] Pass in the platform options when loading dependencies Reviewed By: @jingc Differential Revision: D2488262 --- react-packager/index.js | 4 ++-- react-packager/src/Server/index.js | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/react-packager/index.js b/react-packager/index.js index f399eae0..f42211cb 100644 --- a/react-packager/index.js +++ b/react-packager/index.js @@ -47,9 +47,9 @@ exports.buildBundleFromUrl = function(options, reqUrl) { }); }; -exports.getDependencies = function(options, main) { +exports.getDependencies = function(options, bundleOptions) { var server = createServer(options); - return server.getDependencies(main) + return server.getDependencies(bundleOptions) .then(function(r) { server.end(); return r.dependencies; diff --git a/react-packager/src/Server/index.js b/react-packager/src/Server/index.js index f8113dbb..346f4bcb 100644 --- a/react-packager/src/Server/index.js +++ b/react-packager/src/Server/index.js @@ -96,6 +96,21 @@ const bundleOpts = declareOpts({ } }); +const dependencyOpts = declareOpts({ + platform: { + type: 'string', + required: true, + }, + dev: { + type: 'boolean', + default: true, + }, + entryFile: { + type: 'string', + required: true, + }, +}); + class Server { constructor(options) { const opts = validateOpts(options); @@ -174,8 +189,15 @@ class Server { return this.buildBundle(options); } - getDependencies(main) { - return this._bundler.getDependencies(main); + getDependencies(options) { + return Promise.resolve().then(() => { + const opts = dependencyOpts(options); + return this._bundler.getDependencies( + opts.entryFile, + opts.dev, + opts.platform, + ); + }); } _onFileChange(type, filepath, root) {