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.

Entity Profile

Dependency Diagram

graph LR
  e4b641cd_cedf_fcbc_ccab_c4e184e0c140["compileScript.spec.ts"]
  1502a238_61f0_9afa_8c3c_71d2bb769820["types.ts"]
  e4b641cd_cedf_fcbc_ccab_c4e184e0c140 --> 1502a238_61f0_9afa_8c3c_71d2bb769820
  8fa13167_5ac7_0658_5752_38b3ee82910e["BindingTypes"]
  e4b641cd_cedf_fcbc_ccab_c4e184e0c140 --> 8fa13167_5ac7_0658_5752_38b3ee82910e
  240d4660_83b3_21e3_5187_23f87cd014f3["util.ts"]
  e4b641cd_cedf_fcbc_ccab_c4e184e0c140 --> 240d4660_83b3_21e3_5187_23f87cd014f3
  2e09cab7_5684_9a0b_b161_afdce66d44af["compile"]
  e4b641cd_cedf_fcbc_ccab_c4e184e0c140 --> 2e09cab7_5684_9a0b_b161_afdce66d44af
  eafc4e76_89fd_2cf1_2320_f0d7b65a3c8f["assertCode"]
  e4b641cd_cedf_fcbc_ccab_c4e184e0c140 --> eafc4e76_89fd_2cf1_2320_f0d7b65a3c8f
  style e4b641cd_cedf_fcbc_ccab_c4e184e0c140 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 CompilerSFC 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: CompilerSFC, 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