-
Notifications
You must be signed in to change notification settings - Fork 393
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
fix(babel-plugin-component): skip unnecessary registerDecorators (BREAKING CHANGE) #3660
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
1 similar comment
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
…register-decorators-redux
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.
Many of the diffs in test fixtures appear to be incidental to the changes you've made in the PR. If there are tests that need 👀 , please call that out explicitly.
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 looks really good to me.
import { api } from "lwc"; | ||
import MyCoolMixin from './mixin.js' | ||
|
||
const foo = class extends MyCoolMixin { |
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.
Do you only fail when it doesn't extend anything, since it couldn't possibly be extending LightningElement
indirectly?
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.
Exactly. extends
is a sniff for "might be a LightningElement."
// Any class exposing a field *must* extend either LightningElement or some other superclass. | ||
// Even in the case of superclasses and mixins that expose fields, those must extend something as well. | ||
// So we can skip classes without a superclass to avoid adding unnecessary registerDecorators calls. | ||
// However, we only do this in later API versions to avoid a breaking change. |
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.
Helpful comment, thank you.
@@ -10,15 +10,20 @@ import { isNumber } from './language'; | |||
export const enum APIVersion { | |||
V58_244_SUMMER_23 = 58, | |||
V59_246_WINTER_24 = 59, | |||
V60_248_SPRING_24 = 60, |
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.
Minor nit: Since we're going to be seeing more of these, it'd be nice to have them introduced in a separate PR to keep commit history clean & PRs more readable.
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.
Fair enough. I avoided it since it was like 3 lines though, and since I knew I would have to deal with conflicts anyway once I merged everything all together.
Details
Fixes #2701. New version of #2741
In API version 60+,
registerDecorators
is no longer called for classes that do not extend a superclass (and thus cannot possibly beLightningElement
classes).Does this pull request introduce a breaking change?
Previously, the following would not be a syntax error:
In v60+, this will be a syntax error. The decorators
@track
,@wire
, and@api
can only be used onLightningElement
classes. In the above case,MyCustomClass
does notextend
another class, so it cannot possibly be aLightningElement
class. The fix is to remove the unnecessary@track
,@wire
, and@api
decorators.Does this pull request introduce an observable change?
See above.
GUS work item
W-10736098