watchPackageDataPlugin() — vite Function Reference
Architecture documentation for the watchPackageDataPlugin() function in packages.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD 19079986_f2b8_99fb_9d98_03f44722e17c["watchPackageDataPlugin()"] dff9cadb_1e8c_7fc9_4119_a173f1f21cbd["packages.ts"] 19079986_f2b8_99fb_9d98_03f44722e17c -->|defined in| dff9cadb_1e8c_7fc9_4119_a173f1f21cbd b1b40b5b_3e43_2197_dea0_d36389d312a1["resolvePlugins()"] b1b40b5b_3e43_2197_dea0_d36389d312a1 -->|calls| 19079986_f2b8_99fb_9d98_03f44722e17c 50ac7e51_9f94_e985_bfec_ae95273b23b0["isInNodeModules()"] 19079986_f2b8_99fb_9d98_03f44722e17c -->|calls| 50ac7e51_9f94_e985_bfec_ae95273b23b0 1a695de8_b1e7_7895_f74f_336f516de603["invalidatePackageData()"] 19079986_f2b8_99fb_9d98_03f44722e17c -->|calls| 1a695de8_b1e7_7895_f74f_336f516de603 style 19079986_f2b8_99fb_9d98_03f44722e17c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/vite/src/node/packages.ts lines 254–289
export function watchPackageDataPlugin(packageCache: PackageCache): Plugin {
// a list of files to watch before the plugin is ready
const watchQueue = new Set<string>()
const watchedDirs = new Set<string>()
const watchFileStub = (id: string) => {
watchQueue.add(id)
}
let watchFile = watchFileStub
const setPackageData = packageCache.set.bind(packageCache)
packageCache.set = (id, pkg) => {
if (!isInNodeModules(pkg.dir) && !watchedDirs.has(pkg.dir)) {
watchedDirs.add(pkg.dir)
watchFile(path.join(pkg.dir, 'package.json'))
}
return setPackageData(id, pkg)
}
return {
name: 'vite:watch-package-data',
buildStart() {
watchFile = this.addWatchFile.bind(this)
watchQueue.forEach(watchFile)
watchQueue.clear()
},
buildEnd() {
watchFile = watchFileStub
},
watchChange(id) {
if (id.endsWith('/package.json')) {
invalidatePackageData(packageCache, path.normalize(id))
}
},
}
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does watchPackageDataPlugin() do?
watchPackageDataPlugin() is a function in the vite codebase, defined in packages/vite/src/node/packages.ts.
Where is watchPackageDataPlugin() defined?
watchPackageDataPlugin() is defined in packages/vite/src/node/packages.ts at line 254.
What does watchPackageDataPlugin() call?
watchPackageDataPlugin() calls 2 function(s): invalidatePackageData, isInNodeModules.
What calls watchPackageDataPlugin()?
watchPackageDataPlugin() is called by 1 function(s): resolvePlugins.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free