Commit f17f6901 authored by Robert Knight's avatar Robert Knight

Remove ES 2015 and ES 2016 polyfill sets

All of the browsers we currently support, as specified by the
`browserslist` key in package.json, fully support ES 2015 and ES 2016.

The only exception I'm aware of is that Edge Legacy v17 and v18 do not
support using string regex search/match methods with custom (non-regex)
types via `Symbol.{match, search, replace}`. That's not something we've
ever used AFAIK.
parent 9d89ffc9
...@@ -5,8 +5,6 @@ import { requiredPolyfillSets } from './polyfills'; ...@@ -5,8 +5,6 @@ import { requiredPolyfillSets } from './polyfills';
*/ */
const commonPolyfills = [ const commonPolyfills = [
// ES APIs // ES APIs
'es2015',
'es2016',
'es2017', 'es2017',
'es2018', 'es2018',
......
// ES2015
//
// nb. The imports which add entire classes (Promise, Set etc.) will also add
// all features for later ES years, so this can result in some duplication with
// bundles for later ES years.
import 'core-js/es/promise';
import 'core-js/es/map';
import 'core-js/es/number';
import 'core-js/es/set';
import 'core-js/es/symbol';
import 'core-js/es/array/fill';
import 'core-js/es/array/find';
import 'core-js/es/array/find-index';
import 'core-js/es/array/from';
import 'core-js/es/object/assign';
import 'core-js/es/string/includes';
import 'core-js/es/string/ends-with';
import 'core-js/es/string/starts-with';
import 'core-js/es/array/includes';
...@@ -22,37 +22,6 @@ function hasMethods(obj, ...methods) { ...@@ -22,37 +22,6 @@ function hasMethods(obj, ...methods) {
* if the browser has the functionality natively available. * if the browser has the functionality natively available.
*/ */
const needsPolyfill = { const needsPolyfill = {
es2015: () => {
// Check for new objects in ES2015.
if (
typeof Promise !== 'function' ||
typeof Map !== 'function' ||
typeof Set !== 'function' ||
typeof Symbol !== 'function'
) {
return true;
}
// Check for new methods on existing objects in ES2015.
const objMethods = [
[Array, 'from'],
[Array.prototype, 'fill', 'find', 'findIndex'],
[Object, 'assign'],
[String.prototype, 'startsWith', 'endsWith'],
];
for (let [obj, ...methods] of objMethods) {
if (!hasMethods(obj, ...methods)) {
return true;
}
}
return false;
},
es2016: () => {
return !hasMethods(Array.prototype, 'includes');
},
es2017: () => { es2017: () => {
return !hasMethods(Object, 'entries', 'values'); return !hasMethods(Object, 'entries', 'values');
}, },
......
...@@ -24,14 +24,6 @@ describe('boot/polyfills/index', () => { ...@@ -24,14 +24,6 @@ describe('boot/polyfills/index', () => {
}); });
[ [
{
set: 'es2015',
providesMethod: [Object, 'assign'],
},
{
set: 'es2016',
providesMethod: [Array.prototype, 'includes'],
},
{ {
set: 'es2017', set: 'es2017',
providesMethod: [Object, 'entries'], providesMethod: [Object, 'entries'],
......
...@@ -30,7 +30,7 @@ describe('bootstrap', function () { ...@@ -30,7 +30,7 @@ describe('bootstrap', function () {
function runBoot() { function runBoot() {
const assetNames = [ const assetNames = [
// Polyfills // Polyfills
'scripts/polyfills-es2015.bundle.js', 'scripts/polyfills-es2017.bundle.js',
// Annotation layer // Annotation layer
'scripts/annotator.bundle.js', 'scripts/annotator.bundle.js',
...@@ -110,7 +110,7 @@ describe('bootstrap', function () { ...@@ -110,7 +110,7 @@ describe('bootstrap', function () {
it('loads polyfills if required', () => { it('loads polyfills if required', () => {
fakePolyfills.requiredPolyfillSets.callsFake(sets => fakePolyfills.requiredPolyfillSets.callsFake(sets =>
sets.filter(s => s.match(/es2015/)) sets.filter(s => s.match(/es2017/))
); );
runBoot(); runBoot();
...@@ -120,7 +120,7 @@ describe('bootstrap', function () { ...@@ -120,7 +120,7 @@ describe('bootstrap', function () {
); );
assert.called(fakePolyfills.requiredPolyfillSets); assert.called(fakePolyfills.requiredPolyfillSets);
assert.deepEqual(polyfillsLoaded, [ assert.deepEqual(polyfillsLoaded, [
assetUrl('scripts/polyfills-es2015.bundle.1234.js'), assetUrl('scripts/polyfills-es2017.bundle.1234.js'),
]); ]);
}); });
}); });
...@@ -153,7 +153,7 @@ describe('bootstrap', function () { ...@@ -153,7 +153,7 @@ describe('bootstrap', function () {
it('loads polyfills if required', () => { it('loads polyfills if required', () => {
fakePolyfills.requiredPolyfillSets.callsFake(sets => fakePolyfills.requiredPolyfillSets.callsFake(sets =>
sets.filter(s => s.match(/es2015/)) sets.filter(s => s.match(/es2017/))
); );
runBoot(); runBoot();
...@@ -163,7 +163,7 @@ describe('bootstrap', function () { ...@@ -163,7 +163,7 @@ describe('bootstrap', function () {
); );
assert.called(fakePolyfills.requiredPolyfillSets); assert.called(fakePolyfills.requiredPolyfillSets);
assert.deepEqual(polyfillsLoaded, [ assert.deepEqual(polyfillsLoaded, [
assetUrl('scripts/polyfills-es2015.bundle.1234.js'), assetUrl('scripts/polyfills-es2017.bundle.1234.js'),
]); ]);
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment