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

Promise is not defined when I use babel in android 4.4 #9279

Open
Kerminate opened this Issue Jan 4, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@Kerminate
Copy link

Kerminate commented Jan 4, 2019

Bug Report

In Android 4.4, I use babel6 but I got an error that Promise is not defined.

Input Code

const Promise = new Promise();

Expected behavior/code
Promise should work fine.

Babel Configuration (.babelrc, package.json, cli command)
My package.json is like this:

"dependencies": {
    "babel-runtime": "^6.26.0",
},
  "devDependencies": {
    "babel-core": "^6.4.5",
    "babel-loader": "^6.2.1",
    "babel-plugin-import": "^1.11.0",
    "babel-plugin-transform-runtime": "^6.0.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-es2015": "^6.0.0",
    "babel-preset-stage-0": "^6.5.0"
  },

My .babelrc is like this:

{
    "presets": [
        ["env", {
            "modules": false,
            "targets": {
                "browsers": ["> 1%", "last 2 versions", "Android >= 3.2", "not ie <= 8"]
            },
            "useBuiltIns": true
        }],
        "stage-0"
    ],
    "plugins": [
        "transform-runtime",
        ["import", {
            "libraryName": "vant",
            "libraryDirectory": "es",
            "style": true
        }]
    ],
    "comments": false
}

Environment

  • Babel version(s): [babel6]
  • Node/npm version: [Node 8.12.0/npm 6.4.1]
  • OS: [OSX 10.14.2]
  • Monorepo: [e.g. yes/no/Lerna]
  • How you are using Babel: [loader]

Possible Solution

Additional context/Screenshots

@babel-bot

This comment has been minimized.

Copy link
Collaborator

babel-bot commented Jan 4, 2019

Hey @Kerminate! 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

nicolo-ribaudo commented Jan 7, 2019

It is the expected behavior. That code is roughlty equivalent to this:

const Promise = undefined;
Promise = new Promise();

If you try to run your line of code in any modern browser, you'll get the same error.

Btw, we are not releasing Babel 6 anymore so if you need any new fix you'll need to upgrade to Babel 7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment