ProjectEvergreen / greenwood

Greenwood is your full-stack workbench for the web, focused on supporting modern web standards and development to help you create your next project.
https://www.greenwoodjs.io
MIT License
94 stars 9 forks source link

feature/discussion 1117 Isolation Mode (v1) #1206

Closed thescientist13 closed 3 months ago

thescientist13 commented 4 months ago

Related Issue

1117 (somewhat restores - https://github.com/ProjectEvergreen/greenwood/pull/1110)

Introduces Worker threads as part of the greenwood serve lifecycle when expressed through the a file level export enabling it, which will ensure the page does not get executed in the global scope of the NodeJS process.

// src/pages/products.js
export const isolation = true;

This aims to help address various issues observed with trying to support DOM shims on the server

Summary of Changes

  1. Add opt-in / out isolation mode for SSR pages and add test case
  2. Add opt-in / out isolation mode for API routes and add test case
  3. Default Settings
    • WCC - false
    • Lit - true
  4. Added global configuration for isolation mode
  5. Add documentation and test cases

TODO

  1. [x] Add global configuration option
  2. [x] Docs
    • configuration docs
    • SSR route docs
    • API docs
    • Data sources / graph docs? - N / A
    • adapters / execute route module for export const isolation = true - N / A
  3. [x] Finalize default settings for plugins and docs
    • WCC - false
    • Lit - true
  4. [x] Clean up console logs / comments
  5. [x] refactoring (nice to have)
    • ssr-route-worker filenames are a little clunky
    • Should we re-use thread pool? - maybe?
      • actually no, we should let user's decide on how to scale their own servers, we shouldn't cap anything in production
    • get more options from the graph / module instead upfront instead of in execute route module - will save for https://github.com/ProjectEvergreen/greenwood/issues/991

Question

  1. [x] Should it be set to true by default?