Skip to content

Commit

Permalink
Remove compat polyfills
Browse files Browse the repository at this point in the history
  • Loading branch information
twiss committed Feb 9, 2021
1 parent ed9a029 commit 175eac5
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 90 deletions.
8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,10 @@ matrix:
env: BROWSER='"firefox_61"' OPENPGPJSTEST='browserstack'
- node_js: "10"
env: BROWSER='"chrome_68"' OPENPGPJSTEST='browserstack' LIGHTWEIGHT=1
- node_js: "9"
env: BROWSER='"chrome_49"' OPENPGPJSTEST='browserstack' COMPAT=1
- node_js: "10"
env: BROWSER='"chrome_68"' OPENPGPJSTEST='browserstack'
- node_js: "9"
env: BROWSER='"safari_9_1"' OPENPGPJSTEST='browserstack' COMPAT=1
- node_js: "9"
env: BROWSER='"safari_10_1"' OPENPGPJSTEST='browserstack' COMPAT=1
- node_js: "9"
env: BROWSER='"safari_11_1"' OPENPGPJSTEST='browserstack'
- node_js: "9"
env: BROWSER='{"os":"ios", "os_version":"10.3", "device":"iPhone 7 Plus", "real_mobile":true}' OPENPGPJSTEST='browserstack' COMPAT=1
- node_js: "9"
env: BROWSER='{"os":"ios", "os_version":"11.3", "device":"iPhone 8 Plus", "real_mobile":true}' OPENPGPJSTEST='browserstack'
allow_failures:
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ OpenPGP.js [![Build Status](https://travis-ci.org/openpgpjs/openpgpjs.svg?branch

* The `dist/openpgp.min.js` bundle works well with recent versions of Chrome, Firefox, Safari and Edge. It also works in Node.js 8+.

* The `dist/compat/openpgp.min.js` bundle also works with Internet Explorer 11 and old versions of Safari. Please note that this bundle overwrites the global `Promise` with a polyfill version even in some cases where it already exists, which may cause issues. It also adds some built-in prototype functions if they don't exist, such as `Array.prototype.includes`.

* If you wish, you could even load one or the other depending on which browser the user is using.

* Currently, Chrome, Safari and Edge have partial implementations of the
[Streams specification](https://streams.spec.whatwg.org/), and Firefox
has a partial implementation behind feature flags. Chrome is the only
Expand Down
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"buffer": "^5.0.8",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"core-js": "^2.5.3",
"elliptic": "github:openpgpjs/elliptic#ab7d8268c60b6abeb175841c578c224ac5b2d279",
"email-addresses": "3.1.0",
"eslint": "^4.17.0",
Expand Down
23 changes: 4 additions & 19 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@ import pkg from './package.json';

const nodeDependencies = Object.keys(pkg.dependencies);

const compat = [
'whatwg-fetch',
'core-js/fn/array/fill',
'core-js/fn/array/find',
'core-js/fn/array/includes',
'core-js/fn/array/from',
'core-js/fn/promise',
'core-js/fn/typed/uint8-array',
'core-js/fn/string/repeat',
'core-js/fn/symbol',
'core-js/fn/object/assign'
];

const banner =
`/*! OpenPGP.js v${pkg.version} - ` +
`${new Date().toISOString().split('T')[0]} - ` +
Expand All @@ -48,7 +35,7 @@ export default [
browser: true
}),
commonjs({
ignore: builtinModules.concat(nodeDependencies).concat(compat)
ignore: builtinModules.concat(nodeDependencies)
}),
replace({
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`,
Expand All @@ -68,9 +55,7 @@ export default [
],
plugins: [
resolve(),
commonjs({
ignore: compat
}),
commonjs(),
replace({
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`,
})
Expand All @@ -89,7 +74,7 @@ export default [
browser: true
}),
commonjs({
ignore: builtinModules.concat(nodeDependencies).concat(compat).concat('elliptic')
ignore: builtinModules.concat(nodeDependencies).concat('elliptic')
}),
replace({
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`,
Expand Down Expand Up @@ -121,7 +106,7 @@ export default [
browser: true
}),
commonjs({
ignore: builtinModules.concat(nodeDependencies).concat(compat).concat(['../..', '../../..'])
ignore: builtinModules.concat(nodeDependencies).concat(['../..', '../../..'])
})
]
}
Expand Down
44 changes: 0 additions & 44 deletions src/polyfills.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,7 @@
/**
* @fileoverview Old browser polyfills
* All are listed as dev dependencies because Node does not need them
* and for browser babel will take care of it
* @module polyfills
*/

if (typeof globalThis !== 'undefined') {
/********************************************************************
* NOTE: This list is duplicated in Gruntfile.js, *
* so that these polyfills are only included in the compat bundle. *
********************************************************************/

try {
if (typeof globalThis.fetch === 'undefined') {
require('whatwg-fetch');
}
if (typeof Array.prototype.fill === 'undefined') {
require('core-js/fn/array/fill');
}
if (typeof Array.prototype.find === 'undefined') {
require('core-js/fn/array/find');
}
if (typeof Array.prototype.includes === 'undefined') {
require('core-js/fn/array/includes');
}
if (typeof Array.from === 'undefined') {
require('core-js/fn/array/from');
}

// No if-statement on Promise because of IE11. Otherwise Promise is undefined in the service worker.
require('core-js/fn/promise');

if (typeof Uint8Array.from === 'undefined') {
require('core-js/fn/typed/uint8-array');
}
if (typeof String.prototype.repeat === 'undefined') {
require('core-js/fn/string/repeat');
}
if (typeof Symbol === 'undefined') {
require('core-js/fn/symbol');
}
if (typeof Object.assign === 'undefined') {
require('core-js/fn/object/assign');
}
} catch (e) {}
}

if (typeof TextEncoder === 'undefined') {
const nodeUtil = require('util') || {};
globalThis.TextEncoder = nodeUtil.TextEncoder;
Expand Down
8 changes: 0 additions & 8 deletions test/unittests.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// Old browser polyfills
if (typeof Symbol === 'undefined') {
require('core-js/fn/symbol');
}
if (typeof Promise === 'undefined') {
require('core-js/fn/promise');
}

(typeof window !== 'undefined' ? window : global).resolves = function(val) {
return new Promise(function(res) { res(val); });
};
Expand Down

0 comments on commit 175eac5

Please sign in to comment.