Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clearImmediate not polyfilled when setImmediate is polyfilled earlier #30

Closed
waxidiotic opened this issue Mar 23, 2018 · 3 comments
Closed

Comments

@waxidiotic
Copy link

If another script on a page polyfills only setImmediate and not clearImmediate, when this polyfill runs, it only checks for setImmediate and if that exists, it does not polyfill clearImmediate.

// setimmediate attaches itself to the global object
require("setimmediate");
// On some exotic environments, it's not clear which object `setimmeidate` was
// able to install onto.  Search each possibility in the same order as the
// `setimmediate` library.
exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
                       (typeof global !== "undefined" && global.setImmediate) ||
                       (this && this.setImmediate);
exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
                         (typeof global !== "undefined" && global.clearImmediate) ||
(this && this.clearImmediate);

This causes libraries compiled with webpack to not load properly and throw an exception when clearImmediate is undefined.

From jwplayer/jwplayer:

/*!***************************************************!*\
  !*** ./node_modules/setimmediate/setImmediate.js ***!
  \***************************************************/
/*! dynamic exports provided */
/*! all exports used */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports, __webpack_require__) {

/* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
    "use strict";

    if (global.setImmediate) {
        return;
    }
@robwalch
Copy link

@waxidiotic we can close this. I've opened a PR in setImmediate that handles this issue: YuzuJS/setImmediate#71

@jryans
Copy link
Member

jryans commented Mar 23, 2018

Interesting! My first impression is that a fix in setImmediate is the right place for this, and it appears one has now been filed. For now, I'll close this, but please reopen if the situation changes.

@jryans jryans closed this as completed Mar 23, 2018
@robwalch
Copy link

@jryans yep! Thanks. We filed this as we were still stepping through the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants