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 public class property transform when possible #12849
base: main
Are you sure you want to change the base?
Skip public class property transform when possible #12849
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/42816/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit e912525:
|
ad66f65
to
3657f4d
Compare
I think it's easier for us to keep all our own data in Fyi, I did something like this in #12899 where I re-used existing |
@@ -19,6 +19,8 @@ import { | |||
FEATURES, | |||
isLoose, | |||
} from "./features"; | |||
import { isRequired } from "@babel/helper-compilation-targets"; | |||
import compatData from "../data/compat.json"; |
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.
Please don't directly import .json
files, since it won't work when moving to native ESM 🙏
Ref #12759
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.
💔 https://nodejs.org/api/esm.html#esm_json_modules is still experimental.
What do you think about splitting the private and public transforms instead? If a class contains both private and public fields, we could still leave public fields intact. |
I don't think we can leave public fields intact, for example when private elements are referenced in the initializer.
|
3657f4d
to
a196bc8
Compare
Well that can be compiled to class C {
b = (INITIALIZE(this, #a, 1), this.#a);
} which means class C {
b = (_a.set(this, { writable: true, value: 1 }), _classPrivateFieldGet(this, _a))
} anyway, this PR is already a good step in the correct direction. |
3ee24b4
to
e912525
Compare
In this PR we skip
proposal-class-properties
transform when all of the following conditions are satisfiedtargets
has native support of class propertiesI think we should discuss about where we should put the granular compat data. In this case it is the
public_class_fields
used only inproposal-class-properties
transform. I put this table inhelper-create-features-plugin
, which is how a third-party plugin author would have done if he/she wants to implement granular control on the plugin output given differentapi.targets()
.