-
Notifications
You must be signed in to change notification settings - Fork 795
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: runtime decorators #6076
Open
johnjenkins
wants to merge
16
commits into
ionic-team:main
Choose a base branch
from
johnjenkins:fix-runtime-decorators
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix: runtime decorators #6076
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With the introduction of #3614, Stencil started removing
@State
/@Prop
class fields during transpilation only to re-add them later, during bundling, as constructor initialised values.This was due to a new behaviour with JS classes, given tsconfig:
A typical Stencil component:
Compiled output went from:
to:
A side-effect this behaviour is user-defined, run-time decorators targeting
@State
/@Prop
would be stripped out during transpilation and break expected behaviour.Within the attached issue, the Stencil dev (at-the-time) outlined the reason for the broken behaviour and also stated their reticence to fix it; a preference to move away from Stencil's statically-analysed decorators for real-life, run-time decorators. Getting class fields working again within Stencil would just be layering-on more tech-debt when the ultimate goal should be to remove it.
Whilst I am completely on-board with the dev's reasoning - the more magic that Stencil can remove, the more Stencil can 'get-out-of-the-way' of native behaviour and expectations - the better. However, I also believe:
experimentalDecorators
and / or the not-yet supported ECMA compliant decorators - will not be small and will take time.What is the current behavior?
GitHub Issue Number: #3831
What is the new behavior?
Fixes #3831
@State
/@Prop
decorated fields with the original Stencilget
/set
during run-time only if it finds modern class static initialisers (during build time we detect them and switch on a newmodernPropertyDecls
build flag)Documentation
Does this introduce a breaking change?
Testing
modernPropertyDecls
target: "es2022"
combined withdist
,dist-custom-elements
and run-time decoratorsOther information