Repository navigation
feat: install unstorage, db0 and ocache on demand - #4764
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... ⚙️ Run configuration
⛔ Files ignored due to path filters: 1
📒 Files selected for processing: 39
✨ 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: |
`unstorage` and `db0` are no longer dependencies of nitro. They are resolved from the project and installed on demand when kv mounts, `cache.driver: "kv"` or `experimental.database` are configured, or when `nitro/kv`, `nitro/storage` or `nitro/database` is imported.
- version check now covers prerelease (`^2.0.0-rc.24`) and `0.x` (`^0.4.1`) ranges, which skipped `unenv`, `unstorage` and `db0` before - one missing dependency error with a versioned install command (unenv's hint installed unenv v1) - unenv plugin no longer memoizes the install result, so `nitro dev` recovers after a manual install - do not log a successful install when the package is still not resolvable
pi0x
force-pushed
the
feat/optional-dbkv
branch
from
October 12, 2026 04:59
75c8095 to
4c2db98
Compare
Only resolved (and installed without prompting) once `nitro/cache` or `cache` route rules are used.
unstorage and db0 on demandunstorage, db0 and ocache on demand
pi0
marked this pull request as ready for review
October 18, 2026 02:06
# Conflicts: # package.json # pnpm-lock.yaml # src/runtime/meta.ts
pi0
approved these changes
Oct 18, 2026
pi0
left a comment
Member
There was a problem hiding this comment.
Merging to experience effect e2e. if too much downsides, we will add back default deps as they are fairly small.
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.
unstorage,db0andocacheare no longer dependencies of Nitro. They are resolved from the project and installed on demand, without prompting, likeunenvnow (ensureDepwith the newautoInstalloption; never in test mode), only when used:unstoragedb0ocachekvmounts (or deprecatedstorage/devStorage)experimental.databasecache.driver: "kv"(explicit or inferred from acachemount)nitro/kv,nitro/storagenitro/databasenitro/cachecache/swrrules (headers,redirect, ... do not import it)Apps using none of these never resolve or install them.
Changes
src/utils/storage.ts,src/utils/database.ts). The kv and database virtual templates are now async.nitro:runtime-depsplugin (src/build/plugins/runtime-deps.ts) catchesunstorage*/db0*/ocache*imports from Nitro runtime and virtual modules, ensures the package is installed and resolves it from the project. Used by rollup, rolldown and Vite; Vite dev no longer externalizes them.builder: falsegets an env-runnerfallbackresolver.ensureDep: concurrent calls share one prompt/install. It no longer trusts exsolve's cached failed lookups, which previously caused repeated installs and, with nitro outside the project (pnpm global store,npm link), a build that exited 0 withunstorageleft unresolved.isDepInstalleduses the same lookup, and the version check runs once per package.unenvon-demand install:missingDepError). unenv's previous hint (npx nypm add -D unenv) installed unenv v1.^2.0.0-rc.24) and0.x(^0.4.1) ranges. Before, it skippedunenv,unstorageanddb0entirely.nitro devpicks up a manual install without a restart.OptionalDepType, andPartialfor the cache defaults);.d.mtsimports are@ts-ignored viaoptionalTypeDeps. Inlineimport("ocache")types became named type imports, which the.d.mtsstep requires.server-assetsinlinesnormalizeKey.runtimeDependencies(nitro/meta) no longer listsunstorage/db0/ocache. Nuxt reads this list and already addsunstorageitself, sodb0andocachedrop out of itsoptimizeDeps.exclude.Tests
test/unit/build-runtime-deps.test.ts: each trigger on rollup and rolldown, "not used" builds, missing-package error, no uncached lookups, and a source guard against build-time value imports.test/unit/dep.test.ts: install once, recover after a failed or manual install, concurrent calls share one install, cached lookups, version checked once./kvroute and a direct test of the fallback resolver.npm: one install per package and a working build output, on both builders (forocache: adefineCachedFunctionapp installs it once and the built server serves the cached value).🤖 Generated with AI assistant