Repository navigation
feat: shared services in core - #5023
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait...
|
commit: |
pi0x
force-pushed
the
feat/core-services
branch
from
November 3, 2026 17:13
903bc3d to
c38667f
Compare
pi0x
force-pushed
the
feat/core-services
branch
from
November 3, 2026 17:17
c38667f to
bafb14e
Compare
services in core with fetchService from nitro/servicesservices in core
pi0
approved these changes
Nov 3, 2026
…ces` Top-level `services` option (`vite.services` alias), core entry-server detection, server entry check, default ssr renderer, one services virtual module and `fetchService()` (`fetchViteEnv()` is an alias).
pi0x
force-pushed
the
feat/core-services
branch
from
November 3, 2026 17:31
bafb14e to
65f68d3
Compare
pi0
approved these changes
Nov 3, 2026
This was referenced Nov 3, 2026
2 of 8 tasks
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Implements the core part of #5015 (additive, no breaking change for
nitro/vite).Config
servicesoption ({ [name]: { entry } }), resolved in core (src/config/resolvers/services.ts).vite.servicesis a deprecated alias (top-level wins), merged by the Vite plugin after modules ran (a module can still change it, as onmain).rootDir/scanDirs; bare specifiers are left to the builder (environment conditions apply). The Vite plugin resolves again after modules ran. Inlinevite.servicesoverrideservicesof the config file, with or without a provided instance (nitro build). A service withoutentrythrows an explicit error.entry-serverdetection, the server entry vsssrentry check and the defaultssrrenderer move to core (src/build/services.ts). Vite calls them and registers auto-detected server environments back intonitro.options.services.Integration contract
nitro._serviceLoader(name)(internal) to report how each service output is loaded:{ import }(lazy import, bundled in production) or{ expression }(evaluated per fetch, e.g. the Vite dev worker global).#nitro/virtual/servicesmodule (replaces#nitro/virtual/vite-services). Without a loader, it is empty, and the build warns at start that the services are ignored (not again for the prerenderer).<!--ssr-outlet-->with thessrservice and addsfetchServiceto the template context when services are loaded (_pageTemplate.fetchServiceis removed). The prerenderer getsservicesand the loader.Runtime
fetchService(name, input, init?)fromnitro/services.fetchViteEnv()fromnitro/vite/runtimeis now a deprecated alias (ViteServiceConfigtype too). The default SSR handler moves tointernal/routes/ssr-renderer.Notes
servicesconfig andnitro/servicesin the utils reference.nitro/rsbuild(feat: experimentalnitro/rsbuildplugin #5011) can mapservicesto its environments and set_serviceLoaderinstead of addingfetchRsbuildEnv().Service "x" entry ...(wasVite service "x" ...).Tests
test/unit/services.test.ts(fromvite-services.test.ts): import + expression loaders, empty without a loader.test/unit/services-config.test.ts: path vs bare entries, missingentryerror, alias not merged in core.asset-url-fixtureuses top-levelservices+fetchService;ssr-outletchecksfetchServicein the template context (dev, build, prerender);plugin-optionschecks top-levelserviceson a provided instance, services added or overridden by modules (alsovite.services) and inline vs config precedence.test/vite,test/unitandpnpm test:rolldownpass locally.🤖 Generated with AI assistant