From fa4c91172f4643dd2ca0de9b6fe3dcdbd7fa9486 Mon Sep 17 00:00:00 2001 From: Alexey Morozov Date: Tue, 16 Jul 2019 14:07:07 +0300 Subject: [PATCH] Fix "Invalid calling object" in Edge and ES6 syntax error in IE * 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. --- .browserslistrc | 1 + lib/util.js | 10 +++++----- webpack.config.js | 11 ++++------- 3 files changed, 10 insertions(+), 12 deletions(-) create mode 100644 .browserslistrc diff --git a/.browserslistrc b/.browserslistrc new file mode 100644 index 00000000..7802094f --- /dev/null +++ b/.browserslistrc @@ -0,0 +1 @@ +ie 10 diff --git a/lib/util.js b/lib/util.js index a41e6e7b..52c1f70b 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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; diff --git a/webpack.config.js b/webpack.config.js index da62a315..9dcaf0b8 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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: {