Share services between `nitro/vite` and `nitro/rsbuild`

Abierto
#5,015 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript, vite

Línea de trabajo

Start by comparing entry-server detection in src/build/vite/plugin.ts and src/build/rsbuild/_services.ts, then trace the Vite and Rsbuild runtime and virtual-module paths described in the issue. The proposal is complete when core resolves shared services, both integrations report service loading for development and production, and Rsbuild uses the shared runtime without breaking the Vite alias.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

vite

nitro/vite and nitro/rsbuild (#5011) both run server environments as services that Nitro fetches (e.g. ssr), but each one has its own config, runtime API and internals for the same model: a service is an ESM entry exporting fetch, it shares the nitro/* runtime of the server, and its output is bundled by Nitro in production.

Today:

  • Config: vite.services in Vite; nothing in Rsbuild (only target: "node" environments).
  • entry-server detection is duplicated (src/build/vite/plugin.ts, src/build/rsbuild/_services.ts), and only Vite checks that the server entry and the SSR entry differ.
  • Runtime: fetchViteEnv() from nitro/vite/runtime vs fetchRsbuildEnv() from nitro/rsbuild/runtime.
  • Internals: separate services virtual modules (#nitro/virtual/vite-services, #nitro/virtual/rsbuild-services) with the same lazyService code, separate dev globals, and separate default SSR renderer handlers and renderer selection.

Proposal (additive, no breaking change for nitro/vite):

  • Top-level services option ({ [name]: { entry } }), resolved in core with entry-server detection and the entry conflict check. vite.services stays as an alias.
  • The integrations map services to their environments and register auto-detected server environments back, then report how each service output is loaded (dev and prod).
  • Core generates one services virtual module, one SSR renderer handler and the default renderer selection.
  • One runtime API, e.g. fetchService(name, input, init?) from nitro/services. fetchViteEnv() becomes an alias.

nitro/rsbuild would then use these instead of adding fetchRsbuildEnv().

🤖 Generated with AI assistant

Lenguaje dominante
TypeScript
Estrellas
11.5k
Forks
968
Merge medio
4 d 9 h
PR fusionados (30 d)
64

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de nitrojs/nitro

Todos los issues de nitrojs/nitro

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.