Buslowicz / twc

TypeScript based, boilerplate-less, Polymer toolbox friendly Polymer Modules
32 stars 1 forks source link

Implicit template import if HTML exists #52

Closed tpluscode closed 7 years ago

tpluscode commented 7 years ago

I think that given adjacent ts and html files like

/
|-- src
    |-- my-element.html
    |-- my-element.ts

it could enough to only export the class and have twc automatically pick up the matching HTML file as element's template, i.e. without using the @template decorator.

Buslowicz commented 7 years ago

Personally I'm against magic like that. Had similar magic things in meteor (auto including etc) and it was terrible on the long run. Also having template imported by annotation explicitly makes things easier to check where stuff is coming from. Additionally, checking for template existence would make the tool a bit slower, as it would always make additional FS operation for each module no matter if template will be fetched from the file or not.

tpluscode commented 7 years ago

It was just a thought I had yesterday. The performance argument does make sense.

How about an opt-in feature?

tpluscode commented 7 years ago

I'm not strongly in favor though. It's your call

Buslowicz commented 7 years ago

I could provide a flag to either use implicit template or not, but that would just bring more confusion in my opinion. Maybe in the future if the tool is popular and more people ask for that feature, I could add it, but for now I want to boost the performance (created a task for it already) and keep the options to minimum (some people really hate config files :P). Nevertheless, thanks for the idea, I appreciate the input ;).

tpluscode commented 7 years ago

OK. Let's kill it. For now :)