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

feat: added new express runtime for selfhosted vps and vms #1450

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

thecodacus
Copy link
Collaborator

Add Express Server Runtime

Overview

This PR adds a new Express-based runtime option to run the server build, providing an alternative to the default Cloudflare runtime. This enables developers to run the application in a more traditional Node.js environment for local development and testing.

Key Changes

1. New Express Runtime

  • Added a new bolt-diy-express runtime in the runtimes directory
  • Created npm scripts to build and run the Express runtime: runtime:express_build and runtime:express
  • Implemented a standalone Express server that serves the Remix application

2. Server Entry Point Modifications

  • Updated app/entry.server.tsx to use react-dom/server.browser instead of react-dom/server
  • Added TypeScript ignores and type annotations to resolve compilation issues

Technical Details

bolt-diy-express Runtime

Key technical implementation details:

  • Uses Express.js to serve the Remix application
  • Dynamically imports the Remix build at runtime
  • Serves static files from the client build directory
  • Handles all routes through the Remix request handler

System Changes

  • Added TypeScript configuration for the new runtime
  • Updated project structure to accommodate multiple runtime options
  • Modified the root tsconfig.json to exclude the runtimes directory

Migration Impact

  • No breaking changes - the default Cloudflare runtime still works as before
  • The Express runtime can be used optionally by running pnpm runtime:express_build followed by pnpm runtime:express
  • Server runs on port 5173 by default (configurable via PORT environment variable)

Usage Steps

To leverage the new Express runtime:

  1. Build the application with Remix:

    pnpm build
  2. Build the Express runtime:

    pnpm runtime:express_build
  3. Start the Express server:

    pnpm runtime:express
  4. Access your application at http://localhost:5173

You can also customize the port by setting the PORT environment variable:

PORT=3000 pnpm runtime:express

Future Improvements

  • Add comprehensive documentation for the Express runtime
  • Add configuration options for server port, host, etc.
  • Implement hot reloading for the Express runtime
  • Add environment variable handling

Documentation Updates

  • Documentation changes will be addressed in a future PR

@leex279 leex279 self-requested a review March 8, 2025 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants