Buslowicz / twc

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

Lightweight alternative for lazy imports #114

Open tpluscode opened 7 years ago

tpluscode commented 7 years ago

While implementing #108 will be complex and require bending the language to our needs, I'm thinking that maybe a simple solution is possible by pre-processing this.importHref/Polymer.importHref so that one can write module path instead of absolute path.

For example, given an import of an element which would statically be import 'bower:paper-input/paper-input.html' maybe it would be possible to rewrite each used of importHref (correct depending on version of Polymer used) so that

Polymer.importHref('bower:paper-input/paper-input.html');

becomes

Polymer.importHref('../../bower_components/paper-input/paper-input.html');

where the path is adjusted based on the relative location and .bowerrc/config.

As a nice bonus this could serve as an opportunity to warn if the component isn't found bower_components.

Buslowicz commented 7 years ago

Hmm, sounds good, but it would not be as easy as one would think. Finding every Polymer.importHref is rather easy, under the condition that nothing overrides the Polymer name. If anything overrides it, we have false results. Nevertheless, it's always worth implementing, just need to work out the full flow and specs for this feature.