IC does not correctly handle multiple HTML template files in an LWC bundle

Issue #1216 resolved
Chuck Liddell created an issue

A Lightning web component bundle can contain multiple template files, and toggle between them in its render() function.

Sample javascript:

import {LightningElement} from 'lwc';
import alternative from './alternative.html';

export default class MyModule extends LightningElement {

    render() {
        return alternative;


Obviously a contrived example, but just wanted to establish context.

There is a bug in IC where opening other templates doesn't actually open them, and instead still opens and edits the original template. A new tab (with the right label) is opened so you THINK you're editing the other template, but actually you can never open that other file, it's always the original that opens.

Screenshot 2019-01-11 07.35.48.png Screenshot 2019-01-11 07.35.59.png

How to Reproduce

  1. Create a second HTML file in your LWC Bundle (not possible from right click menu, which blocks creation of a second template once you have one, you have to create an html file in that folder)
  2. Try to edit that new file from inside IC; a tab opens with that file name, but what you see is the original template and all edits that are saved will overwrite the original template, leaving the second template untouched

Comments (6)

  1. Scott Wells repo owner

    Hey, Chuck. Can you provide the documentation for this? When I look at the allowed contents of a component as documented here:


    I don't see any reference to additional HTML files, only additional JS files. I want to make sure that I implement support for this properly, and the documentation for the associated use cases/behaviors will be invaluable for that.


  2. Chuck Liddell reporter

    Not documented afaik, I've seen it explained by LWC team both in the pilot chatter and in the LWC channel in GDS.

    It's an advanced pattern and I'm not sure they've bothered to document it publicly, but it's definitely a recommended and supported approach.

  3. Scott Wells repo owner

    Delivered in It's now possible to create additional HTML files for an LWC bundle as a first-class menu option, and those files are included in the sub-tabs for the bundle.

  4. Log in to comment