codegen.ts — vue Source File
Architecture documentation for codegen.ts, a typescript file in the vue codebase. 11 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR 4aaa14b9_d580_5a66_5221_1be3a11a7eed["codegen.ts"] 92853cf6_4176_f03f_0670_cca3d63c003e["modules.ts"] 4aaa14b9_d580_5a66_5221_1be3a11a7eed --> 92853cf6_4176_f03f_0670_cca3d63c003e 386cc8d1_c4ff_6f53_715a_0c93b8a6e747["genAttrSegments"] 4aaa14b9_d580_5a66_5221_1be3a11a7eed --> 386cc8d1_c4ff_6f53_715a_0c93b8a6e747 1d03c177_581d_f577_3b0a_ad1fbb6de4ba["genDOMPropSegments"] 4aaa14b9_d580_5a66_5221_1be3a11a7eed --> 1d03c177_581d_f577_3b0a_ad1fbb6de4ba 19897393_a1e2_9221_0e22_5928060eae7c["genClassSegments"] 4aaa14b9_d580_5a66_5221_1be3a11a7eed --> 19897393_a1e2_9221_0e22_5928060eae7c 937b9b26_216a_5f69_4ceb_50dd83cad375["genStyleSegments"] 4aaa14b9_d580_5a66_5221_1be3a11a7eed --> 937b9b26_216a_5f69_4ceb_50dd83cad375 baadd20a_b2eb_ce31_b2fe_7fcd14819897["applyModelTransform"] 4aaa14b9_d580_5a66_5221_1be3a11a7eed --> baadd20a_b2eb_ce31_b2fe_7fcd14819897 89eacf5c_deee_e42e_d519_69cb05e48e63["util.ts"] 4aaa14b9_d580_5a66_5221_1be3a11a7eed --> 89eacf5c_deee_e42e_d519_69cb05e48e63 4e8211dc_aa7e_481a_3002_b46e9e8afd4e["escape"] 4aaa14b9_d580_5a66_5221_1be3a11a7eed --> 4e8211dc_aa7e_481a_3002_b46e9e8afd4e b7ef6faa_d112_ca70_98b8_d353bda5bfe0["optimizer.ts"] 4aaa14b9_d580_5a66_5221_1be3a11a7eed --> b7ef6faa_d112_ca70_98b8_d353bda5bfe0 e07318ce_1584_4c80_9350_b88731fb2da0["index"] 4aaa14b9_d580_5a66_5221_1be3a11a7eed --> e07318ce_1584_4c80_9350_b88731fb2da0 a80b8e3b_d720_9146_3bf6_594d4ee5dd77["compiler"] 4aaa14b9_d580_5a66_5221_1be3a11a7eed --> a80b8e3b_d720_9146_3bf6_594d4ee5dd77 e5f97d41_92da_796a_60c6_a76258977cea["index.ts"] e5f97d41_92da_796a_60c6_a76258977cea --> 4aaa14b9_d580_5a66_5221_1be3a11a7eed 92853cf6_4176_f03f_0670_cca3d63c003e["modules.ts"] 92853cf6_4176_f03f_0670_cca3d63c003e --> 4aaa14b9_d580_5a66_5221_1be3a11a7eed style 4aaa14b9_d580_5a66_5221_1be3a11a7eed fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// The SSR codegen is essentially extending the default codegen to handle
// SSR-optimizable nodes and turn them into string render fns. In cases where
// a node is not optimizable it simply falls back to the default codegen.
import {
genIf,
genFor,
genData,
genText,
genElement,
genChildren,
CodegenState
} from 'compiler/codegen/index'
import {
genAttrSegments,
genDOMPropSegments,
genClassSegments,
genStyleSegments,
applyModelTransform
} from './modules'
import { escape } from '../util'
import { optimizability } from './optimizer'
import type { CodegenResult } from 'compiler/codegen/index'
import { ASTElement, ASTNode, CompilerOptions } from 'types/compiler'
export type StringSegment = {
type: number
value: string
}
// segment types
export const RAW = 0
export const INTERPOLATION = 1
export const EXPRESSION = 2
export function generate(
ast: ASTElement | void,
options: CompilerOptions
): CodegenResult {
const state = new CodegenState(options)
const code = ast ? genSSRElement(ast, state) : '_c("div")'
return {
render: `with(this){return ${code}}`,
staticRenderFns: state.staticRenderFns
}
}
function genSSRElement(el: ASTElement, state: CodegenState): string {
if (el.for && !el.forProcessed) {
return genFor(el, state, genSSRElement)
} else if (el.if && !el.ifProcessed) {
return genIf(el, state, genSSRElement)
} else if (el.tag === 'template' && !el.slotTarget) {
return el.ssrOptimizability === optimizability.FULL
? genChildrenAsStringNode(el, state)
: genSSRChildren(el, state) || 'void 0'
}
// ... (201 more lines)
Domain
Subdomains
Functions
Types
Dependencies
Imported By
Source
Frequently Asked Questions
What does codegen.ts do?
codegen.ts is a source file in the vue codebase, written in typescript. It belongs to the ServerRenderer domain, BundleRenderer subdomain.
What functions are defined in codegen.ts?
codegen.ts defines 14 function(s): childrenToSegments, elementToOpenTagSegments, elementToSegments, elementToString, flattenSegments, genChildrenAsStringNode, genNormalElement, genSSRChildren, genSSRElement, genSSRNode, and 4 more.
What does codegen.ts depend on?
codegen.ts imports 11 module(s): applyModelTransform, compiler, escape, genAttrSegments, genClassSegments, genDOMPropSegments, genStyleSegments, index, and 3 more.
What files import codegen.ts?
codegen.ts is imported by 2 file(s): index.ts, modules.ts.
Where is codegen.ts in the architecture?
codegen.ts is located at packages/server-renderer/src/optimizing-compiler/codegen.ts (domain: ServerRenderer, subdomain: BundleRenderer, directory: packages/server-renderer/src/optimizing-compiler).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free