Repository navigation
feat: on-demand dependency manifest and deps option - #4839
Merged
Merged
Conversation
Supported ranges, reasons and install defaults of optional dependencies now live in `src/utils/_deps.ts`. Shims declare their own range within the one of the bundled library.
|
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... ⚙️ Run configuration
📒 Files selected for processing: 44
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
Frameworks built on Nitro can pass their own copies of on-demand dependencies (e.g. `unstorage`, `db0`, `ocache`), generalizing `vite.path` (now an alias of `deps.vite`).
deps option
- check the version of explicit `vite` and `rolldown` paths - resolve packages without `exports` from their explicit path only - do not pass `paths` for deps the bundle imports by name (azure, vercel) - honour `deps.paths` when loading oxc from `rolldown` - ignore `undefined` options when applying manifest defaults - warn when `vite.path` and `deps.paths.vite` differ
`pnpm sync-deps` updates the supported ranges (including shims) once the tested `devDependencies` versions are out of them, and runs as part of `scripts/update-deps.ts`.
pi0
approved these changes
Oct 18, 2026
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.
Optional dependencies installed on demand were configured at each call site: ranges were duplicated (
rollup ^4andvite ^8twice, azure^4hard-coded in error messages), some had no range at all, andbuild.config.tskept its own hand-written lists.This moves them into one manifest,
deps.jsonat the repo root (typed and exported bysrc/utils/_deps.ts). Each entry has its supportedversionrange,reasonand install defaults (dev,autoInstall,projectOnly), plusruntimeandtypesflags.ensureDep/importDep/missingDepErrorapply the manifest defaults, so call sites are justimportDep({ id, dir }).importDepalso infers the module type from theid(DepModulesin the manifest), so call sites no longer pass<typeof import("…")>. A call can still overridereason(unenv and thekv/databaseconfig do).build.config.tsbuildsoptionalDeps(externals) andoptionalTypeDepsfrom the manifest, andshimmedDepsfrom the files insrc/shims/.runtime-deps.tsbuilds its list of runtime deps from the manifest (runtime: true).@vercel/queue ^0.8.0andzephyr-agent ^1.6.0(taken from the versions we test with).New
depsoptionFrameworks built on Nitro (e.g. Nuxt) can pass their own copies of on-demand dependencies by package name, generalizing
vite.path:file://URL to the package directory or entry (same format asvite.path). The resolver behindvite.pathmoved tosrc/utils/_dep-path.ts, so it now works for any package and its subpaths.ensureDep/importDep/resolveDeptakepaths(call sites passnitro.options.deps?.paths). A package with an explicit path is never installed. Its version is still checked against the manifest range, and a path that isn't the package throws.unstorage,db0,ocache,unenv) are bundled from the explicit path.rolldownusesdeps.paths.rolldown, then falls back to resolving throughdeps.paths.vite.viteandrolldownpaths go through the same version check. The oxc loader (src/utils/oxc.ts) uses the explicitrolldown/vitetoo.exports(e.g.xml2js) are resolved from their own directory (main, subpaths), and a path never falls back to another copy found next to it.vite.pathanddeps.paths.viteare aliases (synced in the newresolveDepsOptionsresolver). If both are set to different values,deps.paths.vitewins with a warning.depsis a namespace, so related options (e.g. a resolve root or install mode) can be added next topathslater.c12shims (they load before the config exists), the third-party driver/connector libraries, and@azure/functions/@vercel/queue(the app bundle imports these by name from the project).Shims (
dotenv,giget,jiti) are not on-demand deps of Nitro itself, because their range is set by the bundled library (c12). Their ranges live in a separateshimssection ofdeps.json, next to thelibrarythey belong to:dotenv ^16 || ^17 || ^18andgiget ^3.1.0are new.Syncing ranges (
pnpm sync-deps)scripts/sync-deps.tsupdates adeps.jsonrange only once the testeddevDependenciesversion falls outside it (for example, a Renovate major bump). It keeps the range's precision (^8→^9,^0.8.0→^0.9.2) and adds a new major to||ranges (^16 || ^17 || ^18→… || ^19). It refuses a shim range thatc12's peer range doesn't accept, and a tested version lower than the range. It also runs fromscripts/update-deps.ts, and the manifest unit test's failure message points to it.Tests:
test/unit/deps.test.tschecks that:devDependenciesversion we test withc12's peer range and covers the tested versionimportDepinfers module types andvite.path/deps.paths.vitestay in syncdep.test.tscovers resolving from explicit paths (directory, entry,file://, subpaths), the version check and a wrong path.build-runtime-deps.test.tsbuilds withdeps.paths.ocachepointing to a marked copy and checks that the bundle uses it.Build output change:
@azure/functionsused to be bundled intodist/runtime/_chunks/libs/@azure/functions.mjs(~77 kB), even though the azure preset requires it in the project and adds it totraceDeps. It is now external, like the other manifest entries. Apart from import order, it's the only change indist; the.d.mtsfiles are identical.Not included yet: the update check (recommending or prompting for upgrades). The manifest is where a minimum-recommended version would go.
To review: the new ranges for
@vercel/queue(^0.8.0),zephyr-agent(^1.6.0),giget(^3.1.0) anddotenv(^16 || ^17 || ^18). Users with an installed version outside them will now see a "please update" warning, and on-demand installs of@vercel/queuenow pin^0.8.0. Also,db0required by the unstoragedb0driver now installs without prompting (manifest default), likedb0fornitro/database.🤖 Generated with AI assistant