From e867585c5957997429f2e08d3f7451c434aac43e Mon Sep 17 00:00:00 2001 From: Miki Date: Thu, 3 Aug 2023 12:29:27 -0700 Subject: [PATCH] Update webpack environment targets (#4649) Also: * Bump browserslist * Widen browser support matrix * Update browser typescript target to ES2018 * Bump `autoprefixer` but remove its usage as it spams the logs about it being unnecessary Signed-off-by: Miki --- .browserslistrc | 15 ++-- CHANGELOG.md | 1 + packages/osd-babel-preset/node_preset.js | 2 +- packages/osd-babel-preset/package.json | 4 + packages/osd-babel-preset/webpack_preset.js | 5 ++ packages/osd-optimizer/postcss.config.js | 4 +- .../basic_optimization.test.ts.snap | 2 +- tsconfig.browser.json | 2 +- yarn.lock | 86 +++++++++++++------ 9 files changed, 86 insertions(+), 35 deletions(-) diff --git a/.browserslistrc b/.browserslistrc index 04395b913c9c..968ff45a7552 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -1,9 +1,14 @@ [production] -last 2 Firefox versions -last 2 Chrome versions -last 2 Safari versions -> 0.25% -not ie 11 +Firefox > 0 and last 2 years and > 0.01% +Chrome > 0 and last 2 years and > 0.01% +Safari > 0 and last 2 years and > 0.01% +Edge > 0 and last 1 years and > 0.01% +Opera > 0 and last 2 years and > 0.01% +> 0.2% +not op_mini all +not and_uc < 100 +not android < 100 +not dead [dev] last 1 chrome versions diff --git a/CHANGELOG.md b/CHANGELOG.md index 22675b1c831d..450f027be64e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Removes `minimatch` manual resolution ([#3019](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3019)) - Upgrade `vega-lite` dependency from `4.17.0` to `^5.6.0` ([#3076](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3076)). Backwards-compatible version included in v2.5.0 release. - Bump `js-yaml` from `3.14.0` to `4.1.0` ([#3770](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3770)) +- Update webpack environment targets ([#4649](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4649)) ### 🪛 Refactoring diff --git a/packages/osd-babel-preset/node_preset.js b/packages/osd-babel-preset/node_preset.js index 0acb1e146bdd..43915e239c38 100644 --- a/packages/osd-babel-preset/node_preset.js +++ b/packages/osd-babel-preset/node_preset.js @@ -40,7 +40,7 @@ module.exports = (_, options = {}) => { // `nvm install 8 && node ./src/cli` will run OpenSearch Dashboards // in node version 8 and babel will stop transpiling async/await // because they are supported in the "current" version of node - node: 'current', + node: 14, }, // replaces `import "core-js/stable"` with a list of require statements diff --git a/packages/osd-babel-preset/package.json b/packages/osd-babel-preset/package.json index d24b959c641c..b471529bbda0 100644 --- a/packages/osd-babel-preset/package.json +++ b/packages/osd-babel-preset/package.json @@ -19,7 +19,11 @@ "babel-plugin-add-module-exports": "^1.0.4", "babel-plugin-styled-components": "^2.0.2", "babel-plugin-transform-react-remove-prop-types": "^0.4.24", + "browserslist": "^4.21.10", "react-is": "^16.8.0", "styled-components": "^5.3.9" + }, + "devDependencies": { + "@types/browserslist": "^4.15.0" } } diff --git a/packages/osd-babel-preset/webpack_preset.js b/packages/osd-babel-preset/webpack_preset.js index d1ee5c3cb19a..9d0a75a042c5 100644 --- a/packages/osd-babel-preset/webpack_preset.js +++ b/packages/osd-babel-preset/webpack_preset.js @@ -28,6 +28,10 @@ * under the License. */ +const { resolve } = require('path'); +const browserlist = require('browserslist'); +const targets = browserlist.loadConfig({ path: resolve(__dirname, '../..') }); + module.exports = () => { return { presets: [ @@ -36,6 +40,7 @@ module.exports = () => { { useBuiltIns: 'entry', modules: false, + targets, // Please read the explanation for this // in node_preset.js corejs: '3.2.1', diff --git a/packages/osd-optimizer/postcss.config.js b/packages/osd-optimizer/postcss.config.js index 5b8b2e731989..2b1e3a8694ed 100644 --- a/packages/osd-optimizer/postcss.config.js +++ b/packages/osd-optimizer/postcss.config.js @@ -29,5 +29,7 @@ */ module.exports = { - plugins: [require('autoprefixer')()], + plugins: [ + /*require('autoprefixer')()*/ + ], }; diff --git a/packages/osd-optimizer/src/integration_tests/__snapshots__/basic_optimization.test.ts.snap b/packages/osd-optimizer/src/integration_tests/__snapshots__/basic_optimization.test.ts.snap index a13a8178b6ca..b08793cdae2f 100644 --- a/packages/osd-optimizer/src/integration_tests/__snapshots__/basic_optimization.test.ts.snap +++ b/packages/osd-optimizer/src/integration_tests/__snapshots__/basic_optimization.test.ts.snap @@ -80,4 +80,4 @@ exports[`prepares assets for distribution: bar bundle 1`] = `"(function(modules) exports[`prepares assets for distribution: foo async bundle 1`] = `"(window[\\"foo_bundle_jsonpfunction\\"]=window[\\"foo_bundle_jsonpfunction\\"]||[]).push([[1],{3:function(module,__webpack_exports__,__webpack_require__){\\"use strict\\";__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,\\"foo\\",(function(){return foo}));function foo(){}}}]);"`; -exports[`prepares assets for distribution: foo bundle 1`] = `"(function(modules){function webpackJsonpCallback(data){var chunkIds=data[0];var moreModules=data[1];var moduleId,chunkId,i=0,resolves=[];for(;i