Skip to content

Instantly share code, notes, and snippets.

@wheresrhys
Last active June 1, 2016 16:44
Show Gist options
  • Select an option

  • Save wheresrhys/41755d490bf640c6a2ba6bd5d90cf63d to your computer and use it in GitHub Desktop.

Select an option

Save wheresrhys/41755d490bf640c6a2ba6bd5d90cf63d to your computer and use it in GitHub Desktop.
  1. At start of n-ui/main.js have
window.ftNextDummySymbol = function (){return {iterator: {}}};

This will mean any typeofs called before polyfill shave loaded don't error. Safe to do as any typeof calls looking for Symbol in our application before polyfills have loaded shodul be made to fail anyway

  1. Create an npm component, which has two files
  • assume-symbol/symbol contains
Object.defineProperty(module.exports, 'default', {
   get: function () {
   	return window.Symbol || window.ftNextDummySymbol
   }
})
  • `assume-symbol/iteratortains
Object.defineProperty(module.exports, 'default', {
   get: function () {
   	return window.Symbol.iterator || window.ftNextDummySymbol.iterator
   }
})

These will always give access to Symbol if available

  1. Add some webpack aliases
  {
    'core-js/library/fn/symbol/iterator': 'assume-symbol/iterator',
    'core-js/library/fn/symbol': 'assume-symbol/symbol'
  }
  1. Unexclude Symbol etc from polyfill.io
  2. Build without polyfills
  3. Fix whatever the hell is up with header!!!! Implement Array[@@iterator], NodeList[@@iterator], String[@@iterator] in polyfill.io
  4. Shazzam!
@wheresrhys
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment