Share services between `nitro/vite` and `nitro/rsbuild`
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript, vite
- Domain
- backend, build-system
Research direction
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.
Written by the indexing model from the issue text.
Description
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.servicesin Vite; nothing in Rsbuild (onlytarget: "node"environments). entry-serverdetection 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()fromnitro/vite/runtimevsfetchRsbuildEnv()fromnitro/rsbuild/runtime. - Internals: separate services virtual modules (
#nitro/virtual/vite-services,#nitro/virtual/rsbuild-services) with the samelazyServicecode, separate dev globals, and separate default SSR renderer handlers and renderer selection.
Proposal (additive, no breaking change for nitro/vite):
- Top-level
servicesoption ({ [name]: { entry } }), resolved in core withentry-serverdetection and the entry conflict check.vite.servicesstays as an alias. - The integrations map
servicesto 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?)fromnitro/services.fetchViteEnv()becomes an alias.
nitro/rsbuild would then use these instead of adding fetchRsbuildEnv().
🤖 Generated with AI assistant
- Dominant language
- TypeScript
- Stars
- 11.5k
- Forks
- 968
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 64
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nitrojs/nitro
-
pending triage
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Maintainers usually reply within 2 days
-
cloudflare: `nitro deploy` fails when a parent directory has a Wrangler configPossibly taken @draarivpatel-ui claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 2 days
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
pending triage
Difficulty 5/5 Over a week Newbie friendliness 30/100
nitrojs/nitro#5205 · 1 reaction ·
Maintainers usually reply within 2 days
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ranxianglei/billion-context#8319 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JimLiu/open-artifact#126 ·
-
bug repro-ready
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
mksglu/context-mode#1454 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
laststance/design-world#98 ·
Maintainers usually reply within 1 day
-
Add: KCM True crimeOpenapproved check:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day