From de70d376ca6db346d81cc73afa58aa33c524e5c7 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Thu, 1 Jun 2017 13:51:58 -0700 Subject: [PATCH] add --dev flag to the packager's dependencies command Summary: The packager dependencies CLI command always operates on --dev=true today. This means any tooling that needs to get the production dependencies (--dev=false) will always get the dev-mode list instead. For instance: ``` if (__DEV__) { require('Foobar'); } ``` Previously, `Foobar.js` will always be listed in the CLI output. With this change, setting `--dev false` option will correctly skip `Foobar.js` in the output. Reviewed By: cpojer Differential Revision: D5163184 fbshipit-source-id: 203221ee5d6ecb7df575442f12f6c4c489bfbd46 --- packages/metro-bundler/src/Bundler/index.js | 6 ++++-- packages/metro-bundler/src/Server/index.js | 2 ++ packages/metro-bundler/src/index.js | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/metro-bundler/src/Bundler/index.js b/packages/metro-bundler/src/Bundler/index.js index b9b1a9c6..a0df0b54 100644 --- a/packages/metro-bundler/src/Bundler/index.js +++ b/packages/metro-bundler/src/Bundler/index.js @@ -596,12 +596,14 @@ class Bundler { return response; } - getOrderedDependencyPaths({entryFile, dev, platform}: { + getOrderedDependencyPaths({entryFile, dev, platform, minify, generateSourceMaps}: { +entryFile: string, +dev: boolean, +platform: string, + +minify: boolean, + +generateSourceMaps: boolean, }) { - return this.getDependencies({entryFile, dev, platform}).then( + return this.getDependencies({entryFile, dev, platform, minify, generateSourceMaps}).then( ({dependencies}) => { const ret = []; const promises = []; diff --git a/packages/metro-bundler/src/Server/index.js b/packages/metro-bundler/src/Server/index.js index 5b1bf2ad..d06153a5 100644 --- a/packages/metro-bundler/src/Server/index.js +++ b/packages/metro-bundler/src/Server/index.js @@ -319,6 +319,8 @@ class Server { +entryFile: string, +dev: boolean, +platform: string, + +minify: boolean, + +generateSourceMaps: boolean, }): Promise { return Promise.resolve().then(() => { return this._bundler.getOrderedDependencyPaths(options); diff --git a/packages/metro-bundler/src/index.js b/packages/metro-bundler/src/index.js index 64ad2aba..8a2c2e0a 100644 --- a/packages/metro-bundler/src/index.js +++ b/packages/metro-bundler/src/index.js @@ -92,6 +92,8 @@ exports.getOrderedDependencyPaths = function(options: Options, depOptions: { +entryFile: string, +dev: boolean, +platform: string, + +minify: boolean, + +generateSourceMaps: boolean, }) { var server = createNonPersistentServer(options); return server.getOrderedDependencyPaths(depOptions)