From 100f04e961664678aa51cf8284326b4a29917507 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 27 Sep 2021 16:34:49 -0400 Subject: [PATCH] [7.x] [kbn/optimizer] mangle variables in optimizer bundles (#112435) and (#113119) (#112498) * [kbn/optimizer] mangle variables in optimizer bundles (#112435) Co-authored-by: spalger * [optimizer] keep classnames to support constructor.name (#113119) Co-authored-by: spalger (cherry picked from commit 6612f2b533615f8a02e20925bf1e26324794ca06) Co-authored-by: Spencer Co-authored-by: spalger --- package.json | 2 +- .../basic_optimization.test.ts.snap | 12 +-- .../src/worker/webpack.config.ts | 3 +- yarn.lock | 80 +++++-------------- 4 files changed, 29 insertions(+), 68 deletions(-) diff --git a/package.json b/package.json index d1d02f8502b42..acb3c0f92306e 100644 --- a/package.json +++ b/package.json @@ -811,7 +811,7 @@ "tar-fs": "^2.1.0", "tempy": "^0.3.0", "terser": "^5.7.1", - "terser-webpack-plugin": "^2.1.2", + "terser-webpack-plugin": "^4.2.3", "tough-cookie": "^4.0.0", "ts-loader": "^7.0.5", "ts-morph": "^9.1.0", diff --git a/packages/kbn-optimizer/src/integration_tests/__snapshots__/basic_optimization.test.ts.snap b/packages/kbn-optimizer/src/integration_tests/__snapshots__/basic_optimization.test.ts.snap index fac8cd809932a..8067ee2ce6c0b 100644 --- a/packages/kbn-optimizer/src/integration_tests/__snapshots__/basic_optimization.test.ts.snap +++ b/packages/kbn-optimizer/src/integration_tests/__snapshots__/basic_optimization.test.ts.snap @@ -156,16 +156,16 @@ OptimizerConfig { } `; -exports[`prepares assets for distribution: bar bundle 1`] = `"!function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}__webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{enumerable:!0,get:getter})},__webpack_require__.r=function(exports){\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(exports,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(exports,\\"__esModule\\",{value:!0})},__webpack_require__.t=function(value,mode){if(1&mode&&(value=__webpack_require__(value)),8&mode)return value;if(4&mode&&\\"object\\"==typeof value&&value&&value.__esModule)return value;var ns=Object.create(null);if(__webpack_require__.r(ns),Object.defineProperty(ns,\\"default\\",{enumerable:!0,value:value}),2&mode&&\\"string\\"!=typeof value)for(var key in value)__webpack_require__.d(ns,key,function(key){return value[key]}.bind(null,key));return ns},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,\\"a\\",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p=\\"\\",__webpack_require__(__webpack_require__.s=3)}([function(module,exports,__webpack_require__){\\"use strict\\";var memo,isOldIE=function(){return void 0===memo&&(memo=Boolean(window&&document&&document.all&&!window.atob)),memo},getTarget=function(){var memo={};return function(target){if(void 0===memo[target]){var styleTarget=document.querySelector(target);if(window.HTMLIFrameElement&&styleTarget instanceof window.HTMLIFrameElement)try{styleTarget=styleTarget.contentDocument.head}catch(e){styleTarget=null}memo[target]=styleTarget}return memo[target]}}(),stylesInDom=[];function getIndexByIdentifier(identifier){for(var result=-1,i=0;i