-
Notifications
You must be signed in to change notification settings - Fork 0
Description
To improve security of the rendered output, we should not be using raw strings. Instead we should be using a real templating system which escapes data and input from the actual structure of the rendered HTML. This isn't a massive concern in a Bazel context for rendering at build time, since Bazel requires builds to be hermetic and checked in source code is usually pretty trusted. However potential supply chain vulnerabilities could leak malicious content into their outputs which get sent to users, so this is still good to do. If we move forward with SSR, this will be even more important.
For now, I'd like to start with lit-html as a templating engine because:
- It nicely fits the mental model of
@rules_prerender. - It works in the browser and in Node, so templates can be shared between client side rendering and prerendering.
- No need for DOM emulation in Node either, as long as we limit our usage to
lit-htmland don't pull inLitElement.
- No need for DOM emulation in Node either, as long as we limit our usage to
- It doesn't require a compile-step, which means we don't need a special compiler plugin.
- A compile-step wouldn't be a hard-blocker given that we have a very comprehensive build system available, but
prerender_component()directly wraps the prerenderts_project()orjs_library(), meaning it is very convenient (though not strictly required) to have first-party support for any templating engine with a compile-step.
- A compile-step wouldn't be a hard-blocker given that we have a very comprehensive build system available, but
- It aligns with JavaScript syntax (no change in the language syntax or grammar).
- I'm somewhat familiar with it already.
I'm also open to considering a JSX-based templating system since that has direct support in tsc. I'm not very familiar with it though, so I think that should come secondary to a lit-html engine.