enhance-dev / enhance-ssr

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

Style transform internal API #17

Closed ryanbethel closed 2 years ago

ryanbethel commented 2 years ago

This PR changes the internal API for enhance style transforms. It makes the following changes:

  1. Adds a context property to the internal API so that the style transform knows if it was called from a template or from in the SSR markup
  2. Runs the SSR style transform from in the processCustomElements function and collects the resulting styles to be added to the head.
    • This allows for instance and component unique styles if needed.
    • Users write styles as if they are targeting the shadowDOM and these tags can be transformed to work with the lightDOM for SSR.
    • These styles are processed with context="markup" so that the style transform script knows that the output should be global css rather than css in a shadowDOM.
  3. The collected styles for SSR are deduplicated and merged into one <style> tag added to the document head.