Permalink
Browse files

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
  • Loading branch information...
fkgozali authored and facebook-github-bot committed Jun 1, 2017
1 parent 220ff23 commit d41c9d94fd8c83e435774d7ea4bb7ff240226786
@@ -47,6 +47,9 @@ function dependencies(argv, config, args, packagerInstance) {
const options = {
platform: args.platform,
entryFile: relativePath,
dev: args.dev,
minify: !args.dev,
generateSourceMaps: !args.dev,
};
const writeToFile = args.output;
@@ -94,6 +97,11 @@ module.exports = {
}, {
command: '--transformer [path]',
description: 'Specify a custom transformer to be used'
}, {
command: '--dev [boolean]',
description: 'If false, skip all dev-only code path',
parse: (val) => val === 'false' ? false : true,
default: true,
}, {
command: '--verbose',
description: 'Enables logging',
@@ -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 = [];
@@ -319,6 +319,8 @@ class Server {
+entryFile: string,
+dev: boolean,
+platform: string,
+minify: boolean,
+generateSourceMaps: boolean,
}): Promise<mixed> {
return Promise.resolve().then(() => {
return this._bundler.getOrderedDependencyPaths(options);
View
@@ -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)

0 comments on commit d41c9d9

Please sign in to comment.