immerjs / immer

Create the next immutable state by mutating the current one
https://immerjs.github.io/immer/
MIT License
27.66k stars 847 forks source link

Immer 6.0.1 with IE 11 #601

Closed Kotauror closed 4 years ago

Kotauror commented 4 years ago

🐛 Bug Report

We've upgraded the Immer version from 5.3.6 to 6.0.1. As a result, the app stopped being visible (it doesn't load) on IE 11, even though we've added enableES5() in the root file. It worked fine before the upgrade.

The error that we can see in the console is:

SCRIPT5022: [Immer] minified error nr 19: ES5. Find the full error at: https://bit.ly/38PiBHb

The root js file:

import 'react-app-polyfill/ie11'; // This must be the first line
import 'react-app-polyfill/stable';
import TagManager from 'react-gtm-module';
import { enableES5 } from 'immer';
import React from 'react';
import ReactDOM from 'react-dom';

import App from './App';

import './index.scss';

if (process.env.REACT_APP_GTM) {
  TagManager.initialize({
    gtmId: process.env.REACT_APP_GTM,
  });
}

enableES5();

ReactDOM.render(<App />, document.getElementById('root'));

Other than this root, we only use immer to import produce in reducers.

Environment

Our package.json

{
  "private": true,
  "license": "UNLICENSED",
  "name": "____",
  "scripts": {
    "start": "react-scripts start",
    "start:devserver": "node ./devServer/index.js",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "test:ci": "react-scripts test --ci --maxWorkers=2 --coverage --reporters=default --reporters=jest-junit",
    "test:coverage": "react-scripts test --coverage --watchAll",
    "eject": "react-scripts eject",
    "lint": "eslint 'src/**/*.{ts,tsx}'",
    "lint:fix": "npm run lint -- --fix",
    "storybook": "start-storybook -p 9009 -s public",
    "build-storybook": "build-storybook -c .storybook -o storybook"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "pre-push": "CI=true react-scripts test --changedSince=master"
    }
  },
  "jest": {
    "collectCoverageFrom": [
      "**/*.{ts,tsx}",
      "!**/*.d.ts",
      "!**/*.stories.tsx",
      "!src/serviceWorker.tsx",
      "!**/__fixtures__/**",
      "!**/node_modules/**",
      "!src/shared/utils/test/**",
      "!src/Order/types/**",
      "!src/Quotes/types/**"
    ]
  },
  "lint-staged": {
    "src/**/*.{ts,tsx}": [
      "npm run lint:fix"
    ]
  },
  "proxy": "http://localhost:4000",
  "engines": {
    "node": "^12.13.0",
    "npm": ">=6.12.0"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "ie 11",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "dependencies": {
    "@callstack/async-storage": "^2.0.3",
    "amazon-cognito-identity-js": "^3.2.5",
    "axios": "^0.19.2",
    "babel-polyfill": "^6.26.0",
    "bootstrap": "^4.4.1",
    "classnames": "^2.2.6",
    "file-saver": "^2.0.2",
    "history": "^4.10.1",
    **"immer": "^6.0.1",**
    "moment": "^2.24.0",
    "moment-timezone": "^0.5.28",
    "postcode": "^2.0.0",
    "rc-progress": "^2.5.2",
    "react": "^16.13.0",
    "react-app-polyfill": "^1.0.6",
    "react-datepicker": "^2.15.0",
    "react-dom": "^16.13.0",
    "react-gtm-module": "^2.0.8",
    "react-redux": "^7.2.0",
    "react-router": "^5.1.2",
    "react-router-dom": "^5.1.2",
    "react-select": "^3.1.0",
    "react-slick": "^0.25.2",
    "react-table": "^7.0.0-rc.15",
    "react-tooltip": "^4.1.2",
    "redux": "^4.0.5",
    "redux-devtools-extension": "^2.13.8",
    "redux-saga": "^1.1.3",
    "styled-components": "^5.0.1"
  },
  "devDependencies": {
    "@sambego/storybook-state": "^2.0.1",
    "@storybook/addon-actions": "^5.3.14",
    "@storybook/addon-knobs": "^5.3.14",
    "@storybook/addon-links": "^5.3.14",
    "@storybook/addons": "^5.3.14",
    "@storybook/preset-create-react-app": "^2.0.0",
    "@storybook/react": "^5.3.14",
    "@testing-library/react": "9.4.0",
    "@types/classnames": "^2.2.10",
    "@types/enzyme": "^3.10.5",
    "@types/enzyme-adapter-react-16": "^1.0.6",
    "@types/file-saver": "^2.0.1",
    "@types/google.analytics": "0.0.40",
    "@types/jest": "^25.1.4",
    "@types/moment-timezone": "^0.5.12",
    "@types/react": "^16.9.23",
    "@types/react-datepicker": "^2.11.0",
    "@types/react-dom": "^16.9.5",
    "@types/react-gtm-module": "^2.0.0",
    "@types/react-redux": "^7.1.7",
    "@types/react-router-dom": "^5.1.2",
    "@types/react-select": "^3.0.10",
    "@types/react-slick": "^0.23.4",
    "@types/react-table": "^7.0.4",
    "@types/react-tooltip": "^3.11.0",
    "@types/storybook-react-router": "^1.0.1",
    "@types/styled-components": "^5.0.1",
    "@typescript-eslint/eslint-plugin": "^2.23.0",
    "@typescript-eslint/parser": "^2.23.0",
    "awesome-typescript-loader": "^5.2.1",
    "enzyme": "^3.11.0",
    "enzyme-adapter-react-16": "^1.15.2",
    "eslint": "^6.8.0",
    "eslint-config-prettier": "^6.10.1",
    "eslint-plugin-prettier": "^3.1.2",
    "eslint-plugin-react": "^7.19.0",
    "eslint-plugin-react-hooks": "^2.5.0",
    "husky": "^4.2.3",
    "jest-junit": "10.0.0",
    "jest-styled-components": "^7.0.0",
    "lint-staged": "^10.0.8",
    "node-sass": "^4.13.1",
    "prettier": "^1.19.1",
    "react-scripts": "3.4.0",
    "redux-saga-test-plan": "^4.0.0-rc.3",
    "storybook-react-router": "^1.0.8",
    "typescript": "^3.8.3",
    "webpack": "4.41.5"
  }
}
mweststrate commented 4 years ago

