Search code examples
javascriptecmascript-6babeljsecmascript-5

Babel - how to remove require from javascript


I have Babel installed according documentation and I would like to translate ES6 to ES5. So I have also babel.config.json file which defines presets to run with babel command. Everything works fine but result file uses require() function in the code. This is not supported in browsers. How to remove this stuff and include necessary files to result file? Here is my babel.config.json

{

    "presets": [
        [
            "@babel/env",
            {
                "targets": {
                    "edge": "17",
                    "firefox": "60",
                    "chrome": "67",
                    "safari": "11.1",
                    "ie": "11"
                },
                "useBuiltIns": "usage",
                "corejs": "3.6.4"
            }
        ]
    ]
}

Solution

  • Babel itself isn't a bundler. You may want to use it with a bundler like Webpack or Rollup.js to combine your modules into a small number of optimized runtime files.