From cb24b7b0e84884bf1107000730a83d7b1ccaafb3 Mon Sep 17 00:00:00 2001 From: Christoph Tavan Date: Thu, 2 Dec 2021 11:21:09 +0100 Subject: [PATCH] build: drop support for legacy browsers (IE11, Safari 10) BREAKING CHANGE: Drop support for browsers that don't correctly implement const/let and default arguments, and no longer transpile the browser build to ES2015. This also removes the fallback on msCrypto instead of the crypto API. Browser tests are run in the first supported version of each supported browser and in the latest (as of this commit) version available on Browserstack. --- README.md | 6 ++++- README_js.md | 6 ++++- babel.config.json | 56 ++++++++++++++++++++++++++++++++++++++++++---- src/rng-browser.js | 12 ++++------ wdio.conf.js | 54 +++++++++++++++++--------------------------- 5 files changed, 86 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index c8e71f46..d1a7d955 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ For the creation of [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) UUIDs - **Cross-platform** - Support for ... - CommonJS, [ECMAScript Modules](#ecmascript-modules) and [CDN builds](#cdn-builds) - Node 10, 12, 14, 16 - - Chrome, Safari, Firefox, Edge, IE 11 browsers + - Chrome, Safari, Firefox, Edge browsers - Webpack and rollup.js module bundlers - [React Native / Expo](#react-native--expo) - **Secure** - Cryptographically-strong random values @@ -417,6 +417,10 @@ Note: If you are using Expo, you must be using at least `react-native-get-random [In Edge <= 18, Web Crypto is not supported in Web Workers or Service Workers](https://caniuse.com/#feat=cryptography) and we are not aware of a polyfill (let us know if you find one, please). +### IE 11 (Internet Explorer) + +Support for IE11 and other legacy browsers has been dropped as of `uuid@9`. If you need to support legacy browsers, you can always transpile the uuid module source yourself (e.g. using [Babel](https://babeljs.io/)). + ## Upgrading From `uuid@7` ### Only Named Exports Supported When Using with Node.js ESM diff --git a/README_js.md b/README_js.md index 74d05024..8bd0f363 100644 --- a/README_js.md +++ b/README_js.md @@ -25,7 +25,7 @@ For the creation of [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) UUIDs - **Cross-platform** - Support for ... - CommonJS, [ECMAScript Modules](#ecmascript-modules) and [CDN builds](#cdn-builds) - Node 10, 12, 14, 16 - - Chrome, Safari, Firefox, Edge, IE 11 browsers + - Chrome, Safari, Firefox, Edge browsers - Webpack and rollup.js module bundlers - [React Native / Expo](#react-native--expo) - **Secure** - Cryptographically-strong random values @@ -426,6 +426,10 @@ Note: If you are using Expo, you must be using at least `react-native-get-random [In Edge <= 18, Web Crypto is not supported in Web Workers or Service Workers](https://caniuse.com/#feat=cryptography) and we are not aware of a polyfill (let us know if you find one, please). +### IE 11 (Internet Explorer) + +Support for IE11 and other legacy browsers has been dropped as of `uuid@9`. If you need to support legacy browsers, you can always transpile the uuid module source yourself (e.g. using [Babel](https://babeljs.io/)). + ## Upgrading From `uuid@7` ### Only Named Exports Supported When Using with Node.js ESM diff --git a/babel.config.json b/babel.config.json index a15d3dc2..767dd11f 100644 --- a/babel.config.json +++ b/babel.config.json @@ -3,16 +3,64 @@ "plugins": [], "env": { "commonjsNode": { - "presets": [["@babel/preset-env", { "targets": { "node": "10" }, "modules": "commonjs" }]] + "presets": [ + [ + "@babel/preset-env", + { + "targets": { + "node": "10" + }, + "modules": "commonjs" + } + ] + ] }, "esmNode": { - "presets": [["@babel/preset-env", { "targets": { "node": "10" }, "modules": false }]] + "presets": [ + [ + "@babel/preset-env", + { + "targets": { + "node": "10" + }, + "modules": false + } + ] + ] }, "commonjsBrowser": { - "presets": [["@babel/preset-env", { "modules": "commonjs" }]] + "presets": [ + [ + "@babel/preset-env", + { + "targets": { + "chrome": "49", + "edge": "15", + "firefox": "53", + "safari": "11" + }, + "bugfixes": true, + "modules": "commonjs" + } + ] + ] }, "esmBrowser": { - "presets": [["@babel/preset-env", { "modules": false }]] + "presets": [ + [ + "@babel/preset-env", + { + "targets": { + "chrome": "49", + "edge": "15", + "firefox": "53", + "safari": "11" + }, + "bugfixes": true, + "modules": false + } + ] + ] } } } diff --git a/src/rng-browser.js b/src/rng-browser.js index 38ed20ba..9311281a 100644 --- a/src/rng-browser.js +++ b/src/rng-browser.js @@ -9,15 +9,11 @@ const rnds8 = new Uint8Array(16); export default function rng() { // lazy load so that environments that need to polyfill have a chance to do so if (!getRandomValues) { - // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also, - // find the complete implementation of crypto (msCrypto) on IE11. + // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. getRandomValues = - (typeof crypto !== 'undefined' && - crypto.getRandomValues && - crypto.getRandomValues.bind(crypto)) || - (typeof msCrypto !== 'undefined' && - typeof msCrypto.getRandomValues === 'function' && - msCrypto.getRandomValues.bind(msCrypto)); + typeof crypto !== 'undefined' && + crypto.getRandomValues && + crypto.getRandomValues.bind(crypto); if (!getRandomValues) { throw new Error( 'crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported' diff --git a/wdio.conf.js b/wdio.conf.js index ba65b528..b1ea4628 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -14,45 +14,26 @@ const commonCapabilities = { }; const capabilities = [ - // IE - { - 'bstack:options': { - os: 'Windows', - osVersion: '10', - ...commonCapabilities, - }, - browserName: 'IE', - browserVersion: '11.0', - }, - { - 'bstack:options': { - ...commonCapabilities, - os: 'Windows', - osVersion: '7', - }, - browserName: 'IE', - browserVersion: '11.0', - }, - // Chrome - // Chrome 92 introduced native support for crypto.randomUUID + // Latest { 'bstack:options': { ...commonCapabilities, os: 'Windows', - osVersion: '10', + osVersion: '11', }, browserName: 'Chrome', - browserVersion: '92.0', + browserVersion: '103.0', }, + // Chrome 92 introduced native support for crypto.randomUUID { 'bstack:options': { ...commonCapabilities, os: 'Windows', - osVersion: '10', + osVersion: '11', }, browserName: 'Chrome', - browserVersion: '81.0', + browserVersion: '92.0', }, // Chrome 49 released on 2016-03-02 was the last version supported on Windows XP, Windows Vista, Mac OS X 10.6, 10.7, and 10.8 { @@ -66,15 +47,17 @@ const capabilities = [ }, // Firefox + // Latest { 'bstack:options': { ...commonCapabilities, os: 'Windows', - osVersion: '10', + osVersion: '11', }, browserName: 'Firefox', - browserVersion: '75.0', + browserVersion: '103.0', }, + // Firefox 51 was the first Firefox to correctly support const/let { 'bstack:options': { ...commonCapabilities, @@ -82,7 +65,7 @@ const capabilities = [ osVersion: '10', }, browserName: 'Firefox', - browserVersion: '44.0', + browserVersion: '51.0', }, // Edge @@ -90,11 +73,13 @@ const capabilities = [ 'bstack:options': { ...commonCapabilities, os: 'Windows', - osVersion: '10', + osVersion: '11', }, browserName: 'Edge', - browserVersion: '81.0', + browserVersion: '103.0', }, + // While Edge 12 already supported const/let, Edge 15 is the earliest Edge available on + // Browserstack { 'bstack:options': { ...commonCapabilities, @@ -110,19 +95,20 @@ const capabilities = [ 'bstack:options': { ...commonCapabilities, os: 'OS X', - osVersion: 'Catalina', + osVersion: 'Monterey', }, browserName: 'Safari', - browserVersion: '13.0', + browserVersion: '15.0', }, + // Safari 11 was the first Safari to correctly support const/let { 'bstack:options': { ...commonCapabilities, os: 'OS X', - osVersion: 'Sierra', + osVersion: 'High Sierra', }, browserName: 'Safari', - browserVersion: '10.0', + browserVersion: '11.0', }, ];