简体   繁体   中英

Create react app not compiling abab module to ES5 compliant code, causing failure on IE11

Does anyone know why a create-react-app project using TS and configured to generate code as ES5 is failing to work on IE11 because "atob" from the 'abab' package is not being compiled to es5 compliant code:

module.exports = {
  atob, // SCRIPT1003: Expected ':'
  btoa
};

tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": ".",
    "outDir": "build/dist",
    "module": "esnext",
    "target": "es5",
    "lib": ["es6", "dom", "esnext.asynciterable" ],
    "sourceMap": true,
    "allowJs": true,
    "jsx": "react",
    "moduleResolution": "node",
    "rootDir": "src",
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": false,
    "removeComments": false,
    "strict": true,
    "alwaysStrict": true,
    "noUnusedParameters": true,
    "allowSyntheticDefaultImports": true,
    "downlevelIteration": true
  },
  "include": [
  "src/**/*"
  ],
  "exclude": [
    "build",
    "node_modules"
  ]
}

> npm ls abab

project@0.1.0 E:\project
-- jest@22.4.2
  -- jest-cli@22.4.4
    -- jest-environment-jsdom@22.4.3
      -- jsdom@11.12.0
        -- abab@2.0.0  deduped
    -- jest-runner@22.4.4
      -- jest-config@22.4.4
        -- jest-environment-jsdom@22.4.3
          -- jsdom@11.12.0
            -- abab@2.0.0  deduped
-- jsdom@12.0.0
  -- abab@2.0.0
    -- data-urls@1.0.1
      -- abab@2.0.0  deduped

EDIT:

webpack configs can be found here: https://gist.github.com/JacobPozaic/ed1357efc20b9eb4752eaecbc3340fe4

EDIT 2: issue is not webpack or atob, it is abab causing the problem, and a build of the project claims a syntax error some where else entirely.

通过删除DOMPurify的用法(该问题需要JSDOM和abab软件包),已解决了该问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM