Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode. #9854

Open
xwang1024 opened this Issue Apr 13, 2019 · 4 comments

Comments

Projects
None yet
5 participants
@xwang1024
Copy link

commented Apr 13, 2019

Bug Report

Current Behavior
An error occurred when I use @babel/polyfill in the iOS 8 Safari.

SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode.

The code that caused the error is in:
node_modules/_@babel_polyfill@7.4.3@@babel/polyfill/lib/index.js

"use strict";

require("./noConflict");

function _global() {
  const data = _interopRequireDefault(require("core-js/library/fn/global")); // this line

  _global = function () {
    return data;
  };

  return data;
}

Input Code
src/index.js

import "@babel/polyfill"

Babel Configuration (.babelrc)

{
  "presets": [
    ["env", {
      "targets": {
        "browsers": ["iOS >= 6.0", "Android >= 4.0"],
      }
    }]
  ]
}

Environment

    "@babel/core": "^7.4.3",
    "@babel/polyfill": "^7.4.3",
    "babel-loader": "^8.0.5",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "webpack": "^3.12.0",
    "webpack-cli": "^3.3.0",
    "webpack-dev-server": "^2.11.5"
  • Node version: v8.11.3
  • OS: macOS 10.14.4
  • How you are using Babel: as a loader

Additional context/Screenshots

image

@babel-bot

This comment has been minimized.

Copy link
Collaborator

commented Apr 13, 2019

Hey @xwang1024! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

commented Apr 13, 2019

Fixed by #9812

@jasper-wan

This comment has been minimized.

Copy link

commented Apr 20, 2019

I have encountered this problem too. Is there any workaround on it?

@patotoma

This comment has been minimized.

Copy link

commented Apr 23, 2019

I used a workaround to manually change this one const into var in the build files before deploying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.