MCPcopy
hub / github.com/unplugin/unplugin-vue-components / transformComponent

Function transformComponent

src/core/transforms/component.ts:37–56  ·  view source on GitHub ↗
(code: string, s: MagicString, ctx: Context, sfcPath: string)

Source from the content-addressed store, hash-verified

35}
36
37export default async function transformComponent(code: string, s: MagicString, ctx: Context, sfcPath: string) {
38 let no = 0
39
40 const results = resolveVue3(code, s, ctx.options.transformerUserResolveFunctions)
41
42 for (const { rawName, replace } of results) {
43 debug(`| ${rawName}`)
44 const name = pascalCase(rawName)
45 ctx.updateUsageMap(sfcPath, [name])
46 const component = await ctx.findComponent(name, 'component', [sfcPath])
47 if (component) {
48 const varName = `__unplugin_components_${no}`
49 s.prepend(`${stringifyComponentImport({ ...component, as: varName }, ctx)};\n`)
50 no += 1
51 replace(varName)
52 }
53 }
54
55 debug(`^ (${no})`)
56}

Callers 1

transformerFunction · 0.85

Calls 5

pascalCaseFunction · 0.90
stringifyComponentImportFunction · 0.90
updateUsageMapMethod · 0.80
findComponentMethod · 0.80
resolveVue3Function · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…