enhance-dev / enhance-ssr

Server side render for custom elements.
143 stars 9 forks source link

Collect `<link/>` elements from custom elements and move them to `<head>` #47

Closed sjorsrijsdam closed 1 year ago

sjorsrijsdam commented 1 year ago

Enables the use case where custom elements use the <link/> element to load, prefetch, preconnect, etc to external resources.

kristoferjoseph commented 1 year ago

EDIT: I went for a walk to think through the implications of this PR and it occurred to me that as long as we dedupe; as you did, and do not strip the link tags from the template in the browser then this is actually a good addition.

This is not able to be merged because it will break the use case of linking an external css stylesheet for use in a component that leverages the Shadow DOM.

Since Shadow DOM enabled components do not have access to stylesheets linked in the host page we sometimes need to also add a link inside the component in order to leverage a cached styleguide stylesheet.

And yes, Shadow DOM is annoying. Is there another way we could accomplish the intent of this PR?

sjorsrijsdam commented 1 year ago

Problems that resolve themselves are my favorite kind of problems 😄 If this however does present issues in the future, don't hesitate to ping me either here or on Discord