Skip to content
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

chore: use __lwc for transmogrified function names #5278

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

wjhsf
Copy link
Collaborator

@wjhsf wjhsf commented Mar 7, 2025

Details

When we transmogrify the SSR compiler's output, we only want to target functions created by the compiler, not the component's implementation. We check for specific function names, but technically a component could implement a function with the same name (or even containing the same name, like omgwtftmplbbq, because we don't use ^$ in the regex check). However, we already prevent components from using names starting with __lwc, so we can prevent accidental transmogrification by using that namespace for the functions we own.

Does this pull request introduce a breaking change?

  • 😮‍💨 No, it does not introduce a breaking change.
  • 💔 Yes, it does introduce a breaking change.

Does this pull request introduce an observable change?

  • 🤞 No, it does not introduce an observable change.
  • 🔬 Yes, it does include an observable change.

GUS work item

@wjhsf wjhsf requested a review from a team as a code owner March 7, 2025 20:24
const TMPL_FN_PATTERN = /tmpl($\d+)?/;
const GEN_MARKUP_OR_GEN_SLOTTED_CONTENT_PATTERN =
/(?:generateMarkup|generateSlottedContent)($\d+)?/;
const TRANSMOGRIFY_TARGET = /^__lwc(GenerateMarkup|GenerateSlottedContent|Tmpl)(?:\$\d+)?$/;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having two regex to check for three nearly identical things seemed silly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant