polyfill-io-loader icon indicating copy to clipboard operation
polyfill-io-loader copied to clipboard

Cannot use 'in' operator to search for 'Promise' in undefined

Open sarco3t opened this issue 4 years ago • 1 comments

Tracelog:

    at Module../node_modules/polyfill-io-loader/index.js!./?Promise ((index):2)
    at __webpack_require__ (bootstrap:63)
    at Module.<anonymous> (common.js:1)
    at Module../app/javascript/common.js (common.js:39)
    at __webpack_require__ (bootstrap:63)
    at Module.<anonymous> (theexplorista.js:12)
    at Module../app/javascript/packs/theexplorista.js (theexplorista.js:14)
    at __webpack_require__ (bootstrap:63)
    at Object.10 (log.js:59)
    at __webpack_require__ (bootstrap:63)

Usage:

import loadPolyfills from 'polyfill-io-loader!?Promise,NodeList.prototype.forEach,Object.assign';

window.onload = () => {
  loadPolyfills(() => {
    document.querySelectorAll('.vue').forEach((el) => {
      // eslint-disable-next-line no-new
      new Vue({ el });
    });
  });
};```

sarco3t avatar Nov 04 '19 10:11 sarco3t

I managed to fix the issue, by changing this line to folowwing code https://github.com/garygreen/polyfill-io-loader/blob/master/index.js#L31 return '[' + JSON.stringify(o[0]) + ',' + o[1].replace('this', 'window') + ']';

sarco3t avatar Nov 04 '19 11:11 sarco3t