external.ts — vite Source File
Architecture documentation for external.ts, a typescript file in the vite codebase. 13 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR b64390ad_e6bf_4b1e_f7f0_39d49791e7e0["external.ts"] dcff87b0_a8ea_57a2_3b29_a7b8f19986f3["resolve.ts"] b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 --> dcff87b0_a8ea_57a2_3b29_a7b8f19986f3 3b063797_1fb9_a959_f5c1_af0fc226ed57["InternalResolveOptions"] b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 --> 3b063797_1fb9_a959_f5c1_af0fc226ed57 310b19b4_2716_b45b_716d_edfca3064152["tryNodeResolve"] b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 --> 310b19b4_2716_b45b_716d_edfca3064152 031bc221_67a8_c579_f2bf_bb30a08beeb2["utils.ts"] b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 --> 031bc221_67a8_c579_f2bf_bb30a08beeb2 23a2e685_f919_9578_27ba_bde71c122058["createDebugger"] b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 --> 23a2e685_f919_9578_27ba_bde71c122058 cb293321_1174_554d_b5ce_f153b06a2fb4["getNpmPackageName"] b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 --> cb293321_1174_554d_b5ce_f153b06a2fb4 5d2580c9_3b65_7396_afe1_ab2aa13f8ed9["isBuiltin"] b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 --> 5d2580c9_3b65_7396_afe1_ab2aa13f8ed9 50ac7e51_9f94_e985_bfec_ae95273b23b0["isInNodeModules"] b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 --> 50ac7e51_9f94_e985_bfec_ae95273b23b0 0c33ff62_54e9_5c90_902b_b26728e71fca["environment.ts"] b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 --> 0c33ff62_54e9_5c90_902b_b26728e71fca 7e6f7c83_3515_4e0d_5362_4eb9515b4a86["Environment"] b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 --> 7e6f7c83_3515_4e0d_5362_4eb9515b4a86 84057c57_14eb_2f16_cd5c_1899e8da6db0["baseEnvironment.ts"] b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 --> 84057c57_14eb_2f16_cd5c_1899e8da6db0 dc928824_33f2_0b61_b231_90d8800b77a5["PartialEnvironment"] b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 --> dc928824_33f2_0b61_b231_90d8800b77a5 51e96894_3556_ed5c_1ede_97d449867adf["node:path"] b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 --> 51e96894_3556_ed5c_1ede_97d449867adf 35b0e4f0_6e49_5afb_03d5_4d5a2f9632c2["external.spec.ts"] 35b0e4f0_6e49_5afb_03d5_4d5a2f9632c2 --> b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 style b64390ad_e6bf_4b1e_f7f0_39d49791e7e0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import path from 'node:path'
import type { InternalResolveOptions } from './plugins/resolve'
import { tryNodeResolve } from './plugins/resolve'
import {
bareImportRE,
createDebugger,
createFilter,
getNpmPackageName,
isBuiltin,
isInNodeModules,
} from './utils'
import type { Environment } from './environment'
import type { PartialEnvironment } from './baseEnvironment'
const debug = createDebugger('vite:external')
const isExternalCache = new WeakMap<
Environment,
(id: string, importer?: string) => boolean
>()
export function shouldExternalize(
environment: Environment,
id: string,
importer: string | undefined,
): boolean {
let isExternal = isExternalCache.get(environment)
if (!isExternal) {
isExternal = createIsExternal(environment)
isExternalCache.set(environment, isExternal)
}
return isExternal(id, importer)
}
export function createIsConfiguredAsExternal(
environment: PartialEnvironment,
): (id: string, importer?: string) => boolean {
const { config } = environment
const { root, resolve } = config
const { external, noExternal } = resolve
const noExternalFilter =
typeof noExternal !== 'boolean' &&
!(Array.isArray(noExternal) && noExternal.length === 0) &&
createFilter(undefined, noExternal, { resolve: false })
const targetConditions = resolve.externalConditions
const resolveOptions: InternalResolveOptions = {
...resolve,
root,
isProduction: false,
isBuild: true,
conditions: targetConditions,
}
const isExternalizable = (
id: string,
importer: string | undefined,
configuredAsExternal: boolean,
): boolean => {
// ... (94 more lines)
Domain
Subdomains
Functions
Dependencies
Imported By
Source
Frequently Asked Questions
What does external.ts do?
external.ts is a source file in the vite codebase, written in typescript. It belongs to the ViteCore domain, ConfigEngine subdomain.
What functions are defined in external.ts?
external.ts defines 5 function(s): canExternalizeFile, createIsConfiguredAsExternal, createIsExternal, id, shouldExternalize.
What does external.ts depend on?
external.ts imports 13 module(s): Environment, InternalResolveOptions, PartialEnvironment, baseEnvironment.ts, createDebugger, environment.ts, getNpmPackageName, isBuiltin, and 5 more.
What files import external.ts?
external.ts is imported by 3 file(s): external.spec.ts, importAnalysis.ts, resolve.ts.
Where is external.ts in the architecture?
external.ts is located at packages/vite/src/node/external.ts (domain: ViteCore, subdomain: ConfigEngine, directory: packages/vite/src/node).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free