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
Skip class fields transform when not necessary for private methods #14169
Skip class fields transform when not necessary for private methods #14169
Conversation
return; | ||
} | ||
|
||
throw path.buildCodeFrameError(`Unknown PrivateName "${path}"`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check was causing problems because if we only enable the private methods plugin, some private names might not be transformed (i.e. if they refer to a private field).
We now also validate private names usage in the parser, so it's safe to remove it from here.
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/50794/ |
#y() { | ||
this.#x; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the test for this change; all the other test updates are noise.
packages/babel-preset-env/test/fixtures/plugins-integration/class-features-node-12/options.json
Outdated
Show resolved
Hide resolved
…ass-features-node-12/options.json Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
04e519e
to
db078cd
Compare
This leads to an error "Class fields are not enabled" in my codebase, which can be fixed by returning |
It's surprising because we removed that error: could you share your lockfile? (It's late now here, I'll take a look at it tomorrow morning) |
Same for us. Returning to 7.16.8 resolves the problem. |
Could you share your lockfile? |
Copied only the babel-related parts, otherwise it was too long.
|
Thanks, I think that the problem is that I didn't publish a new version of I'm publishing a new version (7.16.11) of |
Thank you! |
Ok, could you verify if |
It does. Thanks! |
FYI, in case it helps others who end-up there, this change also resulted in us having to explicitly add the |
This PR simply relaxes an error in the
helper-create-class-features-plugin
helper, so that it doesn't throw when a class only has fields (and not private methods or other features) and the class fields transform is not enabled.