T
T
tyoma_koder2021-07-13 21:05:58
Node.js
tyoma_koder, 2021-07-13 21:05:58

How to use Babel polyfills?

I installed babel, it works but not completely, it turned out that to convert closest you need to add a polyfill, I installed it with the command npm install babel-polyfill, but you need webpack to use it, I installed it, launched it, and got errors, what's the problem? I wrote package.json
in the original jsrequire("babel-polyfill");

{
  "name": "",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "element-closest-polyfill": "^1.0.4"
  },
  "devDependencies": {
    "webpack": "^5.44.0",
    "webpack-cli": "^4.7.2"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "webpack"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

babel.config.json
{
  "presets": [
    [
      "@babel/env",
      {
        "targets": {
          "ie": "10",
          "edge": "12",
          "firefox": "28",
          "chrome": "29",
          "opera": "12.1",
          "safari": "6.1",
          "android": "4.4"
        },
        "useBuiltIns": "usage",
        "corejs": "3.6.5"
      }
    ]
  ]
}

60edd548e79cb193596121.png
60edd54ece83a954277991.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question