Search code examples
javascripttypescriptinternet-explorerwebpackecmascript-5

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.


Solution

  • This issue has been resolved by removing usages of DOMPurify, which requires JSDOM, which requires the abab package.