larsgw / citation.js

Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.
https://citation.js.org/
MIT License
222 stars 30 forks source link

Update @babel/polyfill to 7.rc-1 #159

Closed larsgw closed 6 years ago

larsgw commented 6 years ago

This update involves limiting @babel/polyfill quite a lot:

@babel/polyfill will not include proposal polyfills by default

Properly updating involves determining what stage <4 polyfills Citation.js & dependencies are using, and importing those manually.

After updating and creating a bundle, running it on IE8 gives an Out of stack space error which has been linked to a lack of proper polyfills before. In conclusion, updating properly is most likely necessary. If not, I'll have to figure out what is causing this instead.

larsgw commented 6 years ago

Additional testing reveals this isn't actually a problem, but even then I can't test if it does works until the errors are resolved.

Bonus incentive (apart from installing a release candidate, which I don't think I have done on npm before): it removes ~30kb from the bundle size.

larsgw commented 6 years ago

Not sure about the stack error (happens only with the minified file), but IE<9 are hit by iterator.return (https://github.com/babel/babel/issues/1286) anyway, so that won't work anytime soon probably.

larsgw commented 6 years ago

iterator.return should be fixed by babel-plugin-transform-member-expression-literals. There should probably be a separate build for IE. Still not sure about the stack error, debugging is rather difficult in IE9...

larsgw commented 6 years ago

Next: this time { default: ... } (object literals with reserved property names) is the problem which should be fixed by @babel/plugin-transform-property-literals. Just to make sure, I also installed @babel/plugin-transform-reserved-words.

larsgw commented 6 years ago

Success, now we have the stack error in the normal build as well. It seems the ie8 compat mode of uglify-js accounts for things babel doesn't account for. +1! Hopefully getting this error in the normal build eases the debugging.

larsgw commented 6 years ago

IE points to this line:

  } else if ('0'.split(undefined, 0)[LENGTH]) {
    internalSplit = function (separator, limit) {
      return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit);
    };
  }

As if internalSplit is accidentally calling itself for some reason.

larsgw commented 6 years ago

Okay, the problem was in another version (core-js v2), excluding core-js should work: https://github.com/zloirock/core-js/issues/248

Excluding @babel/polyfill would probably not work, as register-runtime still needs a fix.

larsgw commented 6 years ago

Updating to rc.3 works for IE10+, so I guess that's fine.