vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
590 stars 164 forks source link

A new Java Polymer template class doesn't work with JRebel #7186

Open denis-anisimov opened 4 years ago

denis-anisimov commented 4 years ago

Steps to reproduce:

@Tag("my-el")
@JsModule("./src/my-component.js")
public class MyComp extends PolymerTemplate<TemplateModel> {

}
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
import { html } from '@polymer/polymer/lib/utils/html-tag.js';

class MyComponentElement extends PolymerElement {
  static get template() {
    return html`
        <button id="button">Click</button>
        <div id="content"></div>
    `;
  }

  static get is() {
    return 'my-el'
  }
}

customElements.define(MyComponentElement.is, MyComponentElement);
Caused by: java.lang.IllegalStateException: Couldn't find the definition of the element with tag 'my-el' in any template file declared using '@JsModule' annotations. Check the availability of the template files in your WAR file or provide alternative implementation of the method getTemplateContent() which should return an element representing the content of the template file
    at com.vaadin.flow.component.polymertemplate.NpmTemplateParser.getTemplateContent(NpmTemplateParser.java:140)
    at com.vaadin.flow.component.polymertemplate.TemplateDataAnalyzer.parseTemplate(TemplateDataAnalyzer.java:200)
    at com.vaadin.flow.component.polymertemplate.TemplateInitializer.<init>(TemplateInitializer.java:91)
    at com.vaadin.flow.component.polymertemplate.PolymerTemplate.<init>(PolymerTemplate.java:88)
    at com.vaadin.flow.component.polymertemplate.PolymerTemplate.<init>(PolymerTemplate.java:103)
    at com.vaadin.starter.skeleton.MyComp.<init>(MyComp.java:29)
    at com.vaadin.starter.skeleton.MainView.<init>(MainView.java:25)
pleku commented 4 years ago

This would need to a hook to attach to the JRebel reload and then trigger the new polymer template file to be picked. Currently the changes are not ending up into a new stats json file that webpack dev server creates.