From 4301cfc06656b1cd85e4ae6b93b1d2acf030d9b0 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Tue, 8 Nov 2016 09:58:54 -0800 Subject: [PATCH] improve options parser Reviewed By: jeanlauliac Differential Revision: D4146832 fbshipit-source-id: a54284ccc3fa4d6e1628886b748b21b9b9af2cff --- .../react-packager/src/ModuleGraph/worker.js | 2 +- .../src/ModuleGraph/worker.js.flow | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 packager/react-packager/src/ModuleGraph/worker.js.flow diff --git a/packager/react-packager/src/ModuleGraph/worker.js b/packager/react-packager/src/ModuleGraph/worker.js index 2a15f3b14..7410a9d53 100644 --- a/packager/react-packager/src/ModuleGraph/worker.js +++ b/packager/react-packager/src/ModuleGraph/worker.js @@ -70,7 +70,7 @@ function transformJSON(infile, options, outfile, callback) { } function transformModule(infile, options, outfile, callback) { - const filename = options.filename || infile; + const filename = infile; if (filename.endsWith('.json')) { return transformJSON(infile, options, outfile, callback); } diff --git a/packager/react-packager/src/ModuleGraph/worker.js.flow b/packager/react-packager/src/ModuleGraph/worker.js.flow new file mode 100644 index 000000000..3aeaec819 --- /dev/null +++ b/packager/react-packager/src/ModuleGraph/worker.js.flow @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2016-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow + */ +'use strict'; + +declare export function transformModule( + infile: string, + options: { + filename?: string, + transform: string, + variants?: {[key: string]: Object}, + }, + outfile: string, + callback: (e?: Error) => void, +): void + +declare export function optimizeModule( + infile: string, + outfile: string, + options: { + dev?: boolean, + platform?: string, + }, + callback: (e?: Error) => void, +): void