diff --git a/packager/src/JSTransformer/worker/JsMinification.js b/packager/src/JSTransformer/worker/JsMinification.js new file mode 100644 index 000000000..580212ebb --- /dev/null +++ b/packager/src/JSTransformer/worker/JsMinification.js @@ -0,0 +1,19 @@ +/** + * 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'; + +const UGLIFY_JS_OUTPUT_OPTIONS = { + ascii_only: true, + screw_ie8: true, +}; + +module.exports = {UGLIFY_JS_OUTPUT_OPTIONS}; diff --git a/packager/src/JSTransformer/worker/minify.js b/packager/src/JSTransformer/worker/minify.js index e92513a69..deceb4cbe 100644 --- a/packager/src/JSTransformer/worker/minify.js +++ b/packager/src/JSTransformer/worker/minify.js @@ -13,15 +13,14 @@ const uglify = require('uglify-js'); +const {UGLIFY_JS_OUTPUT_OPTIONS} = require('./JsMinification'); + function minify(filename: string, code: string, sourceMap: ?string) { const minifyResult = uglify.minify(code, { fromString: true, inSourceMap: sourceMap, outSourceMap: true, - output: { - ascii_only: true, - screw_ie8: true, - }, + output: UGLIFY_JS_OUTPUT_OPTIONS, }); minifyResult.map = JSON.parse(minifyResult.map); diff --git a/packager/src/ModuleGraph/types.flow.js b/packager/src/ModuleGraph/types.flow.js index 4070f27c3..c1c560744 100644 --- a/packager/src/ModuleGraph/types.flow.js +++ b/packager/src/ModuleGraph/types.flow.js @@ -152,6 +152,7 @@ export type TransformedSourceFile = export type LibraryOptions = {| dependencies?: Array, + optimize: boolean, platform?: string, rebasePath: string => string, |};