Skip to content

Commit

Permalink
Use es6-promise for an IE11 Promise polyfill.
Browse files Browse the repository at this point in the history
This ensures that we support environments without a native `Promise` but
still avoid using the manually configured `Ember.RSVP` runloop
integration.
  • Loading branch information
rwjblue committed Dec 4, 2020
1 parent 03983f7 commit 167100c
Show file tree
Hide file tree
Showing 6 changed files with 2,603 additions and 56 deletions.
8 changes: 2 additions & 6 deletions addon-test-support/@ember/test-helpers/-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ const HAS_PROMISE = typeof Promise === 'function';

import RSVP from 'rsvp';
import { run } from '@ember/runloop';
import { Promise as PromisePolyfill } from 'es6-promise';

This comment has been minimized.

Copy link
@izelnakri

izelnakri Jan 6, 2021

Contributor

@rwjblue fyi this line change now causes a 1.1k lines of JS added to test bundles and additional build overhead.

I'm aware its probably intentional, just wanted to give a heads up, I saw somewhere there is an initiative to drop support for ie11 in future, the earlier we do it, better I think 😄

This comment has been minimized.

Copy link
@rwjblue

rwjblue Jan 11, 2021

Author Member

I'm aware its probably intentional

Yep!

I saw somewhere there is an initiative to drop support for ie11 in future, the earlier we do it, better I think 😄

Couldn't agree more!


const _Promise: typeof Promise = HAS_PROMISE
? Promise
: (() => {
// FIXME: this needs to work on IE11
throw new Error('Missing global Promise!');
})();
const _Promise: typeof Promise = HAS_PROMISE ? Promise : (PromisePolyfill as typeof Promise);

export { _Promise as Promise };

Expand Down
3 changes: 0 additions & 3 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@ module.exports = function (defaults) {
type: 'test',
});

app.import('vendor/shims/qunit.js', { type: 'test' });
app.import('vendor/promise-polyfill.js', { type: 'test' });

return app.toTree();
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@
"@ember/test-waiters": "^2.3.1",
"broccoli-debug": "^0.6.5",
"broccoli-funnel": "^3.0.3",
"ember-auto-import": "^1.7.0",
"ember-cli-babel": "^7.22.1",
"ember-cli-htmlbars": "^5.2.0",
"ember-destroyable-polyfill": "^2.0.2"
"ember-destroyable-polyfill": "^2.0.2",
"es6-promise": "^4.2.8"
},
"devDependencies": {
"@ember/optional-features": "^1.3.0",
Expand Down
6 changes: 6 additions & 0 deletions tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import { isSettled, getSettledState } from '@ember/test-helpers';
import { run } from '@ember/runloop';
import './helpers/resolver';

import { polyfill } from 'es6-promise';

if (typeof Promise === 'undefined') {
polyfill();
}

if (QUnit.config.seed) {
QUnit.config.reorder = false;
}
Expand Down
1 change: 0 additions & 1 deletion vendor/promise-polyfill.js

This file was deleted.

Loading

0 comments on commit 167100c

Please sign in to comment.