5

I am using the TypeScript flavor of create-react-app:

npx create-react-app my-app --typescript

When I build the app, the bundle still includes post-ES5 code such as Symbol. What am I missing? My tsconfig file:

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react"
  },
  "include": [
    "src"
  ]
}

1 Answer 1

2

I found out that create-react-app has an associated polyfill package called react-app-polyfill, not included in the solution by default.

Setting the target to ES5 is not enough, you also need to get the polyfill package and reference it in the code. For example for IE11 support:

// This must be the first line in src/index.js
import 'react-app-polyfill/ie11';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.