useRuntimeDependencies #
Declares the packages that a plugin imports from its runtime code, so both module graphs resolve them from the plugin's own installation instead of from the site root.
Usage #
Parameters
The Vite config that the vite() handler received.
The package that owns the dependencies, usually the plugin itself.
Names of the packages the plugin imports from its runtime code.
Notes #
Sites usually install a preset or kawapress, not every package a plugin uses, so a nested dependency cannot be imported by name from the site root. The declaration therefore names the package that owns the dependency and the helper derives the packages that lead from the site to it. Vite's optimizer expects that path as an owner > dependency chain.
Call it from the vite() handler: the client dependency optimizer then pre-bundles these packages before the first request instead of discovering them after it and reloading the page, and the SSR build bundles them so Node never loads a second copy of Vue from node_modules.
import { useRuntimeDependencies } from 'kawapress/generator'
api.vite((config) => {
useRuntimeDependencies(config, '@your-scope/plugin-name', ['some-browser-lib'])
})Full type signature
function useRuntimeDependencies(config: UserConfig, owner: string, dependencies: readonly string[]): void

Comments