manolo / gwt-polymer-elements

Polymer Web Components for GWT. A collection of Material Design widgets for desktop and mobile.
Apache License 2.0
155 stars 49 forks source link

Allow placing custom components outside of 'bower_components'. #115

Closed kumpelblase2 closed 7 years ago

kumpelblase2 commented 8 years ago

When using the polymer elements without creating custom web components, this is non-issue. However, when I would use PolymerWidget as a base for my own component, being forced to have my html files somewhere under bower_components is irritating and inconvenient. If I don't Polymer will fail to load them, because bower_components will get added to front one way or another.

So things like these structures totally fail:

"components/bower_components/custom-component/custom-component.html" => fails, adds bower_components in front
"components/my-component.html" => fails, adds bower_comonents in front
"./my-component.html" => fails, adds bower_components in front
"//mydomain.com/resources/bower_components/my-component/my-component.html" => fails, adds bower_component in front

I think all of these situations should be possible somehow. Right now I would have to do the following to get the desired behavior:

  1. Don't extend PolymerWidget (or use the 2args constructor) and directly interface with Polymer.Base to add my import and replicate all the other code (e.g. in Polymer.ensureCustomElement())
  2. Directly import my element in html
  3. Use asolute urls (can't even use '//' to use same schema)

This seems too much work for something this basic.

manolo commented 7 years ago

Well, we deliver all the elements in the library under the bower_components folder, which is quite standard name. Anyway, if you import your own element before you use it, for instance in your index.html or calling Polymer.importHref with your URL, the ensureCustomElement should detect that the web component is registered and shouldn't do any request, at least using 1.7.0.0-SNAPSHOT

Another option could be that bower_components could be configurable via a static method, or something, but then you need to provide all the elements you use like iron-icon etc in your component folder. Or do you have better idea ?

manolo commented 7 years ago

Fixed in https://github.com/vaadin/gwt-api-generator/commit/5590d81fd6241802297772c764e0fabdfe11e180