packager: optimize assets' JS

Reviewed By: davidaurelio

Differential Revision: D5010186

fbshipit-source-id: 3c26d8b8792df1dbc24e5200f28f63e017cb0173
This commit is contained in:
Jean Lauliac 2017-05-08 07:44:04 -07:00 committed by Facebook Github Bot
parent 021ff010d8
commit a2e4e54245
3 changed files with 23 additions and 4 deletions

View File

@ -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};

View File

@ -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);

View File

@ -152,6 +152,7 @@ export type TransformedSourceFile =
export type LibraryOptions = {|
dependencies?: Array<string>,
optimize: boolean,
platform?: string,
rebasePath: string => string,
|};