razzle: IE 11: broken with webpackHotDevClient.
There seems to be an issue with Internet Explorer 11, where it breaks on an arrow function in ansi-styles. I think the requirement chain is like this:
ansi-styleschalkreact-dev-utilsrazzle-dev-utils.
This is very similar to #522. It may have once been fixed by #547. There is something of a difference in that those had to do with strip-ansi & ansi-regex… not the same package but AFAIK they’re interrelated with chalk, coloring output from the hot reloading middleware.
No particular steps to reproduce this, just make a new Razzle app and try running it in IE 11.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 15 (1 by maintainers)
I finally have a workaround after looking at this for a couple of days
I had to change the client for WebpackDevServer from react-dev-utils/webpackHotDevClient to the alternative of webpack/hot/dev-server
You have to go to your webpack.config.js file and swap out this line:
isEnvDevelopment && require.resolve('react-dev-utils/webpackHotDevClient'),with this one:
isEnvDevelopment && require.resolve('webpack/hot/dev-server'),My solution of this problem was the following (note that on Windows you need
\delimiters in paths, while on Linux/- it is taken into account in the regex):razzle.config.js:.babelrc:Also there were some additional errors in IE 11 such as:
These were solved by editing the Windows registry as it’s said here https://stackoverflow.com/questions/52549799/securityerror-on-ie11-when-initializing-websocket
Namely I created
to increase the allowed amount of websockets per a page. After that the issue appeared less often (rarely enough to debug without much inconvenience, but when it appears again you need to open another tab and close the current).
You can follow below to resolve your issue: https://create-react-app.dev/docs/supported-browsers-features/#supported-browsers
Update package.json with below browserlist to get it working for IE:
This way you will at-least get it complied your code without
const&arrowfunction, but catch is after that I am stuck with webpackHotDevClient starts breaking & getting no clue in console too.I still don’t get what’s needed to change to make it work for IE 11. Even my whole production bundle now contains
consts and arrow functions. Do I need to find out which modules need transpiling by looking at the minified bundle? That’d suck, is there a more approachable way?I now see the docs about polyfills were updated for v3.
However, I don’t think this resolves the issue. It appears something similar is being tracked in CRA: https://github.com/facebook/create-react-app/issues/5336. That one is related to
Mapbeing undefined, which, would make sense as something fixable w/ a polyfill.All these things about supporting IE 9-11 are about polyfilling though. I don’t think a polyfill can fix an arrow function. The code just isn’t transpiled for older browsers and I don’t see how that can be fixed without updating the dependency itself.
The solution provided by @a1g0rithm is the only one that worked for me after upgrading an older, ejected CRA app from webpack v2 to v4. The webpack.dev.config file contains this message:
Simply uncomment the first two
require.resolves and comment the last one:kinda annoying
This got things working for me:
https://github.com/styleguidist/react-styleguidist/pull/1327#issuecomment-483928457
I think I’m seeing now that create-react-app doesn’t support IE 11 or less anymore by default, but there is an opt-in with a separate package. Maybe this is just a documentation thing? If so I will try to update.