Please only file bug reports against the latest Immer version

Note that enableES5() should be called before doing any logic, so I'd make sure to do it before initializing that tag manager, and ideally directly after those ie11 polyfills

On Wed, May 20, 2020 at 11:11 AM Justyna Jurkowska (Zygmunt) < notifications@github.com> wrote:

🐛 Bug Report

We've upgraded the Immer version from 5.3.6 to 6.0.1. As a result, the app stopped being visible (it doesn't load) on IE 11, even though we've added enableES5() in the root file. It worked fine before the upgrade.

The error that we can see in the console is:

SCRIPT5022: [Immer] minified error nr 19: ES5. Find the full error at: https://bit.ly/38PiBHb

The root js file:

import 'react-app-polyfill/ie11'; // This must be the first line

import 'react-app-polyfill/stable';

import TagManager from 'react-gtm-module';

import { enableES5 } from 'immer';

import React from 'react';

import ReactDOM from 'react-dom';

import App from './App';

import './index.scss';

if (process.env.REACT_APP_GTM) {

TagManager.initialize({

gtmId: process.env.REACT_APP_GTM,

});

}

enableES5();

ReactDOM.render(, document.getElementById('root'));

Other than this root, we only use immer to import produce in reducers. Environment

Our package.json

{

"private": true,

"license": "UNLICENSED",

"name": "sse",

"scripts": {

"start": "react-scripts start",

"start:devserver": "node ./devServer/index.js",

"build": "react-scripts build",

"test": "react-scripts test",

"test:ci": "react-scripts test --ci --maxWorkers=2 --coverage --reporters=default --reporters=jest-junit",

"test:coverage": "react-scripts test --coverage --watchAll",

"eject": "react-scripts eject",

"lint": "eslint 'src/**/*.{ts,tsx}'",

"lint:fix": "npm run lint -- --fix",

"storybook": "start-storybook -p 9009 -s public",

"build-storybook": "build-storybook -c .storybook -o storybook"

},

"husky": {

"hooks": {

  "pre-commit": "lint-staged",

  "pre-push": "CI=true react-scripts test --changedSince=master"

}

},

"jest": {

"collectCoverageFrom": [

  "**/*.{ts,tsx}",

  "!**/*.d.ts",

  "!**/*.stories.tsx",

  "!src/serviceWorker.tsx",

  "!**/__fixtures__/**",

  "!**/node_modules/**",

  "!src/shared/utils/test/**",

  "!src/Order/types/**",

  "!src/Quotes/types/**"

]

},

"lint-staged": {

"src/**/*.{ts,tsx}": [

  "npm run lint:fix"

]

},

"proxy": "http://localhost:4000",

"engines": {

"node": "^12.13.0",

"npm": ">=6.12.0"

},

"browserslist": {

"production": [

  ">0.2%",

  "not dead",

  "ie 11",

  "not op_mini all"

],

"development": [

  "last 1 chrome version",

  "last 1 firefox version",

  "last 1 safari version"

]

},

"dependencies": {

"@callstack/async-storage": "^2.0.3",

"amazon-cognito-identity-js": "^3.2.5",

"axios": "^0.19.2",

"babel-polyfill": "^6.26.0",

"bootstrap": "^4.4.1",

"classnames": "^2.2.6",

"file-saver": "^2.0.2",

"history": "^4.10.1",

**"immer": "^6.0.1",**

"moment": "^2.24.0",

"moment-timezone": "^0.5.28",

"postcode": "^2.0.0",

"rc-progress": "^2.5.2",

"react": "^16.13.0",

"react-app-polyfill": "^1.0.6",

"react-datepicker": "^2.15.0",

"react-dom": "^16.13.0",

"react-gtm-module": "^2.0.8",

"react-redux": "^7.2.0",

"react-router": "^5.1.2",

"react-router-dom": "^5.1.2",

"react-select": "^3.1.0",

"react-slick": "^0.25.2",

"react-table": "^7.0.0-rc.15",

"react-tooltip": "^4.1.2",

"redux": "^4.0.5",

"redux-devtools-extension": "^2.13.8",

"redux-saga": "^1.1.3",

"styled-components": "^5.0.1"

},

"devDependencies": {

"@sambego/storybook-state": "^2.0.1",

"@storybook/addon-actions": "^5.3.14",

"@storybook/addon-knobs": "^5.3.14",

"@storybook/addon-links": "^5.3.14",

"@storybook/addons": "^5.3.14",

"@storybook/preset-create-react-app": "^2.0.0",

"@storybook/react": "^5.3.14",

"@testing-library/react": "9.4.0",

"@types/classnames": "^2.2.10",

"@types/enzyme": "^3.10.5",

"@types/enzyme-adapter-react-16": "^1.0.6",

"@types/file-saver": "^2.0.1",

"@types/google.analytics": "0.0.40",

"@types/jest": "^25.1.4",

"@types/moment-timezone": "^0.5.12",

"@types/react": "^16.9.23",

"@types/react-datepicker": "^2.11.0",

"@types/react-dom": "^16.9.5",

"@types/react-gtm-module": "^2.0.0",

"@types/react-redux": "^7.1.7",

"@types/react-router-dom": "^5.1.2",

"@types/react-select": "^3.0.10",

"@types/react-slick": "^0.23.4",

"@types/react-table": "^7.0.4",

"@types/react-tooltip": "^3.11.0",

"@types/storybook-react-router": "^1.0.1",

"@types/styled-components": "^5.0.1",

"@typescript-eslint/eslint-plugin": "^2.23.0",

"@typescript-eslint/parser": "^2.23.0",

"awesome-typescript-loader": "^5.2.1",

"enzyme": "^3.11.0",

"enzyme-adapter-react-16": "^1.15.2",

"eslint": "^6.8.0",

"eslint-config-prettier": "^6.10.1",

"eslint-plugin-prettier": "^3.1.2",

"eslint-plugin-react": "^7.19.0",

"eslint-plugin-react-hooks": "^2.5.0",

"husky": "^4.2.3",

"jest-junit": "10.0.0",

"jest-styled-components": "^7.0.0",

"lint-staged": "^10.0.8",

"node-sass": "^4.13.1",

"prettier": "^1.19.1",

"react-scripts": "3.4.0",

"redux-saga-test-plan": "^4.0.0-rc.3",

"storybook-react-router": "^1.0.8",

"typescript": "^3.8.3",

"webpack": "4.41.5"

}

}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/immerjs/immer/issues/601, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBCVGTQR6SP3SC4YUUTRSOUF3ANCNFSM4NFZMWPQ .

