Skip to content

Commit

Permalink
Preserve symbols across builds, don't mangle _handle (#2687)
Browse files Browse the repository at this point in the history
* Preserve symbols across builds

* let => const
  • Loading branch information
jeffposnick committed Dec 3, 2020
1 parent 48cb3fd commit e05b105
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions gulp-tasks/build-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ module.exports = {
parallel(
build_node_packages,
build_node_ts_packages,
build_sw_packages,
build_window_packages,
// This needs to be a series, not in parallel, so that there isn't a
// race condition with the terser nameCache.
series(build_sw_packages, build_window_packages),
),
),
};
4 changes: 3 additions & 1 deletion gulp-tasks/build-sw-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ function swBundleSequence() {

return series(
parallel(transpilations),
parallel(builds),
// This needs to be a series, not in parallel, so that there isn't a
// race condition with the terser nameCache.
series(builds),
);
}

Expand Down
4 changes: 3 additions & 1 deletion gulp-tasks/build-window-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ function windowBundleSequence() {

return series(
parallel(transpilations),
parallel(builds),
// This needs to be a series, not in parallel, so that there isn't a
// race condition with the terser nameCache.
series(builds),
);
}

Expand Down
8 changes: 7 additions & 1 deletion gulp-tasks/utils/rollup-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const terserPlugin = require('rollup-plugin-terser').terser;
const constants = require('./constants');
const getVersionsCDNUrl = require('./versioned-cdn-url');

// See https://github.com/GoogleChrome/workbox/issues/1674
const nameCache = {};

module.exports = {
// Every use of rollup should have minification and the replace
// plugin set up and used to ensure as consist set of tests
Expand Down Expand Up @@ -46,6 +49,7 @@ module.exports = {
const minifyBuild = buildType === constants.BUILD_TYPES.prod;
if (minifyBuild) {
const terserOptions = {
nameCache,
module: buildFormat === 'esm' ? true : false,
mangle: {
properties: {
Expand All @@ -54,8 +58,10 @@ module.exports = {
'_obj',
// We need this to be exported correctly.
'_private',
// See https://github.com/GoogleChrome/workbox/issues/2686
'_handle',
],
// mangle > properties > regex will allow uglify-es to minify
// mangle > properties > regex will allow terser to minify
// private variable and names that start with a single underscore
// followed by a letter. This restriction to avoid mangling
// unintentional fields in our or other libraries code.
Expand Down

0 comments on commit e05b105

Please sign in to comment.