build: update to terser 4.4.0 (#33835)

Now that terser_minified supports args as of nodejs rules 0.40.0, ng_rollup_bundle can updated to the pass —comments /a^/ to args can turn off all comments and maintain the current ng_rollup_bundle behavior with the latest version fo terser. //packages/core/test/bundling/todo:bundle.min.js size test passes with this fix.

Tho not strictly necessary to update terser, this will be a rough edge when someone does try it as it is not obvious why the //packages/core/test/bundling/todo:bundle.min.js size test fails. Updating now should save time in the future by not hitting this issue.\

This change also affect ng_package output as the default comments that are preserved by terser are now Comments with @preserve, @license, @cc_on as well as comments starting with /*! and /**! are now preserved by default.. (https://github.com/terser/terser/blob/master/CHANGELOG.md). Example ng_package golden file also updated as there are not some /*! comments preserved that were in older versions of terser.

PR Close #33835
This commit is contained in:
Greg Magolan 2019-11-14 13:08:40 -08:00 committed by Alex Rickabaugh
parent 695bb6ca87
commit 7bf3e70553
5 changed files with 66 additions and 14 deletions

View File

@ -113,7 +113,7 @@
"source-map": "^0.6.1",
"source-map-support": "0.5.9",
"systemjs": "0.18.10",
"terser": "4.3.3",
"terser": "^4.4.0",
"tsickle": "0.37.0",
"tslib": "^1.10.0",
"tslint": "5.7.0",

View File

@ -341,6 +341,20 @@ Hello
* License: MIT
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("example/secondary",["exports","@angular/core"],t):t(((e=e||self).example=e.example||{},e.example.secondary={}),e.ng.core)}(this,(function(e,t){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/**
* @license
* Copyright Google Inc. All Rights Reserved.
@ -613,6 +627,20 @@ e.SecondaryModule=o,e.a=1,Object.defineProperty(e,"__esModule",{value:!0})}));
* License: MIT
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("example",["exports","@angular/core"],t):t((e=e||self).example={},e.ng.core)}(this,(function(e,t){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/**
* @license
* Copyright Google Inc. All Rights Reserved.

View File

@ -329,6 +329,20 @@ License: MIT
* License: MIT
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("example/portal",["exports","@angular/core"],t):t(((e=e||self).example=e.example||{},e.example.portal={}),e.ng.core)}(this,(function(e,t){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/**
* @license
* Copyright Google Inc. All Rights Reserved.

View File

@ -384,6 +384,16 @@ def ng_rollup_bundle(name, **kwargs):
build_optimizer = kwargs.pop("build_optimizer", True)
visibility = kwargs.pop("visibility", None)
# Common arguments for all terser_minified targets
common_terser_args = {
# As of terser 4.3.4 license comments are preserved by default. See
# https://github.com/terser/terser/blob/master/CHANGELOG.md. We want to
# maintain the comments off behavior. We pass the --comments flag with
# a regex that always evaluates to false to do this.
"args": ["--comments", "/bogus_string_to_suppress_all_comments^/"],
"sourcemap": False,
}
# TODO(gregmagolan): reduce this macro to just use the new @bazel/rollup rollup_bundle
# once esm5 inputs are no longer needed. _ng_rollup_bundle is just here for esm5 support
# and once that requirement is removed for Angular 10 then there is nothing that rule is doing
@ -395,9 +405,9 @@ def ng_rollup_bundle(name, **kwargs):
visibility = visibility,
**kwargs
)
terser_minified(name = name + ".min", src = name + "", sourcemap = False, visibility = visibility)
terser_minified(name = name + ".min", src = name + "", visibility = visibility, **common_terser_args)
native.filegroup(name = name + ".min.js", srcs = [name + ".min"], visibility = visibility)
terser_minified(name = name + ".min_debug", src = name + "", sourcemap = False, debug = True, visibility = visibility)
terser_minified(name = name + ".min_debug", src = name + "", debug = True, visibility = visibility, **common_terser_args)
native.filegroup(name = name + ".min_debug.js", srcs = [name + ".min_debug"], visibility = visibility)
npm_package_bin(
name = "_%s_brotli" % name,
@ -418,9 +428,9 @@ def ng_rollup_bundle(name, **kwargs):
visibility = visibility,
**kwargs
)
terser_minified(name = name + ".min.es2015", src = name + "", sourcemap = False, visibility = visibility)
terser_minified(name = name + ".min.es2015", src = name + "", visibility = visibility, **common_terser_args)
native.filegroup(name = name + ".min.es2015.js", srcs = [name + ".min.es2015"], visibility = visibility)
terser_minified(name = name + ".min_debug.es2015", src = name + "", sourcemap = False, debug = True, visibility = visibility)
terser_minified(name = name + ".min_debug.es2015", src = name + "", debug = True, visibility = visibility, **common_terser_args)
native.filegroup(name = name + ".min_debug.es2015.js", srcs = [name + ".min_debug.es2015"], visibility = visibility)
npm_package_bin(
name = "_%s_es2015_brotli" % name,

View File

@ -11149,15 +11149,6 @@ term-size@^1.2.0:
dependencies:
execa "^0.7.0"
terser@4.3.3:
version "4.3.3"
resolved "https://registry.yarnpkg.com/terser/-/terser-4.3.3.tgz#f626c6779cadd60a3018e072fedeceabe4769db1"
integrity sha512-Nzr7dpRjSzMEUS+z2UYQBtzE0LDm5k0Yy8RgLRPy85QUo1TjU5lIOBwzS5/FVAMaVyHZ3WTTU2BuQcMn8KXnNQ==
dependencies:
commander "^2.20.0"
source-map "~0.6.1"
source-map-support "~0.5.12"
terser@^3.14.1:
version "3.17.0"
resolved "https://registry.yarnpkg.com/terser/-/terser-3.17.0.tgz#f88ffbeda0deb5637f9d24b0da66f4e15ab10cb2"
@ -11167,6 +11158,15 @@ terser@^3.14.1:
source-map "~0.6.1"
source-map-support "~0.5.10"
terser@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/terser/-/terser-4.4.0.tgz#22c46b4817cf4c9565434bfe6ad47336af259ac3"
integrity sha512-oDG16n2WKm27JO8h4y/w3iqBGAOSCtq7k8dRmrn4Wf9NouL0b2WpMHGChFGZq4nFAQy1FsNJrVQHfurXOSTmOA==
dependencies:
commander "^2.20.0"
source-map "~0.6.1"
source-map-support "~0.5.12"
test-exclude@^5.2.2:
version "5.2.3"
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.2.3.tgz#c3d3e1e311eb7ee405e092dac10aefd09091eac0"