fast icon indicating copy to clipboard operation
fast copied to clipboard

Determine how FASTStyle and Command Buffering client code gets exposed

Open nicholasrice opened this issue 2 years ago • 1 comments

SSR has two features that require client-side JavaScript code to be executed prior to custom element parsing on the client;

  1. The FASTStyle custom element
  2. command-buffering custom element

For both of these features, we need to decide how exactly to expose the JavaScript for those features. The JavaScript will need to be emitted to a <script> element in the page response / resulting HTML.

Emit from TemplateRenderer.render() A naive approach would be to emit the code when configured whenever TemplateRenderer.render() is called. However, this would limit implementations to only invoking TemplateRenderer.render() oncer per page request, otherwise duplicating the script code which would cause client side errors from defining the same element multiple times.

Require authors to write the @microsoft/fast-ssr can expose the script content as a string. With that, authors can write that script content into their template, or otherwise ensure it is sent appropriately with the request response. At this point this is the approach I would prefer but I'm open to other ideas or ways to improve.

nicholasrice avatar Apr 27 '22 22:04 nicholasrice

discussion on typescript minification https://github.com/microsoft/TypeScript/issues/8

prudepixie avatar Jul 28 '22 23:07 prudepixie