question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Babel compiled ES5 doesn't work in IE11

See original GitHub issue

Babel compiled ES5 doesn’t work in IE11

Current Behavior I compiled my ES6 code with babel and Webpack and it doesn’t work in Internet Explorer browser.

Input Code http://iml.ru/new-widget

And I receive such Error in console: Syntax Error on in /js/newPvz-compiled.js line 37

Expected behavior/code

It should work in IE

Babel Configuration (.babelrc, package.json, cli command)

.babelrc

{
  "presets": [
    ["env", {
      "targets": {
        "browsers": ["last 2 versions", "ie >= 11"]
      },
        "useBuiltIns": true
    }],

  ]
}

package.json

{
  "scripts": {
    "minify": "node minify.js"
  },
  "dependencies": {
    "babel-cli": "^6.26.0",
    "babel-preset-es2015": "^6.24.1",
    "less": "^3.0.1",
    "minifier": "0.8.1",
    "vue2-filters": "^0.3.0",
    "watch": "^1.0.2",
    "webpack": "^4.6.0",
    "babel-polyfill": "6.26.0",
    "babel-preset-es2015-ie": "6.7.0"
  },
  "devDependencies": {
    "babel-preset-env": "^1.7.0"
  }
}

cli

$ webpack
$ ./babel-cli/bin/babel.js --presets babel-preset-es2015-ie /js/newPvz-webpack.js  -o /js/newPvz-compiled.js

Environment

  • Babel version(s): babel-1.4.0
  • Node/npm version: v4.2.6
  • OS: Windows 10
  • Monorepo [e.g. yes/no/Lerna]
  • cli

Possible Solution I tried to add babel-preset-es2015 and configure IE as supported browsers in .babelrc

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jinnyMcKindycommented, May 16, 2018

I’m sorry, this problem is not related to Babel. I found the solution. Had to add devtools to webpack.config to remove eval

const path = require('path');
module.exports = {
  devtool: "source-map",
  entry: ['babel-polyfill', path.resolve(__dirname, './yourjs.js')],
  mode: 'production',
  output: {
    path: __dirname+'/draft.iml.ru/static/main/js/',
    filename: 'yout.js'
  }
};

You can close this issue.

0reactions
RinkAttendant6commented, May 21, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with JS output on IE11 using babel - Stack Overflow
The library comes as an es-module compiled for evergreen browsers with the following browserlist config: >1%, not dead, not ie 11, not op_mini ......
Read more >
Support IE 11 Using Babel and Webpack | by Rameez Aijaz
In this article, I will be focusing on converting Typescript code to ES5 using Webpack and Babel 7 configuration. Let's gets started.
Read more >
Why you don't need Babel - LogRocket Blog
Babel is a compiler that converts your modern JavaScript to run in older browsers. It can also perform other jobs such as converting...
Read more >
Solving IE11 Compatibility Problems of Node_Modules ... - petkir
The most common way is to use babel-loader in webpack to solve this issue. In your SPFx solution you have to add additional...
Read more >
Using Babel and Webpack to compile ES7 code to ES5 for IE ...
How was the freelance job? He helped me walk through some adjusting of code to work in IE11. He was polite, knowledgeable, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found