create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

IE11 syntax error with v3.3.1

Open afrankel-sfdo opened this issue 6 years ago • 11 comments

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

  1. Upgraded to CRA v3.3.1
  2. Startup app in dev mode (yarn start)
  3. Open site in IE11

Expected behavior

  • IE11 should work

Chrome - WORKS

Screen Shot 2020-01-31 at 6 48 09 AM

Actual behavior

  • IE11 throws SCRIPT438: Object doesn't support property or method 'entries' in ansi-styles
  • Posted an issue to that repo, was denied: https://github.com/chalk/ansi-styles/issues/57

IE11 - BROKEN

Screen Shot 2020-01-31 at 6 49 32 AM

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

afrankel-sfdo avatar Jan 31 '20 13:01 afrankel-sfdo

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?

ianschmitz avatar Jan 31 '20 17:01 ianschmitz

#8164 could also be related?

ianschmitz avatar Jan 31 '20 17:01 ianschmitz

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?

petetnt avatar Jan 31 '20 20:01 petetnt

+1, also experiencing this.

schm-dt avatar Feb 03 '20 05:02 schm-dt

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.

ambroselittle avatar Feb 03 '20 22:02 ambroselittle

the same issue on my side with the same CRA version - v3.3.1

arolonger avatar Feb 05 '20 11:02 arolonger

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],
        };
    }
};

demns avatar Feb 05 '20 12:02 demns

I suspect reverting #8164 will fix it for folks - at least in react-error-overlay.

ianschmitz avatar Feb 06 '20 18:02 ianschmitz

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

staszekj avatar Feb 06 '20 18:02 staszekj

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.

silverwind avatar Feb 07 '20 15:02 silverwind

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"
}

codercodingthecode avatar Feb 07 '20 17:02 codercodingthecode