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

Function getNpmPackageName

packages/vite/src/node/utils.ts:1684–1692  ·  view source on GitHub ↗
(importPath: string)

Source from the content-addressed store, hash-verified

1682}
1683
1684export function getNpmPackageName(importPath: string): string | null {
1685 const parts = importPath.split('/')
1686 if (parts[0][0] === '@') {
1687 if (!parts[1]) return null
1688 return `${parts[0]}/${parts[1]}`
1689 } else {
1690 return parts[0]
1691 }
1692}
1693
1694export function getPkgName(name: string): string | undefined {
1695 return name[0] === '@' ? name.split('/')[1] : name

Callers 4

tryNodeResolveFunction · 0.90
tryOptimizedResolveFunction · 0.90
expandGlobIdsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected