`new Set()` is not supported in old browsers
tiye opened this issue ยท 11 comments
We got reports that diffhtml throw errors in some mobile browsers since Set
is now implemented. I thought it was compiled by Babel?
https://github.com/tbranyen/diffhtml/blob/master/dist/diffhtml.js#L2256
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#Browser_compatibility
Are you including the Babel polyfill?
I would include the polyfill in your app, and I consider it a feature that its not transpiled.
As usual we use diffhtml
from npm and our Babel loader will not compile code inside node_modules/
folder. And it's "include the polyfill in our apps" in our side.
Ah, gotcha. So you need diffHTML to be transpired before distribution. Makes sense to me.
yeah, I want dist/diffhtml.js
and other code in dist/
compiled before pushing to npm
By compiled, do you mean to ES5? I don't think I should add in a polyfill for Set though, because then I'd need to polyfill Promise, and Map. I might be able to publish a diffhtml.legacy.js file that contains the polyfills if you think that'd help?
I think it's more about the CommonJS code we talked about last time. And diffhtml.legacy.js
looks good to me.
Yeah the CommonJS code is published to npm isn't it?
I don't think that the polyfills should be managed in this repo. corejs has all of those covered pretty thoroughly...it'd be adding extra maintenance to this project for pretty much 0 gain for the consumer, I think. Because most folks transpile code, I would expect most people to already be using the polyfill.
My suggestion would be to:
- transpile the source through Babel, and distribute those as the
main
field in package.json - also include the src files in the bundle in case someone wants to transpile the source themselves
- document the polyfills. Include the list of polyfills they need from corejs to run the lib (they can pull just those in from corejs already), or just say that babel's polyfill will have you covered.
- The main field is currently the built UMD file, which I find to be generally more useful than pointing to CJS transpiled files. Although the CJS files are present in the dist directory during npm publish.
- The source is also included since many will want to use ES6 import/exports.
- We'll have to do a quick audit for what polyfills will be necessary. Off the top of my head I can think of:
Promise
,Map
, andSet
, but there may be more likeArray.from
.
Added a note in the README about polyfills here: https://github.com/tbranyen/diffhtml#polyfills