有谁知道为什么使用TS并配置为以ES5生成代码的create-react-app项目无法在IE11上运行,因为“ abab”包中的“ atob”没有被编译为es5兼容代码:

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

[email protected] E:\project
-- [email protected]
  -- [email protected]
    -- [email protected]
      -- [email protected]
        -- [email protected]  deduped
    -- [email protected]
      -- [email protected]
        -- [email protected]
          -- [email protected]
            -- [email protected]  deduped
-- [email protected]
  -- [email protected]
    -- [email protected]
      -- [email protected]  deduped


编辑:

webpack的配置可以在这里找到:https://gist.github.com/JacobPozaic/ed1357efc20b9eb4752eaecbc3340fe4

编辑2:问题不是webpack或atob,它是导致问题的原因,并且该项目的构建在其他地方完全声明了语法错误。

最佳答案

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

10-06 16:07