babel / babel

🐠 Babel is a compiler for writing next generation JavaScript.
https://babel.dev
MIT License
42.98k stars 5.59k forks source link

Transform Generator Plugin Fails #6126

Closed wdalrymple closed 6 years ago

wdalrymple commented 6 years ago

EDIT by @hzoo: make sure babel-core is >= 6.26.0, and in general keep the babel deps the same version

Transform Generator Plugin Fails

Input Code

I grab the lastest version of babel:

.... babel-plugin-transform-object-rest-spread@6.26.0 node_modules/babel-plugin-transform-object-rest-spread ├── babel-plugin-syntax-object-rest-spread@6.13.0 └── babel-runtime@6.26.0 (regenerator-runtime@0.11.0, core-js@2.5.0)

babel-preset-es2015@6.6.0 node_modules/babel-preset-es2015 ├── babel-plugin-transform-es2015-block-scoped-functions@6.22.0 (babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-arrow-functions@6.22.0 (babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-typeof-symbol@6.23.0 (babel-runtime@6.26.0) ├── babel-plugin-check-es2015-constants@6.22.0 (babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-literals@6.22.0 (babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-spread@6.22.0 (babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-template-literals@6.22.0 (babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-function-name@6.24.1 (babel-types@6.26.0, babel-helper-function-name@6.24.1, babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-unicode-regex@6.24.1 (regexpu-core@2.0.0, babel-helper-regex@6.26.0, babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-duplicate-keys@6.24.1 (babel-types@6.26.0, babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-object-super@6.24.1 (babel-helper-replace-supers@6.24.1, babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-for-of@6.23.0 (babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-sticky-regex@6.24.1 (babel-helper-regex@6.26.0, babel-types@6.26.0, babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-shorthand-properties@6.24.1 (babel-types@6.26.0, babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-computed-properties@6.24.1 (babel-template@6.26.0, babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-destructuring@6.23.0 (babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-parameters@6.24.1 (babel-helper-get-function-arity@6.24.1, babel-helper-call-delegate@6.24.1, babel-types@6.26.0, babel-template@6.26.0, babel-traverse@6.26.0, babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-modules-commonjs@6.26.0 (babel-plugin-transform-strict-mode@6.24.1, babel-types@6.26.0, babel-template@6.26.0, babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-block-scoping@6.26.0 (babel-types@6.26.0, babel-template@6.26.0, babel-traverse@6.26.0, babel-runtime@6.26.0) ├── babel-plugin-transform-es2015-classes@6.24.1 (babel-helper-optimise-call-expression@6.24.1, babel-messages@6.23.0, babel-helper-replace-supers@6.24.1, babel-helper-define-map@6.26.0, babel-helper-function-name@6.24.1, babel-types@6.26.0, babel-template@6.26.0, babel-traverse@6.26.0, babel-runtime@6.26.0) └── babel-plugin-transform-regenerator@6.26.0 (regenerator-transform@0.10.0)

babel-core@6.7.7 node_modules/babel-core ├── slash@1.0.0 ├── shebang-regex@1.0.0 ├── path-exists@1.0.0 ├── path-is-absolute@1.0.1 ├── private@0.1.7 ├── convert-source-map@1.5.0 ├── babel-code-frame@6.26.0 (js-tokens@3.0.2, esutils@2.0.2) ├── debug@2.6.8 (ms@2.0.0) ├── minimatch@2.0.10 (brace-expansion@1.1.8) ├── babylon@6.18.0 ├── json5@0.4.0 ├── source-map@0.5.6 ├── lodash@3.10.1 ├── babel-runtime@5.8.38 (core-js@1.2.7) ├── babel-register@6.26.0 (home-or-tmp@2.0.0, source-map-support@0.4.15, mkdirp@0.5.1, babel-core@6.26.0, babel-runtime@6.26.0, lodash@4.17.4, core-js@2.5.0) ├── babel-messages@6.23.0 (babel-runtime@6.26.0) ├── babel-template@6.26.0 (lodash@4.17.4, babel-runtime@6.26.0) ├── babel-helpers@6.24.1 (babel-runtime@6.26.0) ├── babel-generator@6.26.0 (trim-right@1.0.1, jsesc@1.3.0, detect-indent@4.0.0, lodash@4.17.4, babel-runtime@6.26.0) ├── babel-types@6.26.0 (to-fast-properties@1.0.3, esutils@2.0.2, lodash@4.17.4, babel-runtime@6.26.0) └── babel-traverse@6.26.0 (globals@9.18.0, invariant@2.2.2, lodash@4.17.4, babel-runtime@6.26.0)

When i try and transpile my code: Module build failed: Error: Plugin 20 specified in "/my app folder/node_modules/babel-preset-es2015/index.js" provided an invalid property of "name" at Plugin.init (/my app folder/node_modules/babel-core/lib/transformation/plugin.js:115:13) at Function.normalisePlugin (/my app folder/node_modules/babel-core/lib/transformation/file/options/option-manager.js:149:12) at /my app folder/node_modules/babel-core/lib/transformation/file/options/option-manager.js:183:30 at Array.map (native) at Function.normalisePlugins (/my app folder/node_modules/babel-core/lib/transformation/file/options/option-manager.js:155:20) at OptionManager.mergeOptions (/my app folder/node_modules/babel-core/lib/transformation/file/options/option-manager.js:277:36) at /my app folder/node_modules/babel-core/lib/transformation/file/options/option-manager.js:349:14 at /my app folder/node_modules/babel-core/lib/transformation/file/options/option-manager.js:369:24 at Array.map (native) at OptionManager.resolvePresets (/my app folder/node_modules/babel-core/lib/transformation/file/options/option-manager.js:364:20) at OptionManager.mergePresets (/my app folder/node_modules/babel-core/lib/transformation/file/options/option-manager.js:348:10) at OptionManager.mergeOptions (/my app folder/node_modules/babel-core/lib/transformation/file/options/option-manager.js:307:14) at OptionManager.init (/my app folder/node_modules/babel-core/lib/transformation/file/options/option-manager.js:465:10) at File.initOptions (/my app folder/node_modules/babel-core/lib/transformation/file/index.js:194:75) at new File (/my app folder/node_modules/babel-core/lib/transformation/file/index.js:123:22) at Pipeline.transform (/my app folder/node_modules/babel-core/lib/transformation/pipeline.js:45:16)

I assume that plugin 20 is: babel-plugin-transform-regenerator@6.26.0 (regenerator-transform@0.10.0)

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

    "babel-core": "~6.7.4",
    "babel-loader": "~6.2.4",
    "babel-plugin-resolver": "^1.0.0",
    "babel-plugin-transform-object-rest-spread": "^6.8.0",
    "babel-preset-es2015": "~6.6.0",

Expected Behavior

It shouldn't barf

Current Behavior

Barfs

Context

Can't build

Your Environment

Nothing special. I have a build server where I am getting the latest version of all my dependencies during each run.

software version(s)
Babel babel-core@6.7.7
node v0.10.46
npm 2.12.0
Operating System linux
babel-bot commented 6 years ago

Hey @wdalrymple! 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.

jmrapp1 commented 6 years ago

I ran into this issue as well today and have been scouring the internet trying to find a fix. I've tried everything from re-installing npm & node, re-cloning the repository from the point that it was working, and countless other small things, but nothing has worked.

jgrayauskie commented 6 years ago

Seeing this too.

Fionoble commented 6 years ago

Same issue here.

hzoo commented 6 years ago

Ok thanks for the report but we don't have enough info here. Just the error message but not the babelrc or a minimal reproduction. I can guess what the issue is.. not sure yet

jmrapp1 commented 6 years ago

@hzoo The error happens when I simply do a fresh install of the packages with either yarn or npm. I was able to recreate this on a fresh project as well. Is it possible that one of babel's package dependencies has a carrot (^) and caused it to upgrade to a breaking version?

Babelrc:

{
  "presets": ["es2015", "stage-0"],
  "plugins": ["syntax-class-properties", "add-module-exports", "transform-object-assign"]
}

Package.json:

"dependencies": {
    "babel-preset-es2015": "6.24.1",
    "bootstrap": "3.3.6",
    "classnames": "2.2.1",
    "flux": "2.1.1",
    "font-awesome": "4.7.0",
    "form-serialize": "0.7.0",
    "git-rev": "0.2.1",
    "is-promise": "2.1.0",
    "jquery": "2.1.4",
    "lodash": "4.17.4",
    "lodash.sortbyorder": "3.4.4",
    "moment": "2.17.1",
    "moment-timezone": "0.4.1",
    "node-uuid": "1.4.7",
    "react-datepicker": "0.41.1",
    "react-dom": "15.1.0",
    "react-redux": "4.4.6",
    "react-s-alert": "1.2.0",
    "react-select": "0.9.1",
    "redux": "3.6.0",
    "redux-form": "6.6.2",
    "shelljs": "0.6.0",
    "valid-url": "1.0.9",
    "yargs": "4.3.2"
  },
  "devDependencies": {
    "babel-core": "6.3.21",
    "babel-eslint": "5.0.0",
    "babel-loader": "6.2.0",
    "babel-plugin-add-module-exports": "0.1.2",
    "babel-plugin-syntax-class-properties": "6.5.0",
    "babel-plugin-transform-object-assign": "6.5.0",
    "babel-preset-react": "6.3.13",
    "babel-preset-stage-0": "6.5.0",
    "body-parser": "1.13.2",
    "chai": "3.4.1",
    "chai-dom": "1.4.0",
    "chai-equal-jsx": "1.0.9",
    "colors": "1.1.2",
    "cookie-parser": "1.3.5",
    "css-loader": "0.23.0",
    "debug": "2.2.0",
    "del": "2.2.0",
    "ejs": "2.3.3",
    "enzyme": "2.4.1",
    "eslint": "1.10.3",
    "eslint-config-airbnb": "2.0.0",
    "eslint-plugin-react": "3.11.3",
    "express": "4.13.1",
    "express-request-id": "1.1.0",
    "extract-text-webpack-plugin": "1.0.1",
    "file-loader": "0.8.5",
    "glob": "6.0.1",
    "globule": "0.2.0",
    "gulp": "3.9.0",
    "gulp-babel": "6.1.1",
    "gulp-eslint": "1.1.1",
    "gulp-file": "0.2.0",
    "gulp-istanbul": "1.1.1",
    "gulp-less": "3.0.5",
    "gulp-watch": "4.3.5",
    "json-loader": "0.5.4",
    "karma": "0.13.19",
    "karma-chai": "0.1.0",
    "karma-coverage": "1.1.1",
    "karma-expect": "1.1.1",
    "karma-jsdom-launcher": "1.0.1",
    "karma-junit-reporter": "0.3.8",
    "karma-mocha": "0.2.1",
    "karma-mocha-reporter": "1.1.3",
    "karma-sinon": "1.0.4",
    "karma-sinon-chai": "1.2.0",
    "less": "2.6.0",
    "less-loader": "2.2.2",
    "logs-to-sumologic": "1.0.2",
    "lolex": "1.4.0",
    "mkpath": "1.0.0",
    "mocha": "2.3.4",
    "morgan": "1.6.1",
    "node-branch-manager": "^1.5.4",
    "nodemon": "1.9.2",
    "npm": "3.5.2",
    "raw-loader": "0.5.1",
    "react": "15.1.0",
    "react-addons-pure-render-mixin": "15.1.0",
    "react-addons-test-utils": "15.1.0",
    "react-bootstrap": "0.29.3",
    "react-dom": "15.1.0",
    "react-element-to-jsx-string": "2.1.0",
    "react-router": "2.0.0-rc5",
    "run-sequence": "1.1.5",
    "serve-favicon": "2.3.0",
    "sinon": "1.17.5",
    "sinon-chai": "2.8.0",
    "style-loader": "0.13.0",
    "url-loader": "0.5.7",
    "webpack": "1.12.9",
    "webpack-stream": "3.1.0"
  },
  "peerDependencies": {
    "react": ">= 15.3.0",
    "react-addons-pure-render-mixin": ">= 15.3.0",
    "react-bootstrap": ">= 0.29.3",
    "react-dom": ">= 15.3.0"
  }
wdalrymple commented 6 years ago

Looks like it is https://github.com/babel/babel-preset-env/issues maybe?

It could be this since that is what is loading the plugin '20' that seems to be failing?

babel-preset-es2015@6.6.0 node_modules/babel-preset-es2015

I am kind of guessing here. It sucks though. I saw that there was a PR from 3hrs ago and that is about the time when my builds started to fail....

jmrapp1 commented 6 years ago

My error was putting out "plugin 19", so that may not have anything to do with it. It started to fail on me about 3-3:30 hours ago

kylehood commented 6 years ago

I have a hunch that an incompatibility with an updated dependency. Our project was working fine this morning, and everyone is now experiencing the issue after a fresh npm install. I work with @jmrapp1 so the configuration is the same. We noticed this first about 3-4 hours ago, around noon eastern time.

existentialism commented 6 years ago

@wdalrymple confused... don't think preset-env is being used?

@jmrapp1 can you try babel-core@6.26.0?

hzoo commented 6 years ago

Ok I'm thinking it must be https://github.com/facebook/regenerator/commit/70b1f14896634200b250340ceae54d043688dd0, need to determine why it's failing it because it shouldn't have an issue with name. Either way we can ask @benjamn to do another release

https://github.com/facebook/regenerator/pull/311

whoo backports..

wdalrymple commented 6 years ago

Ahh, that would make sense. Seems to line up with the error that I am seeing.

jmrapp1 commented 6 years ago

@existentialism Change to babel-core@6.26.0 worked. Built successfully. Everyone else try to update to this version of core as well.

hzoo commented 6 years ago

Ok then it sounds like everyone here is actually using an older babel-core verison?

I see in the OP it says babel-core@6.7.7 b/c of "babel-core": "~6.7.4",

It works fine for me locally, not sure why pinning to ~ for babel-core but ^ for plugins.

jmrapp1 commented 6 years ago

Must be the cause, yes.

hzoo commented 6 years ago

aside: if you are using npm 2, Babel is going to be really slow to install and isn't really supported (and node 0.10/0.12 is EOL and will be dropped in Babel 7)

existentialism commented 6 years ago

@jmrapp1 as @hzoo pointed out, transform-regenerator added a name property in preparation for 7.0, but that prop isn't compatible with babel-core <6.14.0

=/

jmrapp1 commented 6 years ago

Ok that explains it. Thanks for the help @existentialism & @hzoo!

wdalrymple commented 6 years ago

sigh thanks. Don't really want to upgrade but I guess i need to.

hzoo commented 6 years ago

Thanks everyone! I would tend to suggest using ^ for deps (or at least be consistent with it's usage), and use a lockfile (yarn/npm package-lock) since it's hard for all libraries/deps to not break

nicolo-ribaudo commented 6 years ago

@wdalrymple You should use the same version for every babel package. So use either always ^version or always ~version in your package.json.

wdalrymple commented 6 years ago

So use the same version of every package in babel? like say: "babel-core": "~6.26.0", "babel-loader": "~6.26.0", "babel-plugin-resolver": "~6.26.0", "babel-plugin-transform-object-rest-spread": "~6.26.0"", "babel-preset-es2015": "~6.26.0"",

syrnick commented 6 years ago

re npm2, node 4 ships with 2.15.11 and is supported till April 2018.

wdalrymple commented 6 years ago

yeah - we definitely need to upgrade the version of node on the build server. it is old

syrnick commented 6 years ago

My point is that although node 0.10 isn't supported, npm 2 should be supported until node 4 maintenance ends.

nicolo-ribaudo commented 6 years ago

So use the same version of every package in babel? like say: "babel-core": "~6.26.0", "babel-loader": "~6.26.0", "babel-plugin-resolver": "~6.26.0", "babel-plugin-transform-object-rest-spread": "~6.26.0"", "babel-preset-es2015": "~6.26.0"",

Only for official plugins/presets

loganfsmyth commented 6 years ago

@syrnick npm@2 does work, but for Babel to be fast you need to npm dedupe, npm@>=3 do flattening automatically so it is fast automatically. There's also nothing stopping you from installing more recent versions of npm on Node 4, npm 2 is just the included version.

wdalrymple commented 6 years ago

Thanks for the pointers. Much appreciated! Thanks everyone!

internet-john commented 6 years ago

can confirm setting plugins and presets to <6.26.0 works

wssgcg1213 commented 6 years ago

Same issue here.

nicolo-ribaudo commented 6 years ago

@wssgcg1213 Which versions of the babel packages are you using?

wdalrymple commented 6 years ago

I am using: "babel-core": "~6.23.0", "babel-loader": "~6.4.1", "babel-plugin-resolver": "~1.0.0", "babel-plugin-transform-object-rest-spread": "~6.23.0", "babel-preset-es2015": "~6.24.1",

Successfully. "babel-core": 6.26.0 seems to conflict with some of my other dependencies with the babel-loader.

bogo26 commented 6 years ago

I keep having this issue, my package.json looks like:

"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"babel-eslint": "^6.1.2",
"babel-loader": "^6.4.1",
"babel-plugin-istanbul": "^4.1.4",
"babel-plugin-rewire": "^1.1.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1"

babel-core is 6.26.0 babel-cli is 6.26.0 babel-preset-es2015 is 6.24.1

All the latest but I keep getting this when I try to build: //I also tried with fix 6.24.1 to match the latest preset-es2015

_Error: Plugin 20 specified in "app\nodemodules\babel-preset-es2015\lib\index.js" provided an invalid property of "name"

.babelrc looks like this:

{
  "presets": ["es2015", "stage-0", "react"],
  "plugins": ["transform-decorators-legacy", "rewire"],
  "env": {
      "test": {
        "plugins": [
          "istanbul"
        ]
    }
  }
}

npm v3.10.8 Node v6.9.1

What am I missing?

nicolo-ribaudo commented 6 years ago

Can you try to delete node_modules and reinstall it? Maybe you still have an older version of babel-core downloaded. (You can check the installed versions in node_modules/babel-core/package.json and node_modules/babel-preset-es2015/package.json)

bogo26 commented 6 years ago

@nicolo-ribaudo I did that like 20 times today :) I also cleared the cache from AppData, still the same issue I tried to set some old versions, that used to work, same issue.

nicolo-ribaudo commented 6 years ago

Can you yarn list or npm list and upload the output to gist?

bogo26 commented 6 years ago

Yes, here it is https://gist.github.com/bogo26/2c535156663743be7ca745563581f73c

nicolo-ribaudo commented 6 years ago

I'm sorry, I can't reproduce this issue with your package versions... Can you upload a small reproduction on github? Also, in that npm list there isn't a top-level babel-core (I think that it should there be, but I'm not sure)

loganfsmyth commented 6 years ago

Update on this. I've posted https://github.com/facebook/regenerator/pull/312 which will fix the backward-compatibility issue people are hitting. Hopefully we can get that out sooner rather than later.

bogo26 commented 6 years ago

@nicolo-ribaudo I will do that tomorrow if I can't find a fix. I will start a new project and take it step by step and check where it brakes then post it if I can't figure it out.

If anyone has a better solution to fix this I'm all ears :)

hzoo commented 6 years ago

@benjamn published regenerator-transform@0.10.1 so this should be ok https://github.com/facebook/regenerator/commit/30d34536b9e3f7a2873b04a16ec66fec9c8246f6 with Logan's PR ^.

babel-preset-es2015 uses babel-plugin-transform-regenerator which uses "regenerator-transform": "^0.10.0" so it should be updated.

bogo26 commented 6 years ago

That fixed it for me. Thanks guys ^^

hzoo commented 6 years ago

Thanks everyone!