Skip to content

Commit

Permalink
build: drop support for legacy browsers (IE11, Safari 10)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ctavan committed Aug 3, 2022
1 parent 16f9c46 commit cb24b7b
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 48 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion README_js.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
56 changes: 52 additions & 4 deletions babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
]
}
}
}
12 changes: 4 additions & 8 deletions src/rng-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
54 changes: 20 additions & 34 deletions wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -66,35 +47,39 @@ 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,
os: 'Windows',
osVersion: '10',
},
browserName: 'Firefox',
browserVersion: '44.0',
browserVersion: '51.0',
},

// Edge
{
'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,
Expand All @@ -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',
},
];

Expand Down

0 comments on commit cb24b7b

Please sign in to comment.