Skip to content

chore: use __lwc for transmogrified function names #5278

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

Merged
merged 4 commits into from
Mar 11, 2025

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.

@wjhsf wjhsf merged commit 785479b into master Mar 11, 2025
11 checks passed
@wjhsf wjhsf deleted the wjh/__lwc-transmogrify branch March 11, 2025 19:09
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.

2 participants