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

オープン
#5,015 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript, vite

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
TypeScript
スター
11.5k
フォーク
968
平均マージ
4日 9時間
マージ済み PR(30日)
64

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nitrojs/nitro のほかの issue

nitrojs/nitro の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。