Git Product home page Git Product logo

lit-ssr's Introduction

lit-ssr

Experimental lit-html & LitElement SSR server

Note: This requires npm linking the hydration branch of lit-html.

Setup

This repo requires Node 13.9.0 because of it's use of experimental VM modules. It also requires unreleased versions of lit-html and lit-element. Nothing here is for public comsumption yet.

To keep the experimental dependencies localized, they should be checked out into sibling folders. lit-ssr uses file dependencies to reference them:

SSR
├── lit-element (patched to use the lit-html)
├── lit-html (checkout and build the hydration-repeat branch)
├── lit-ssr (this repo)
└── template-attach-shadow (will be required soon)

lit-ssr's People

Contributors

justinfagnani avatar kevinpschaaf avatar sorvell avatar straversi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lit-ssr's Issues

Set up client/server testing

Using the lit-html hydration branch, we should set up integration test infrastructure so that we can run unit tests that do server rendering, hydrate the results on the client, and check assertions on the hydrated results.

The working assumption is that these will be Karma tests utilizing a proxy to serve up the server rendered HTML.

Serialize user-defined reflecting properties to LitElements

Description

lit-ssr needs to recognize property bindings to user-defined reflect: true properties on LitElements and automatically serialize those to their corresponding attributes.

Acceptance Criteria

  • Tests that demonstrate correct serialization of user-defined reflecting properties to attributes are checked in and passing.

Ensure <script> tags rendered via TemplateResults on server do not result in executable code on client

On the client, this code will not result in script execution:

const result = html`<script>alert('hi')</script>`;
render(result, container);

However, when rendering the same template via render-lit-html, the script will be emitted into the page and executed when parsed on the client. The SSR code should (optionally) identify <script> tags and mark with a type="disabled" or similar attribute to prevent script execution, to maintain the same guarantees client-side security guarantees when server-rendering.

Declarative ShadowRoot polyfill MVP

  • Write benchmarks
  • Decide on template or element or both (SEO impact)
  • Design shard styles (design doc & public explainer?)
  • Implement shared styles
  • Implement hacker-news shadow-dom app

Benchmark lit hydration vs. normal lit rendering

Let's benchmark hydration of pre-rendered html using lit-html VS. rendering of the same page using normal lit-html. This can give us insights on the costs of the hashing scheme and other additions made for hydration.

Investigate custom SSR & hydration for components

Components like <lit-virtualizer> may need to render differently on the server and client. It's possible that existing component SSR, renderLight(), plus whatever we do for directives may cover the cases here, but we should verify and prototype before releasing lit-virtualizer.

Allow custom elements to reflect properties to attributes

ElementRenderer might need changes to enable this.

There's an ordering issue in that we want to set attributes before the element renders so that the element can use them, but we need reflected attributes to be streamed before closing the start tag.

Style scoping for pre-rendered custom elements

Implement style scoping for pre-rendered custom elements. We already generate a scoped stylesheet that covers all defined custom elements, now we need to add the scoping classes to all of those elements.

Emit slotting comments

We need to keep track of the slotted element's original locations for shadow root rehydration.

Factor out common element renderer code

In render.ts we have handleNode can render an element including finding the correct renderer for it, handling attributes, etc., LitHtmlChildRenderer also needs to do this, so we should expose a common element rendering function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.