Skip to content

Commit

Permalink
Fix "Invalid calling object" in Edge and ES6 syntax error in IE
Browse files Browse the repository at this point in the history
* Wrap indirect `setImmediate` into function to prevent "Invalid calling object" error in IE/Edge (due to a bug it's an error to call `setImmediate` indirectly).
* Fix `babel-loader` include condition to transpile `rdf-canonize` dependency.
  • Loading branch information
AlexeyMz committed Aug 30, 2019
1 parent 865d757 commit fa4c911
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ie 10
10 changes: 5 additions & 5 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ api.IdentifierIssuer = IdentifierIssuer;
// from https://github.com/caolan/async/blob/master/lib/async.js

// capture the global reference to guard against fakeTimer mocks
const _setImmediate = typeof setImmediate === 'function' && setImmediate;
const _setImmediate = typeof setImmediate === 'function'
// not a direct alias to prevent "Invalid calling object" error in IE and Edge
? fn => setImmediate(fn)
: undefined;

const _delay = _setImmediate ?
// not a direct alias (for IE10 compatibility)
fn => _setImmediate(fn) :
fn => setTimeout(fn, 0);
const _delay = _setImmediate || (fn => setTimeout(fn, 0));

if(typeof process === 'object' && typeof process.nextTick === 'function') {
api.nextTick = process.nextTick;
Expand Down
11 changes: 4 additions & 7 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,10 @@ outputs.forEach(info => {
rules: [
{
test: /\.js$/,
include: [{
// exclude node_modules by default
exclude: /(node_modules)/
}, {
// include rdf-canonize
include: /(node_modules\/rdf-canonize)/
}],
include: [
path.join(__dirname, 'lib'),
path.join(__dirname, 'node_modules', 'rdf-canonize'),
],
use: {
loader: 'babel-loader',
options: {
Expand Down

0 comments on commit fa4c911

Please sign in to comment.