mweststrate commented 4 years ago

Note that error 19 indicates that you are using a feature (like patches or maps) without enabling it. Please check https://immerjs.github.io/immer/docs/installation for details

Kotauror commented 4 years ago

@mweststrate , thanks for responding! I've tried enableAllPlugins already, with the same result. However, I'll try to combine it with reordering in the file.

Kotauror commented 4 years ago

@mweststrate , I've upgraded immer to 6.0.5., I've also made the changes you've recommended, I'm still seeing the same error.

Anything I should be looking into? Is there anything maybe related to babel that you'd suggest checking?

import 'react-app-polyfill/ie11'; // This must be the first line
import 'react-app-polyfill/stable';
import { enableAllPlugins } from 'immer';
/* eslint-disable import/first */
enableAllPlugins();

import TagManager from 'react-gtm-module';
import React from 'react';
import ReactDOM from 'react-dom';

import App from './App';

import './index.scss';

if (process.env.REACT_APP_GTM) {
  TagManager.initialize({
    gtmId: process.env.REACT_APP_GTM,
  });
}

ReactDOM.render(<App />, document.getElementById('root'));
mweststrate commented 4 years ago

Would you mind retrying with 6.0.6? it should give a clearer error message.

mweststrate commented 4 years ago

Never mind, that won't help with your case. I think you need a reproduction, it looks like immer is still being used before that enable plugins call is made, or you have multiple immers in your project (yarn why immer might help with that). For more help you might need to strip the project and make a minimal thing that can be checked.

Kotauror commented 4 years ago

@mweststrate, thank you for your answer. Indeed, we do have a few dependencies that are using immer(immer@1.10.0).

mweststrate commented 4 years ago

Ok, best analyse the stack traces to see if the throwing immer is the one you enable ES5 for. Not much we can do from this side without small repro. It might be that enableES5 needs to be called by one of the dependencies that you are trying to use, if they are bundling their own version.

On Thu, 21 May 2020, 16:04 Justyna Jurkowska (Zygmunt), < notifications@github.com> wrote:

@mweststrate https://github.com/mweststrate, thank you for your answer. Indeed, we do have a few dependencies that are using immer(immer@1.10.0).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/immerjs/immer/issues/601#issuecomment-632136683, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBCWEBLE272LSWO6UNDRSU7GVANCNFSM4NFZMWPQ .

mweststrate commented 4 years ago

@katiawheeler Please only report issues against the latest version (there has been some IE fixes lately).

If the issue still exists on the latest version, please do provide actionable information. Otherwise just a thumbs up on the issue will do.

mweststrate commented 4 years ago

Closing for now, as without further info this is not actionable

sourcesoft commented 4 years ago

@Kotauror How did you fix it? I have the exact same issue, getting the plugin error in IE11 even though I've installed all plugins. I also have react-dev-utils depending on immer@1.10.0 which is not inlucded in the final bundle actually (it's a @storybook/react dependency)

Kotauror commented 4 years ago

@Kotauror How did you fix it? I have the exact same issue, getting the plugin error in IE11 even though I've installed all plugins. I also have react-dev-utils depending on immer@1.10.0 which is not inlucded in the final bundle actually (it's a @storybook/react dependency)

I'm sorry to disappoint you, but the fix we went with for now was to freeze immer on v. 5.3.6, where it works fine, as solving this got deprioritized. Once it's back on our radar, I'll come back to the issue and hopefully will be able to have a more positive update.

sourcesoft commented 4 years ago

@Kotauror Thanks for the heads up, I actually just fixed it randomly with bunch of different changes. One was that I imported and called enableES5 directly where I used produce. Apparently doing it in the entry Webpack file didn't quite worked (although it used to before). I also did a chore update to all my dependencies and excluded storybook from babel-loader webpack config (so immer@1.10.0 doesn't go through babel).

mweststrate commented 4 years ago

IE 11 should work on the last version. If it doesn't, please report fresh issues with new details on the latest immer version. Otherwise it is unclear if we are dealing with old problems or not. Locking the conversation now, as comments on old issues are inactionable.