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

standalone production server #1282

Open
3 tasks
thescientist13 opened this issue Sep 19, 2024 · 0 comments
Open
3 tasks

standalone production server #1282

thescientist13 opened this issue Sep 19, 2024 · 0 comments
Labels
CLI documentation Greenwood specific docs enhancement Improve something existing (e.g. no docs, new APIs, etc) Init question Further information is requested SSR
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Sep 19, 2024

Summary

While Greenwood output its build in standalone files (even for SSR) in order to self-host using Greenwood's server (greenwood serve] docs requires using the CLI, which requires invoking Greenwood on a production server, or installing it as production dependency e.g.

$ npx @greenwood/cli serve

However, it would be extremely valuable and more ergonomic if you could boot up Greenwood as a server using just Node.js, by providing a server.js entry point / front-controller that bundles everything needed for the routing and static asset handling, so instead you can just build and serve. Pretty much just like this feature in Next.js

$ greenwood build

$ node ./public/server.js

Having the CLI only need to be a dev / build time tool and not be in the hot path of production would be really really nice.

Details

In particular for these two key responsibilities would have to be entirely self-contained:

  1. Routing - matching incoming requests to static assets, SSR pages, and API routes
  2. Static Hosting - using its internal resource plugins to handle sending the right content type for JavaScript, CSS, fonts, images, etc

I suppose this would likely just be another custom Rollup configuration and we just build up the entry point manually.

I wonder if we would still want to have the serve command anymore? I think we would probably just rename it to preview


Some related thoughts that could / should be their own issue

  1. We have a server plugin API, should we factor this in? Should we give the option to run server plugins for production? (I don't think they are, its only for dev mode. Or we should at least document this behavior
  2. Not sure if this means we wouldn't have to create adapters for specific server frameworks (Fastify, Express, etc), since if we can just start from a node server.js then there's nothing else needed?
  3. This would make Dockerizing a bit easier, so let's remember to update those related hosting docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI documentation Greenwood specific docs enhancement Improve something existing (e.g. no docs, new APIs, etc) Init question Further information is requested SSR
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant