Skip to content

[SSR] Avoid variable name collisions on tmpl, generateMarkup, etc. #5109

Closed
@nolanlawson

Description

@nolanlawson

If a component author does something like the following:

import { LightningElement } from 'lwc';

const tmpl = undefined;
const generateMarkup = undefined;

export default class extends LightningElement {
    connectedCallback() {
        // just use the variables to avoid them being tree-shaken
        Object.assign(
            {},
            {
                tmpl,
                generateMarkup
            }
        );
    }
}

Then currently, it will throw an error at compile time in the @lwc/ssr-compiler:

Identifier "tmpl" has already been declared
Identifier "generateMarkup" has already been declared

These are pretty generic names, so we should probably switch to something like __lwcTemplate and __lwcGenerateMarkup to avoid collisions.

Related:

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