Buslowicz / twc

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

Invalid import links don't appear in output #71

Closed tpluscode closed 7 years ago

tpluscode commented 7 years ago

Related to #57, I see that v0.1.12-beta.1 shows warning when an import is invalid but it also doesn't put those imports in the JS output.

For example, when I have import 'link!../../polymer/polymer.html'; in a processed file, it gives the warning but not <link> in output.

It is obvious that such imports are invalid at build time of element project. I think that twc should fall back to looking in bower_component to see if the path would actually resolve to bower_components/polymer/polymer.html.

Do you think it's also worth observing .bowerrc in case the components folder has a non-default name?

Buslowicz commented 7 years ago

Hmm, I could do that, but I was rather thinking of calculating difference between source and output location and modifying every link! and script! path using that diff. What do you think about that solution? Or should I do as you suggested?

tpluscode commented 7 years ago

Oh right, I didn't think about that. Definitely a good idea to have links transformed so that they work in output dir, if it's different.

But still I wouldn't remove any links if they are invalid...

Buslowicz commented 7 years ago

Not a problem at all :). Thought it was better to not emit invalid imports, but it might actually be unwanted. I will however add a flag, sort of --noEmitInvalidLink, to restore that behavior on demand (but the default will be as you described).

tpluscode commented 7 years ago

My thinking is that you can run into trouble when a link would actually be valid but incorrectly classified. Also, absolute HTTP hrefs (cdn?)

And I'd call the flag --stripBrokenLinks or --stripInvalidLinks

Buslowicz commented 7 years ago

Non-relative paths (cdns, absolute) are pretty easy to check, relative are much worse due to changing physical position. I can definitely leave invalid links, but the question is what to do with them? Warnings are fine if they are definitely dead links, but should not appear if they just don't match physical structure in design time. Any suggestions about that ^^?

tpluscode commented 7 years ago

I don't know. Maybe it's safe to assume that links will usually match a physical location relative to source or destination folder?

Buslowicz commented 7 years ago

Yea it might be the best thing to do, at least for now. Nevertheless, I will not strip invalid links as you suggested :).

Buslowicz commented 7 years ago

Fixed in #74.