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

On update to version 7.00-beta.46 Get Decorators Support Error [BUG] #7786

Closed
adeelibr opened this issue Apr 23, 2018 · 23 comments
Closed

On update to version 7.00-beta.46 Get Decorators Support Error [BUG] #7786

adeelibr opened this issue Apr 23, 2018 · 23 comments
Labels
i: question outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@adeelibr
Copy link

This is error I get,
The new decorators proposal is not supported yet. You must pass the"decoratorsLegacy": true option to @babel/preset-stage-2 (While processing

@babel-bot
Copy link
Collaborator

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

@hzoo
Copy link
Member

hzoo commented Apr 23, 2018

This is a specific/intentional breaking change we made to beta.45

#7734

This is because we want the Stage 2 behavior to be default before the final 7.0 release but we currently want people to opt-into decorators legacy instead. However We have a side effect of the stage presets having to pass all the options down (and why Logan is suggesting we also do #7770)

@adeelibr
Copy link
Author

Can you kindly update the docs, as to how to resolve this breaking change. As to what changes are required to make in .babelrc file.

@hzoo
Copy link
Member

hzoo commented Apr 23, 2018

Yep I just released this yesterday night and was going to do it today. This shouldn't be an issue unless you are using ^ in your dependencies right?

Either way it should be in the release notes, the PR, and we have a PR merged in babel-upgrade babel/babel-upgrade#63. Didn't get to write the docs for the website yet but I'm not sure which ones you are referring to? The readmes all have the new option and the error says to add the decoratorsLegacy option to the corresponding preset?

@adeelibr
Copy link
Author

adeelibr commented Apr 23, 2018

My .package.json file's dev dependencies look something like this.

    "@babel/core": "^7.0.0-beta.44",
    "@babel/preset-env": "^7.0.0-beta.44",
    "@babel/preset-react": "^7.0.0-beta.44",
    "@babel/preset-stage-2": "^7.0.0-beta.44",
    "babel-loader": "^8.0.0-beta.2",
    "css-loader": "^0.28.11",
    "copy-webpack-plugin": "^4.5.0",
    "html-loader": "^0.5.5",
    "html-webpack-plugin": "^3.2.0",
    "mini-css-extract-plugin": "^0.4.0",
    "node-sass": "^4.8.3",
    "sass-loader": "^6.0.7",
    "webpack": "^4.5.0",
    "webpack-cli": "^2.0.14",
    "webpack-dev-server": "^3.1.3"
  },```

and my `.babelrc` file looks like this

`
{
  "presets": [
    "@babel/env",
    "@babel/preset-react",
    "@babel/preset-stage-2"
  ]
}
`
This was working fine 2-3 days ago, but today when I shipped I got the error for 

`The new decorators proposal is not supported yet. You must pass the"decoratorsLegacy": trueoption to @babel/preset-stage-2 (While processing`

@hzoo
Copy link
Member

hzoo commented Apr 23, 2018

The new decorators proposal is not supported yet. You must pass the "decoratorsLegacy": true option to @babel/preset-stage-2

I think the error message is correct? I believe I made it pretty clear above, but it's

{
  "presets": [
    "@babel/env",
    "@babel/preset-react",
+    ["@babel/preset-stage-2", { "decoratorsLegacy": true }]
-    "@babel/preset-stage-2"
  ]
}

Also like I mentioned if you use "@babel/core": "^7.0.0-beta.44", and we make an intentional breaking change it will break the build automatically. That's why I'm suggesting people pin the version while in beta (we've tried to suggest this since it's not released but difficult to get that message across especially when it's the default)

@adeelibr
Copy link
Author

Thank you so much for reaching out & helping with this, I'll write an article about this with a publication like freeCodeCamp & try to spread the word out.

@hzoo
Copy link
Member

hzoo commented Apr 23, 2018

I'll write an article about this with a publication like freeCodeCamp & try to spread the word out.

I'm a bit confused, is this article about this bug, about Babel 7, or my comment about pinning the version in beta?

Was the error message not clear enough in your opinion? I know it assumes knowledge about presets/options.

I'm going to close this either way though, the message is correct! Thanks.

@hzoo hzoo closed this as completed Apr 23, 2018
@loganfsmyth
Copy link
Member

loganfsmyth commented Apr 23, 2018

So everyone's on the same page here. Babel is still in beta, and we are still making breaking changes. If you are using a prerelease version of any package, you should be using a lockfile and only upgrading it when you're ready to test out the new version, just like if it were a new major version release.

Personally I wouldn't use ^ in the version at all, but if you want to, you must at least use a lockfile or else you are opting into instability.

@adeelibr
Copy link
Author

By writing an article I meant about this that if you are using babel 7 in beta mode you should not use ^ because at any time there can be breaking changes. @hzoo

joncasey added a commit to joncasey/modern-hta that referenced this issue Apr 23, 2018
Intentional breaking change was introduced in beta.45.
More info babel/babel#7786
@AdamKochanski
Copy link

AdamKochanski commented Apr 24, 2018

I just try to make fresh installation and I have same errors.

My solution in package.json

  "babel": {
    "presets": [
	"@babel/env",
	["@babel/preset-stage-2", { "decoratorsLegacy": true }]
    ]
  },

@markusenglund
Copy link

markusenglund commented Apr 24, 2018

This doesn't make any sense to me. I'm not using decorators anywhere in my code but still getting this error. Is that the intended behaviour?

@nicolo-ribaudo
Copy link
Member

Yes. If you are using a stage <= 2 preset, you are asking Babel to transpile decorators, even if you actually don't use them

@hzoo
Copy link
Member

hzoo commented Apr 24, 2018

Due to that consequence ^ we are considering removing the stage presets #7770.

@markusenglund
Copy link

I see. Still, it doesn't seem reasonable that the default behaviour of stage <= 2 presets is to crash the build.

@loganfsmyth
Copy link
Member

@markusenglund The idea initially was that we'd require the flag in the short-term until we finished implementing the standard-compliant version of decorators as a replacement, and then that would be the default behavior. Now that we're removing the preset, it'll be up to people to do the right thing when they use the individual plugins.

@markusenglund
Copy link

Are you definitely gonna drop the stage <= 2 presets?

@Tsury
Copy link

Tsury commented Apr 30, 2018

So what configuration do I need to use now if I'd like to use decorators as I've previously used (I use decorators for mobx).

@nicolo-ribaudo
Copy link
Member

["@babel/plugin-transform-decorators", { "legacy": true }]

@Tsury
Copy link

Tsury commented Apr 30, 2018

@nicolo-ribaudo There's no such thing as @babel/plugin-transform-decorators, only npm install --save-dev babel-plugin-transform-decorators. Did you mean this one?

@vuldin
Copy link

vuldin commented Apr 30, 2018

Don't want to speak for @nicolo-ribaudo but he probably meant @babel/plugin-proposal-decorators

@Tsury
Copy link

Tsury commented Apr 30, 2018

Well that's the one I was already using. Adding legacy = true makes babel complain that the decorators experimental feature is not turned on...

@nicolo-ribaudo
Copy link
Member

@vuldin Tuo, thank you!

@Tsury Can you show your configuration and the error message?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: question outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

9 participants