Home / File/ compileScript.spec.ts — vue Source File

compileScript.spec.ts — vue Source File

Architecture documentation for compileScript.spec.ts, a typescript file in the vue codebase. 5 imports, 0 dependents.

File typescript VueCore 5 imports

Entity Profile

Dependency Diagram

graph LR
  e91c3191_e713_5a24_f1a5_0b0a82abbda9["compileScript.spec.ts"]
  1a27e6b3_7515_332e_8d02_d958c72a568c["types.ts"]
  e91c3191_e713_5a24_f1a5_0b0a82abbda9 --> 1a27e6b3_7515_332e_8d02_d958c72a568c
  fd729ff9_ab37_2b0a_f764_780a95167427["BindingTypes"]
  e91c3191_e713_5a24_f1a5_0b0a82abbda9 --> fd729ff9_ab37_2b0a_f764_780a95167427
  6d6bc116_08b7_aba4_746f_b6a4c1096a7f["util.ts"]
  e91c3191_e713_5a24_f1a5_0b0a82abbda9 --> 6d6bc116_08b7_aba4_746f_b6a4c1096a7f
  af8cc907_eee9_5cc2_ae25_acd9ed4278cf["compile"]
  e91c3191_e713_5a24_f1a5_0b0a82abbda9 --> af8cc907_eee9_5cc2_ae25_acd9ed4278cf
  8867eb91_50d2_a122_a5c3_e8fe547b1016["assertCode"]
  e91c3191_e713_5a24_f1a5_0b0a82abbda9 --> 8867eb91_50d2_a122_a5c3_e8fe547b1016
  style e91c3191_e713_5a24_f1a5_0b0a82abbda9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { BindingTypes } from '../src/types'
import { compile, assertCode } from './util'

describe('SFC compile <script setup>', () => {
  test('should expose top level declarations', () => {
    const { content, bindings } = compile(`
      <script setup>
      import { x } from './x'
      let a = 1
      const b = 2
      function c() {}
      class d {}
      </script>

      <script>
      import { xx } from './x'
      let aa = 1
      const bb = 2
      function cc() {}
      class dd {}
      </script>
      `)
    expect(content).toMatch('return { aa, bb, cc, dd, a, b, c, d, xx, x }')
    expect(bindings).toStrictEqual({
      x: BindingTypes.SETUP_MAYBE_REF,
      a: BindingTypes.SETUP_LET,
      b: BindingTypes.SETUP_CONST,
      c: BindingTypes.SETUP_CONST,
      d: BindingTypes.SETUP_CONST,
      xx: BindingTypes.SETUP_MAYBE_REF,
      aa: BindingTypes.SETUP_LET,
      bb: BindingTypes.SETUP_CONST,
      cc: BindingTypes.SETUP_CONST,
      dd: BindingTypes.SETUP_CONST
    })
    assertCode(content)
  })

  test('binding analysis for destructure', () => {
    const { content, bindings } = compile(`
      <script setup>
      const { foo, b: bar, ['x' + 'y']: baz, x: { y, zz: { z }}} = {}
      </script>
      `)
    expect(content).toMatch('return { foo, bar, baz, y, z }')
    expect(bindings).toStrictEqual({
      foo: BindingTypes.SETUP_MAYBE_REF,
      bar: BindingTypes.SETUP_MAYBE_REF,
      baz: BindingTypes.SETUP_MAYBE_REF,
      y: BindingTypes.SETUP_MAYBE_REF,
      z: BindingTypes.SETUP_MAYBE_REF
    })
    assertCode(content)
  })

  test('defineProps()', () => {
    const { content, bindings } = compile(`
<script setup>
const props = defineProps({
  foo: String
// ... (1576 more lines)

Domain

Frequently Asked Questions

What does compileScript.spec.ts do?
compileScript.spec.ts is a source file in the vue codebase, written in typescript. It belongs to the VueCore domain.
What does compileScript.spec.ts depend on?
compileScript.spec.ts imports 5 module(s): BindingTypes, assertCode, compile, types.ts, util.ts.
Where is compileScript.spec.ts in the architecture?
compileScript.spec.ts is located at packages/compiler-sfc/test/compileScript.spec.ts (domain: VueCore, directory: packages/compiler-sfc/test).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free