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
Parser decorators
plugin option decoratorsBeforeExport
no longer defaulting
#8562
Comments
Hey @jaydenseric! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
This was a purposeful change in #8465 for now because the spec authors haven't settled on one or the other. To avoid us choosing the wrong default, we opted to require users to choose. In the short term, I'd expect users transitioning from |
Maybe the docs should be updated to reflect that there is no longer a default. Encountered the issue when reinstalling node_modules for |
Totally, happy to leave this open to we can address the docs. FYI, you may want to consider using Also, in the long run, since you're using |
I'm struggling with this right now, when I set this:
OR
For both I get the same error if I remove the
I get "The new decorators proposal is not supported yet. You must pass the if I remove the
I am able to proceed... However this does now cause errors with using decorators and then using export default. I'm aware the spec is 'still in flux' but what is the way to configure this where I can use decorators like
Is this no longer able to be done? |
Just using |
Its not giving me a message like the others, just 'failed to compile'. when I change the files to
that works. I'm not really sure what's wrong but in the previous beta (7.0.0-beta.49) this worked, and for me at least in 7 its not. What I mean is that code that had decorators preceding an export did not break, and I was able to specify If you're telling me that's a config that works, its possible the error is in eslint or something. I mainly wanted to confirm that's the correct config, but I am getting breaks on situations where there are dercorators before export and I was not beforehand. Should that config be working on decorators before the export keyword ? |
This comment has been minimized.
This comment has been minimized.
Sorry y'all, I was confused with another issue. Our parser has two diffrent plugins: |
@nicolo-ribaudo I'll answer your questions first: I am a bit confused on what is meant about the new/old proposal. I have been using this 'new' proposal lib and only with the release of 7.0.0 did it break. It was working with beta-49+ as far as i can recall. I'm using and have been using the new behavior. However, I am not sure what the expectation right now in this proposal plugin should be. I was under the impression that there was no consensus yet on before or after export (such as in this thread) tc39/proposal-decorators#69 and that the plugin you've authored here allowed the enduser to configure, via a flag ( Regardless, rather than referencing these confusing threads with hundreds of back-and-forth comments, more directly I am asking :
I've already converted my codebase to
I've been able to move past, but this was really time consuming, and to be honest I preferred the way it was beforehand. Sorry to keep this going, but any answers you give help other folks besides myself reading this get some clarity. The decorators 'situation' is very confusing overall, even if you're studiously reading the TC-39 threads (most people aren't). Thanks again for any replies, and I appreciate the effort on this project. |
Sorry for the confusion, I get that old/new proposal doesn't mean anything for many people. The "old" proposal is the one y'all are used to: it's the only one implemented in Babel and TypeScript. It's the one supported by The "new" proposal is currently only implemented in The
You still can, the old behavior hasn't changed. We only require the const out = babel.transformSync(
`
@decorator
export default class Foo {}
`,
{
plugins: [
[
require("./packages/babel-plugin-proposal-decorators"),
{ legacy: true },
],
],
}
);
console.log(out.code); logs var _class;
let Foo = decorator(_class = class Foo {}) || _class;
export { Foo as default };
In babel-eslint you have to opt-in to use the "old" proposal: in your eslint config, you should have something like this: {
parserOptions: {
ecmaFeatures: {
legacyDecorators: true
}
}
} |
Do you want to open a PR to babel/website? |
@the-simian I had you same problem, solved with @nicolo-ribaudo suggestion, change you eslint config:
|
I believe this was my problem thank you @nicolo-ribaudo , I see there's an issue for this here: babel/babel-eslint#679 |
@nicolo-ribaudo @loganfsmyth @existentialism The intention of #8465 is unclear, probably should write the tests a bit better so this is caught. |
@wyuenho could you please open an issue on https://github.com/babel/website? |
How can you set the legacyDcorators:false in webpack? |
What is your current config? |
Yes, please explain how to resolve this with a webpack config. I dont' even know where to start with this error. |
What is your current config? |
@nicolo-ribaudo This is my webpack 3.x config, which is used by electron-webpack. I'm taking over this project and I'm very ignorant of why things are configured the way they are. .babelrc
webpack.config.js
And of course when attempting to upgrade to Webpack 4.x, I've changed the babel 6 versions of things to the babel 7 Unfortunately I don't have my Webpack 4.x attempt because it's just too frustrating of an endeavor right now, so I had to revert and move on. |
You can run |
Thanks, that's very helpful
…On Tue, Nov 6, 2018, 5:55 PM Nicolò Ribaudo ***@***.***> wrote:
You can run npx nls why @babel/plugin-proposa-decorators to see why it is
installed.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#8562 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABlGHbuDAIH_Idfeo5zMc03HUdxZlEhlks5ushNbgaJpZM4WO5xl>
.
|
recently was getting problem with this error and installed this run my code with some errors, but app was working, I'm a beginner, so hope this comment is relevant |
For would be Googler's and create-react-app users. Create your Then eject the project:
Add mobx, mobx-react and the decorator plugin:
Then in your package.json you'll see:
Just update it to:
|
@sergiotapia Did you mean 'Then in your .babelrc` |
Bug Report
Current Behavior
In a recent v7 release (maybe even the final?), the parser
decorators
plugin optiondecoratorsBeforeExport
no longer defaults as it used to.Results in an error:
This is unexpected, as the
decoratorsBeforeExport
option is meant to default tofalse
. Manually providing the same value as the supposed default works:Expected behavior/code
A clear and concise description of what you expected to happen (or code).
Babel Configuration (.babelrc, package.json, cli command)
N/A.
Environment
cli
,register
,loader
]: APIPossible Solution
Additional context/Screenshots
The text was updated successfully, but these errors were encountered: