Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/issue 1088 refactor Workers out of SSR builds #1110

Conversation

thescientist13
Copy link
Member

@thescientist13 thescientist13 commented May 16, 2023

Related Issue

resolves #1088

Summary of Changes

  1. Refactor Workers out of serving SSR pages
  2. Pre-compile static HTML templates as local variables at build time
  3. Refactor renderer plugin to just be a function (not tied to Workers implementation)

References

TODO

  1. confirm static templating works, e.g. src/templates/
  2. Will still need the concept of an executeModule for custom implementations like Lit (do we have to handle a renderer and an adapter plugin at the same time?) and for development
  3. get executeRouteModule from config
  4. simplify executeModule signature (pass in entire page)
  5. Update static router serve spec per new implementation
  6. refactor lit renderer and get all specs passing
  7. Is it OK to reference executeModuleUrl in our wrapper bundles? Can we bundle down into one file instead?
  8. Likely we don't need to output templates/ dir anymore?
  9. What about os / thread pooling for prerendering? - deferred to performance benchmarking / optimizing Greenwood #970 and Encapsulating SSR Rendering (Isolation Mode) #1117
  10. Docs
    • prerender plugin
    • getTemplate is a "static" function - deprecating anyways?
    • make a discussion for how best encapsulate SSR?
  11. Test in adapter demo repos
  12. Test in Benchmarking repo - deferred to performance benchmarking / optimizing Greenwood #970
  13. Clean up TODOs / console logs

Questions

  1. getTemplate has to be a "static" function (for now) but maybe we will deprecating anyways as part of Layouts (Templates) and Pages #955 ? - deferred to Static and Serverless Hosting Runtime Adapters #1008
  2. Create a discussion to evaluate alternatives to Workers, or making it opt-in? Or maybe I'm just over thinking it? Would be good to cross reference as part of Static and Serverless Hosting Runtime Adapters #1008 - Encapsulating SSR Rendering (Isolation Mode) #1117
  3. Can we ever "bundle down" to a single file executable for SSR pages? - single file bundles (SFBs) for SSR page and API routes #1118
  4. How to handle something like Netlify which needs custom handling for import.meta.url? - deferred to - Static and Serverless Hosting Runtime Adapters #1008 (comment)
    await fs.writeFile(outputUrl, `
      import 'wc-compiler/src/dom-shim.js';
      import Page from './_${filename}';
    
      export async function handler(request) {
        console.log('${JSON.stringify(page)}');          
    
        let initBody = ${body};
        let initHtml = \`${html}\`;
    
        if (!initBody) {
          const page = new Page();
          await page.connectedCallback();
    
          initHtml = initHtml.replace(\/\<content-outlet>(.*)<\\/content-outlet>\/s, page.innerHTML);
        }
    
        return new Response(initHtml);
      }
    `);

@thescientist13 thescientist13 added enhancement Improve something existing (e.g. no docs, new APIs, etc) CLI SSR labels May 16, 2023
@thescientist13 thescientist13 self-assigned this Jun 8, 2023
@thescientist13 thescientist13 added the Plugins Greenwood Plugins label Jun 8, 2023
@thescientist13 thescientist13 marked this pull request as ready for review June 21, 2023 02:23
@thescientist13 thescientist13 changed the title Enhancement/issue 1088 refactor workers out of ssr builds Enhancement/issue 1088 refactor workers out of SSR builds Jun 25, 2023
@thescientist13 thescientist13 added the documentation Greenwood specific docs label Jun 25, 2023
@thescientist13 thescientist13 changed the base branch from master to release/0.29.0 June 29, 2023 01:24
@thescientist13 thescientist13 force-pushed the enhancement/issue-1088-refactor-workers-out-of-SSR-builds branch from 7f8d9d7 to 27a9c22 Compare June 29, 2023 01:28
@thescientist13 thescientist13 merged commit 65bc4a2 into release/0.29.0 Jun 29, 2023
9 checks passed
@thescientist13 thescientist13 deleted the enhancement/issue-1088-refactor-workers-out-of-SSR-builds branch June 29, 2023 01:46
@thescientist13 thescientist13 changed the title Enhancement/issue 1088 refactor workers out of SSR builds Enhancement/issue 1088 refactor Workers out of SSR builds Jun 29, 2023
thescientist13 added a commit that referenced this pull request Aug 12, 2023
* production SSR workers refactor WIP

* initial draft refactoring for no Workers as part of serving SSR builds

* decouple SSR module execution from Workers implementation

* enable pre-compiled HTML for templates during SSR

* ammed static router spec for execute-route-module

* get SSR execution module from config

* refactor executeRouteModule signature and fix all specs

* update lit renderer per execute module refactoring

* pre-bundle SSR entry points

* refactor entry file to use runtime import.meta.url

* use placholder for SSR page entry point path and replace at write with rollup

* expand rollup and lit circular reference TODO comment

* clean up console logs and track TODOs

* update Renderer plugin docs
thescientist13 added a commit that referenced this pull request Nov 9, 2023
* production SSR workers refactor WIP

* initial draft refactoring for no Workers as part of serving SSR builds

* decouple SSR module execution from Workers implementation

* enable pre-compiled HTML for templates during SSR

* ammed static router spec for execute-route-module

* get SSR execution module from config

* refactor executeRouteModule signature and fix all specs

* update lit renderer per execute module refactoring

* pre-bundle SSR entry points

* refactor entry file to use runtime import.meta.url

* use placholder for SSR page entry point path and replace at write with rollup

* expand rollup and lit circular reference TODO comment

* clean up console logs and track TODOs

* update Renderer plugin docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking CLI documentation Greenwood specific docs enhancement Improve something existing (e.g. no docs, new APIs, etc) Plugins Greenwood Plugins SSR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

evaluate (remove) use of Workers for SSR and prerendering
1 participant