-
Notifications
You must be signed in to change notification settings - Fork 319
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
Fix polyfills working incorrectly on Edge #2743
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2743 +/- ##
=======================================
Coverage 45.95% 45.95%
=======================================
Files 248 248
Lines 5273 5273
Branches 1222 1222
=======================================
Hits 2423 2423
Misses 2850 2850
Continue to review full report at Codecov.
|
Deployment preview for |
website/src/entry/App.tsx
Outdated
@@ -7,6 +7,11 @@ import { hot } from 'react-hot-loader/root'; | |||
import { BrowserRouter as Router } from 'react-router-dom'; | |||
import { Provider } from 'react-redux'; | |||
import { PersistGate } from 'redux-persist/integration/react'; | |||
import 'core-js/es/promise/finally'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this order correct? I think the polyfill should go as early as possible, since you are importing for side-effect here. Technically from the stacktrace it looks like the error would only manifest on mount, but for safety polyfills should be loaded as early as possible since the other modules can also have side effect / call the polyfilled methods during init
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also another nit - comments usually go above the line they are commenting on, not below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in e28803a!
Also good job sleuthing out this solution! |
Also I think Packtracker has the same issue as the other GitHub apps in that it has issue with PRs from forks, which is rather annoying :( Thanks for manually validating the size issue |
Wow great work @chrisgzf! |
Sorry, one last issue - the polyfill added in the wrong file - App.tsx is not the entry point. It should be |
@ZhangYiJiang fixed in 09ca440! |
Context
Users who use the non-Chromium Edge were reporting that they were seeing a white-screen of death when loading NUSMods, caused by:
Which is caused by:
PersistGate
from one of our deps,redux-persist
usesPromise.prototype.finally
which somehow isn't supported on Edge.But no, the story doesn't end here.
Promise.prototype.finally
actually IS SUPPORTED by Edge. Except that there is some oddity with our polyfill librarycore-js
or with Edge that causes it to fail Promise feature detection, and Promise is entirely polyfilled incorrectly bycore-js
on Edge, causing the native implementation offinally
to be gone.To resolve this, we polyfill
finally
.Implementation
Tried 3 methods
require.resolve('redux-persist/integration/react')
to the list of files transpiled by Babel. This should make a lot of sense, but somehowcore-js
has issues with adding polyfills to deps. ❌useBuiltIns: usage
touseBuiltIns: entry
in Babel's config, so that it adds every single stable polyfill fromcore-js
to every file. Works great, but greatly increases the bundle size (+13 KB), see WIP Promise.prototype.finally polyfill #2741. ✅Tested on Edge 44.17763.1.0 (which is from donkey years ago).
Other Information
Congrats to the 70 people who use Edge! 🥴 🤢 🤮 You can now use NUSMods again!