MCPcopy
hub / github.com/vuejs/core / genAssets

Function genAssets

packages/compiler-core/src/codegen.ts:537–565  ·  packages/compiler-core/src/codegen.ts::genAssets
(
  assets: string[],
  type: 'component' | 'directive' | 'filter',
  { helper, push, newline, isTS }: CodegenContext,
)

Source from the content-addressed store, hash-verified

535}
536
537function genAssets(
538 assets: string[],
539 type: class="st">'component' | class="st">'directive' | class="st">'filter',
540 { helper, push, newline, isTS }: CodegenContext,
541) {
542 const resolver = helper(
543 __COMPAT__ && type === class="st">'filter'
544 ? RESOLVE_FILTER
545 : type === class="st">'component'
546 ? RESOLVE_COMPONENT
547 : RESOLVE_DIRECTIVE,
548 )
549 for (let i = 0; i < assets.length; i++) {
550 let id = assets[i]
551 class="cm">// potential component implicit self-reference inferred from SFC filename
552 const maybeSelfReference = id.endsWith(class="st">'__self')
553 if (maybeSelfReference) {
554 id = id.slice(0, -6)
555 }
556 push(
557 `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${
558 maybeSelfReference ? `, true` : ``
559 })${isTS ? `!` : ``}`,
560 )
561 if (i < assets.length - 1) {
562 newline()
563 }
564 }
565}
566
567function genHoists(hoists: (JSChildNode | null)[], context: CodegenContext) {
568 if (!hoists.length) {

Callers 1

generateFunction · 0.85

Calls 4

toValidAssetIdFunction · 0.90
newlineFunction · 0.85
helperFunction · 0.70
pushFunction · 0.70

Tested by

no test coverage detected