-
Notifications
You must be signed in to change notification settings - Fork 49
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
Transpile ES6 for smoother IE11 support #24
Comments
Hi @jalada (&@DSchau), welcome to the party : )! Thanks for bringing this up, have completely missed it, cause I was thinking I already were using the babel-transpile mechanism from But, fortunately, solving your issue was an easy one - at least it seems that way: Just published |
@timhagn Just checked this, using the 0.2.9 version without |
Thanks @JonathanAndrews for testing it - and am happy it worked : ). |
Will do! And yes indeed; @JonathanAndrews is on my team. Thanks for your help Tim! |
Was happy to help - and thanks to all participants for bringing this up, |
Is this really working? I had to use |
Would you mind to share the type of errors (or warnings) you are receiving so other contributors and I will be able to replicate them (in my place on a VM)? A quick |
Thanks for your response. Here are my steps to reproduce:
IE version: 11.437.17763.0, update 11.0.120 (KB4493435) I don't know how exactly IE 11 is excluded in dev mode there. If I run |
Hi @vhenzl, thanks for your detailed setup, though I already could replicate some grave errors with So I worked through some IE flaws once again (quite a throwback to the browser wars era ; ) and found the following problems running on a VM with nearly the same specs as yours:
For the moment the just published I definitely can replicate your observation with Hope this works for you momentarily anyway (and that some day IE will be a thing of the past ; ). Oh, and don't forget having a look at polyfilling IntersectionObserver like mentioned in the README. Best, EDIT: Added Info on IO & |
Thanks a lot for your work and detailed comment. Unfortunately, The problem with |
No prob, helped soothe an itch I had about |
Hi @vhenzl! I just published |
Yes, |
No problem, you're welcome - should have rather read than only skimmed the babel docs way sooner (and might not only have caused some errors in IE, so thanks for pointing this out ; ). Should you need the |
Just a heads up here that including babel-polyfill spikes the library size a bit here (about tripled). gatsby-background-image@0.5.6 -> 5.5Kb (gzipped) Here's the why of what is happening. We use the So we could go a few ways here:
I'd recommend option #3 here, since the code is about the same and the library size will be fairly minimal. |
Hi @DSchau, thanks a lot for this concise explanation and presenting possible solutions all at once : )! Thanks again, best, Tim. |
Hi @DSchau, followed your guidance and replaced package size minified gzipped
gatsby-background-image@0.5.9 88.88 KB 16.47 KB 5.38 KB (bundlephobia hasn't updated its cache at the time of writing ; ). Thanks and best wishes, Tim. |
Well… It isn't, and never been, about It works right now thanks to const errors = Object.values(errorMap) which ensures what polyfill for // around line 1470 for timhagn/gbitest project:
/***/ "./.cache/error-overlay-handler.js":
/*!*****************************************!*\
!*** ./.cache/error-overlay-handler.js ***!
\*****************************************/
/*! exports provided: clearError, reportError, errorMap */
//...
/* harmony import */ var core_js_modules_es7_object_values__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/es7.object.values */ "./node_modules/core-js/modules/es7.object.values.js");
/* harmony import */ var core_js_modules_es7_object_values__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es7_object_values__WEBPACK_IMPORTED_MODULE_3__); However, if (or better say when) error-overlay-handler.js changes and As I see it, there are three options:
Since 1) would be maintenance hell and 2) unnecessary increases package size for those who target ES6+ only, option 3) is IMO the only reasonable way to go. It also makes sense from the long term view as Gatsby 3 will hopefully support compiling dependencies with |
Actually, my previous comment is valid only for development mode ( |
*miff* That's a bummer : (. |
I think the "burden" of using this (or rather, any) package should fall to the consumer of the package if they have specific browser requirements. Generally - if you can manage it, I'd recommend avoiding using features that require a polyfill (e.g. Object.values, Array.from, for of loops, etc.) because the requirements for a library author are different than that of an application author (e.g. someone writing Gatsby code). In the case of Object.values, a simplified solution (that would probably work here too) would be something like: const values = obj => Object.keys(obj).map(key => obj[key]) It's not an ideal solution, but I'm not sure there's a better solution (again, apart from eventually transpiling node_modules in Gatsby--which we're not really quite ready to do yet!). I strongly encourage you to not bundle the polyfill, as that is imposing a triple-the-size package on all users for <=2.75% of the web. |
As I mentioned yesterday, I was just getting into monorepos & But it seems to work having a symlinked Any thoughts on, comments or even fixes to the monorepo's config and setup would be greatly appreciated : )! |
@vhenzl & @DSchau Now both are published at
Any thoughts are still appreciated! Perhaps @jalada or @JonathanAndrews would want to chime in? |
Adding
gatsby-background-image
to a project causes issues in IE11 because it has ES6-syntax in its JS. Gatsby doesn't transpile third-party libraries (gatsbyjs/gatsby#12399 gatsbyjs/gatsby#3780).You can use gatsby-plugin-compile-es6-packages but this can be error prone if the library also needs polyfills, because Gatsby won't automatically provide those either. It can be pretty challenging to know if a library needs a manual polyfill added.
I added this to my
gatsby-config.js
:And that does seem to have resolved the issue, but I think (and this is definitely personal opinion!) it would be better if the npm package for this library had the code already compiled.
I appreciate there's a wider issue around IE11 and the needed polyfills; so please close this if the automatic integration is being tracked elsewhere, so long as this is part of that :)
The text was updated successfully, but these errors were encountered: