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

[babel-plugin] Warn/error for undefined sel instead of returning the empty string #4824

Open
nolanlawson opened this issue Nov 11, 2024 · 0 comments · May be fixed by #4825
Open

[babel-plugin] Warn/error for undefined sel instead of returning the empty string #4824

nolanlawson opened this issue Nov 11, 2024 · 0 comments · May be fixed by #4825
Labels

Comments

@nolanlawson
Copy link
Collaborator

nolanlawson commented Nov 11, 2024

According to our unit tests, the empty string condition here is uncovered:

const componentName = namespace && kebabCasedName ? `${namespace}-${kebabCasedName}` : '';

Screenshot 2024-11-11 at 12 30 28 PM

Defaulting to the empty string here is questionable because you will end up with an error at runtime here:

const sel = getComponentRegisteredName(Ctor);
if (isUndefined(sel) || sel === '') {
throw new Error(
`Invalid LWC constructor ${toString(Ctor)} does not have a registered name`
);
}

This is hard to debug, and we should never have an undefined name/namespace in the Babel plugin, so it may be safer to throw an error or at least log a warning.

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

Successfully merging a pull request may close this issue.

1 participant