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

Function createIsExternal

packages/vite/src/node/external.ts:127–147  ·  view source on GitHub ↗
(
  environment: Environment,
)

Source from the content-addressed store, hash-verified

125}
126
127function createIsExternal(
128 environment: Environment,
129): (id: string, importer?: string) => boolean {
130 const processedIds = new Map<string, boolean>()
131
132 const isConfiguredAsExternal = createIsConfiguredAsExternal(environment)
133
134 return (id: string, importer?: string) => {
135 if (processedIds.has(id)) {
136 return processedIds.get(id)!
137 }
138 let isExternal = false
139 if (id[0] !== '.' && !path.isAbsolute(id)) {
140 isExternal =
141 isBuiltin(environment.config.resolve.builtins, id) ||
142 isConfiguredAsExternal(id, importer)
143 }
144 processedIds.set(id, isExternal)
145 return isExternal
146 }
147}
148
149export function canExternalizeFile(filePath: string): boolean {
150 const ext = path.extname(filePath)

Callers 1

shouldExternalizeFunction · 0.70

Calls 5

isBuiltinFunction · 0.90
hasMethod · 0.80
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected