2

I am working on an React App, and I can not open this app in Safari and IE.

For Safari(10.1.2) : SyntaxError: Unexpected token '...'. Expected a property name.

For IE-11: SCRIPT1028: SCRIPT1028: Expected identifier, string or number

my package.json file is as..

"dependencies": {
    "@babel/core": "^7.0.0",
    "@babel/plugin-proposal-object-rest-spread": "^7.6.2",
    "@storybook/addon-backgrounds": "^3.4.8",
    "@storybook/react": "^4.0.0-alpha.4",
    "@types/d3": "^5.0.0",
    "@types/debug": "^0.0.30",
    "@types/enzyme": "^3.1.9",
    "@types/jest": "^23.1.4",
    "@types/moment-timezone": "^0.5.4",
    "@types/react": "^16.9.11",
    "@types/react-dom": "^16.9.3",
    "@types/react-intl": "^2.3.16",
    "@types/react-mentions": "2.4.0",
    "@types/react-redux": "^7.1.5",
    "@types/react-router": "^5.1.2",
    "@types/react-router-dom": "^5.1.0",
    "@types/react-select": "^1.2.6",
    "@types/react-show-more": "^2.0.1",
    "@types/reactour": "^1.13.1",
    "@types/redux": "^3.6.0",
    "@types/redux-form": "^7.3.1",
    "@types/redux-logger": "^3.0.6",
    "@types/storybook__addon-backgrounds": "^3.2.0",
    "@types/storybook__react": "^3.0.8",
    "@types/styled-components": "^4.1.19",
    "awesome-typescript-loader": "^5.2.0",
    "axios": "^0.18.0",
    "babel-engine-plugin": "^0.3.0",
    "babel-loader": "^7.0.0",
    "babel-register": "^6.26.0",
    "connected-react-router": "^4.4.1",
    "cosed": "^1.1.8",
    "d3": "^5.7.0",
    "date-fns": "^1.29.0",
    "debug": "^3.1.0",
    "duplicate-package-checker-webpack-plugin": "^3.0.0",
    "emoji-mart": "^2.6.1",
    "enzyme": "^3.3.0",
    "enzyme-adapter-react-16": "^1.1.1",
    "gen-tester": "^3.1.2",
    "history": "^4.10.1",
    "html-loader": "^0.5.5",
    "html-webpack-plugin": "^3.1.0",
    "husky": "^0.14.3",
    "immer": "^1.3.1",
    "jest": "^23.3.0",
    "jest-environment-enzyme": "^6.0.2",
    "jest-enzyme": "^6.0.2",
    "jest-styled-components": "^6.0.0",
    "lint-staged": "^7.2.0",
    "moment-timezone": "^0.5.14",
    "prettier": "^1.13.7",
    "prop-types": "^15.7.2",
    "react": "^16.11.0",
    "react-cosed": "^1.0.9",
    "react-dom": "^16.11.0",
    "react-intl": "^2.8.0",
    "react-redux": "^5.1.1",
    "react-router": "^5.1.2",
    "react-router-dom": "^5.1.2",
    "react-select": "^1.2.1",
    "reactour": "^1.15.4",
    "redux": "^4.0.0",
    "redux-cosed": "^1.0.1",
    "redux-form": "^8.2.6",
    "redux-persist": "^5.10.0",
    "redux-thunk": "^2.3.0",
    "styled-components": "^4.4.1",
    "ts-jest": "^23.0.0",
    "tslint": "^5.9.1",
    "tslint-config-prettier": "^1.13.0",
    "tslint-no-circular-imports": "^0.5.0",
    "typescript": "^3.0.1",
    "uglifyjs-webpack-plugin": "^1.2.7",
    "url-loader": "^1.0.1",
    "webpack": "^4.15.1",
    "webpack-cli": "^3.0.8",
    "webpack-dev-server": "^3.1.5",
    "webpack-merge": "^4.1.3"
  },
  "devDependencies": {
    "@types/lodash.debounce": "^4.0.4",
    "firebase-tools": "^6.1.0",
    "lodash.debounce": "^4.0.8"
  }

If some more details needed please let me know.

Please suggest, what do i need to do.... Thanks

My webpack.js file is as....

const path = require('path');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const {
  CheckerPlugin,
  TsConfigPathsPlugin,
} = require('awesome-typescript-loader');
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');

const ROOT = path.resolve(__dirname, '..');

module.exports = {
  module: {
    rules: [
      {
        test: /.tsx?$/,
        use: 'awesome-typescript-loader',
        exclude: /node_modules/,
      },
      {
        test: /.(png|jpg|gif|svg)$/,
        use: [
          {
            loader: 'url-loader',
            options: {
              limit: 25000,
            },
          },
        ],
      },
      {
        test: /.html$/,
        use: 'html-loader',
      },
    ],
  },
  resolve: {
    extensions: ['.tsx', '.ts', '.js'],
    modules: [path.resolve(ROOT, 'shared'), 'node_modules'],
    plugins: [new TsConfigPathsPlugin()],
  },
  plugins: [
    new HtmlWebPackPlugin({
      template: path.join(ROOT, 'shared', 'index.html'),
      filename: './index.html',
    }),
    new CheckerPlugin(),
    new DuplicatePackageCheckerPlugin(),
  ],
};

I think babel-loader will work but can't find any way to use babel-loader.

Please suggest some solution...

Raja Sharma
  • 460
  • 1
  • 7
  • 19
  • 2
    Please provide the full error and the code you are trying to run. We cannot say anything based on this question. – Mathieu Nov 08 '19 at 13:08
  • Mention the version of the browser. Are you working on spread operator? – ravibagul91 Nov 08 '19 at 13:15
  • Safari(10.1.2) and IE-11 – Raja Sharma Nov 08 '19 at 13:20
  • I think spread operator is not supported for both the version of browser. Check [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) – ravibagul91 Nov 08 '19 at 13:41
  • Yeah spread operator is not supported. But my code base is so large it will be very difficult to modify the existing code, So please suggest any package or something else that can help me out. – Raja Sharma Nov 08 '19 at 13:55
  • 1
    Have you followed the steps in [this answer](https://stackoverflow.com/questions/56435589/starter-create-react-app-with-ie11-polyfill-import-still-aborts-in-ie11/56439822#56439822) about how to make react app compatible with IE 11? You could try to follow the steps to support IE 11. – Yu Zhou Nov 11 '19 at 01:59
  • Yeah i tried that one too – Raja Sharma Nov 11 '19 at 09:26
  • But I can't see the `react-app-polyfill` in your `package.json`. Besides, which line of which file dose the error point to? Could you please provide [a minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) so that we can test it on our side and can have a better understanding of the issue? – Yu Zhou Nov 12 '19 at 02:24

1 Answers1

0

By default, the application was rendered in IE7, not only IE IE11/Edge that supports the transpiled build. So I had to mention the meta information to let the browser know that the intended browser is IE11/Edge. So add this in the head section of your index.html.

Now you might get some error in the console that reads:

SCRIPT5009: 'Set' is undefined

Refer below link for error: https://reactjs.org/docs/javascript-environment-requirements.html

For more information, follow the link: https://github.com/facebook/react/issues/8379

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
Aravind
  • 129
  • 1