Skip to content

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

Open
@nolanlawson

Description

@nolanlawson

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions