prefixIdentifiers() — vue Function Reference
Architecture documentation for the prefixIdentifiers() function in prefixIdentifiers.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD daf5feaa_5661_e63c_80fa_09f5265e529c["prefixIdentifiers()"] d97c3715_d6ea_cb5a_f615_2a6156a68d87["actuallyCompile()"] d97c3715_d6ea_cb5a_f615_2a6156a68d87 -->|calls| daf5feaa_5661_e63c_80fa_09f5265e529c 0619d942_1d45_256a_46da_d12186658236["genCssVarsCode()"] 0619d942_1d45_256a_46da_d12186658236 -->|calls| daf5feaa_5661_e63c_80fa_09f5265e529c 89db3100_db23_2ba5_52ae_1299b220043a["walkIdentifiers()"] daf5feaa_5661_e63c_80fa_09f5265e529c -->|calls| 89db3100_db23_2ba5_52ae_1299b220043a b2fae490_d4f1_9ca2_c2d6_72ee9198f4bc["isStaticProperty()"] daf5feaa_5661_e63c_80fa_09f5265e529c -->|calls| b2fae490_d4f1_9ca2_c2d6_72ee9198f4bc 5670215c_12e8_f1ac_96f5_43fa02f28d30["remove()"] daf5feaa_5661_e63c_80fa_09f5265e529c -->|calls| 5670215c_12e8_f1ac_96f5_43fa02f28d30 bb53260c_b91e_4c53_9052_5970ccb57525["toString()"] daf5feaa_5661_e63c_80fa_09f5265e529c -->|calls| bb53260c_b91e_4c53_9052_5970ccb57525 style daf5feaa_5661_e63c_80fa_09f5265e529c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/compiler-sfc/src/prefixIdentifiers.ts lines 19–82
export function prefixIdentifiers(
source: string,
isFunctional = false,
isTS = false,
babelOptions: ParserOptions = {},
bindings?: BindingMetadata
) {
const s = new MagicString(source)
const plugins: ParserPlugin[] = [
...(isTS ? (['typescript'] as const) : []),
...(babelOptions?.plugins || [])
]
const ast = parseExpression(source, {
...babelOptions,
plugins
})
const isScriptSetup = bindings && bindings.__isScriptSetup !== false
walkIdentifiers(
ast,
(ident, parent) => {
const { name } = ident
if (doNotPrefix(name)) {
return
}
let prefix = `_vm.`
if (isScriptSetup) {
const type = bindings[name]
if (type && type.startsWith('setup')) {
prefix = `_setup.`
}
}
if (isStaticProperty(parent) && parent.shorthand) {
// property shorthand like { foo }, we need to add the key since
// we rewrite the value
// { foo } -> { foo: _vm.foo }
s.appendLeft(ident.end!, `: ${prefix}${name}`)
} else {
s.prependRight(ident.start!, prefix)
}
},
node => {
if (node.type === 'WithStatement') {
s.remove(node.start!, node.body.start! + 1)
s.remove(node.end! - 1, node.end!)
if (!isFunctional) {
s.prependRight(
node.start!,
`var _vm=this,_c=_vm._self._c${
isScriptSetup ? `,_setup=_vm._self._setupProxy;` : `;`
}`
)
}
}
}
)
return s.toString()
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does prefixIdentifiers() do?
prefixIdentifiers() is a function in the vue codebase.
What does prefixIdentifiers() call?
prefixIdentifiers() calls 4 function(s): isStaticProperty, remove, toString, walkIdentifiers.
What calls prefixIdentifiers()?
prefixIdentifiers() is called by 2 function(s): actuallyCompile, genCssVarsCode.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free