MCPcopy
hub / github.com/vitejs/vite / getModuleInfo

Method getModuleInfo

packages/vite/src/node/server/pluginContainer.ts:1204–1240  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

1202 }
1203
1204 getModuleInfo(id: string): ModuleInfo | null {
1205 const clientModuleInfo = (
1206 this.environments.client as DevEnvironment
1207 ).pluginContainer.getModuleInfo(id)
1208 const ssrModuleInfo = (
1209 this.environments.ssr as DevEnvironment
1210 ).pluginContainer.getModuleInfo(id)
1211
1212 if (clientModuleInfo == null && ssrModuleInfo == null) return null
1213
1214 return new Proxy({} as any, {
1215 get: (_, key: string) => {
1216 // `meta` refers to `ModuleInfo.meta` of both environments, so we also
1217 // need to merge it here
1218 if (key === 'meta') {
1219 const meta: Record<string, any> = {}
1220 if (ssrModuleInfo) {
1221 Object.assign(meta, ssrModuleInfo.meta)
1222 }
1223 if (clientModuleInfo) {
1224 Object.assign(meta, clientModuleInfo.meta)
1225 }
1226 return meta
1227 }
1228 if (clientModuleInfo) {
1229 if (key in clientModuleInfo) {
1230 return clientModuleInfo[key as keyof ModuleInfo]
1231 }
1232 }
1233 if (ssrModuleInfo) {
1234 if (key in ssrModuleInfo) {
1235 return ssrModuleInfo[key as keyof ModuleInfo]
1236 }
1237 }
1238 },
1239 })
1240 }
1241
1242 get options(): InputOptions {
1243 return (this.environments.client as DevEnvironment).pluginContainer.options

Callers

nothing calls this directly

Calls 1

getModuleInfoMethod · 0.45

Tested by

no test coverage detected