IE11 syntax error with v3.3.1
Describe the bug
- Development mode throws a syntax error in IE11 on v3.3.1
SCRIPT438: Object doesn't support property or method 'entries'
Did you try recovering your dependencies?
Yes.
›» yarn --version
1.21.1
Environment
›» npx create-react-app --info
Environment Info:
System:
OS: macOS Mojave 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Binaries:
Node: 10.16.3 - /usr/local/bin/node
Yarn: 1.21.1 - ~/Code/makana-platform/nani/node_modules/.bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Browsers:
Chrome: 79.0.3945.130
Firefox: Not Found
Safari: 13.0.5
npmPackages:
react: ^16.12.0 => 16.12.0 (16.8.6, 0.14.9)
react-dom: ^16.9 => 16.12.0 (16.8.6)
react-scripts: 3.3.1 => 3.3.1
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
- Upgraded to CRA v3.3.1
- Startup app in dev mode (
yarn start) - Open site in IE11
Expected behavior
- IE11 should work
Chrome - WORKS
Actual behavior
- IE11 throws
SCRIPT438: Object doesn't support property or method 'entries'inansi-styles - Posted an issue to that repo, was denied: https://github.com/chalk/ansi-styles/issues/57
IE11 - BROKEN
Reproducible demo
- https://github.com/afrankel-sfdo/cra-3.3.1
- clone
- yarn && yarn start
- View site in IE11
›» yarn browserslist --env="development"
chrome 79
firefox 72
ie 11
safari 13
Ah yes it looks like this is a change from 6.0.4 => 6.0.5 of react-error-overlay.
https://unpkg.com/[email protected]/lib/index.js https://unpkg.com/[email protected]/lib/index.js
I think what's happening is there isn't an appropriate browserslist in the react-error-overlay project. The overlay is built before we publish to npm. I would have thought that our babel config that runs over node_modules dependencies in the consuming application would have fixed that up? https://github.com/facebook/create-react-app/blob/3190e4f4a99b8c54acb0993d92fec8a859889a28/packages/react-scripts/config/webpack.config.js#L457-L493
Did you want to try putting in a PR that adds browserslist to packages/react-error-overlay and set it to "ie 11" and see if that fixes it for you?
#8164 could also be related?
I struggled with this today too: ended up in downgrading to 3.2.0. which worked. Changing browserslist did nothing.
There’s a recent issue at babel where polyfills are not applied in dev which is could be the root cause?
+1, also experiencing this.
I really don't mean this sarcastically. Could y'all add "Open in IE 11" to your test plans for CRA? This plus this, both very recently, where it breaks immediately in IE. Both head scratchers until we figure it out/Google and find the issue(s) here.
the same issue on my side with the same CRA version - v3.3.1
as a quick fix -- overriding config to
entry: ['./node_modules/core-js/es/object/entries.js', ...config.entry],
works
so if you use https://github.com/timarney/react-app-rewired the config may look like the following
const path = require('path');
module.exports = {
webpack(config = {}) {
return {
...config,
entry: [path.resolve(__dirname, './node_modules/core-js/es/object/entries.js'), ...config.entry],
};
}
};
I suspect reverting #8164 will fix it for folks - at least in react-error-overlay.
As I mentioned in #8438. The temporary solution could be:
Download: core-js-bundle.js from https://unpkg.com/[email protected]/index.js
In ./public/index.html
<% if (process.env.NODE_ENV === 'development') { %>
<script src="./core-js-bundle.js"></script>
<% } %>
Ugly hack but working so far I've checked
This issue makes one wonder why a module dedicated to terminal colors is sent to browsers in the first place. To my knowledge, chalk does not support the browser console in any way.
add this to your package.json, should fix chalk dev reload issue which is caused on ansi-styles with that 438 error
"resolutions": {
"react-dev-utils/chalk/ansi-styles": "https://github.com/codercodingthecode/ansi-styles"
}