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

Add TypeScript Server for template-ssr-react-ts and template-ssr-react-streaming-ts #68

Open
maxh1t opened this issue Jan 19, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@maxh1t
Copy link

maxh1t commented Jan 19, 2025

I would like to add a new template to this repository or update existing projects with an Express server written in TypeScript and production-ready build setup. What do you think? What would be the best approach?

Here are examples from my repositories:

The server could be updated in these templates:

I chose to build the TypeScript server using tsup. Any thoughts?

@bluwy
Copy link
Owner

bluwy commented Jan 20, 2025

Hi! Thanks for sharing your templates, and great setup with tsup + nodemon.

I'm open to having the server script be in TS. Since the templates here are often used as a learning resource and reproductions, I'd like to keep it a single file still so it's easier to digest, but I'm sure it shouldn't be too hard to refactor as a directory like yours later.

Instead of a build step, I've been thinking that we could use tsx to execute the server.ts file directly in both dev and prod 🤔 It might take slightly more time to startup but I think it makes configuring easier, plus matches nicely with node --experimental-strip-types once it stabilizes. There's also builtin tsx watch mode for dev. The only downside is that it relies on esbuild v0.23, while vite uses v0.24, but it's probably not the end of the world.

Curious what do you think and if you've tried this setup before?

@bluwy bluwy added the enhancement New feature or request label Jan 20, 2025
@maxh1t
Copy link
Author

maxh1t commented Jan 22, 2025

I like the "keep it simple" approach, but I'm more interested in creating a production-ready template for custom SSR. Something that allows you to build a project, delete node_modules, and still run it. Do you think this repository is the right place for that?

@bluwy
Copy link
Owner

bluwy commented Jan 22, 2025

Server-side code doesn't necessarily need to be bundled to work, so I'd prefer to avoid another build tooling there. Even with Vite's SSR output it also defaults to externalising all dependencies, and expect deployments to run npm install --prod, so I'd like to stick with that convention.

If you prefer to keep the build step, then I think having it in a separate template repo is good for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants