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

Aperta
#5,015 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript, vite

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
TypeScript
Stelle
11.5k
Fork
968
Merge medio
4g 9h
PR unite (30g)
64

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nitrojs/nitro

Tutte le issue di nitrojs/nitro

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.