Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve symbols across builds, don't mangle _handle #2687

Merged
merged 2 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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