Home / File/ lib.spec.ts — vite Source File

lib.spec.ts — vite Source File

Architecture documentation for lib.spec.ts, a typescript file in the vite codebase. 2 imports, 0 dependents.

File typescript 2 imports

Entity Profile

Dependency Diagram

graph LR
  ebf927ca_0204_1891_4552_d4f757f36edb["lib.spec.ts"]
  a340ba46_b2b7_3048_3bb3_6907a74c8464["vitest"]
  ebf927ca_0204_1891_4552_d4f757f36edb --> a340ba46_b2b7_3048_3bb3_6907a74c8464
  d3fd5575_295b_d6be_24dd_62d277645dc9["~utils"]
  ebf927ca_0204_1891_4552_d4f757f36edb --> d3fd5575_295b_d6be_24dd_62d277645dc9
  style ebf927ca_0204_1891_4552_d4f757f36edb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { describe, expect, test } from 'vitest'
import { isBuild, isServe, page, readFile, serverLogs } from '~utils'

describe.runIf(isBuild)('build', () => {
  test('es', async () => {
    expect(await page.textContent('.es')).toBe('It works')
  })

  test('umd', async () => {
    expect(await page.textContent('.umd')).toBe('It works')
    const code = readFile('dist/my-lib-custom-filename.umd.cjs')
    const noMinifyCode = readFile(
      'dist/nominify/my-lib-custom-filename.umd.cjs',
    )
    const namedCode = readFile('dist/named/my-lib-named.umd.cjs')
    // esbuild helpers are injected inside of the UMD wrapper
    expect(code).toMatch(/^\/\*[^*]*\*\/\s*\(function\(/)
    expect(noMinifyCode).toMatch(
      /^\/\*[^*]*\*\/\s*\(function\(global.+?function\smyLib\(/s,
    )
    expect(namedCode).toMatch(/^\(function\(/)
  })

  test('iife', async () => {
    expect(await page.textContent('.iife')).toBe('It works')
    const code = readFile('dist/my-lib-custom-filename.iife.js')
    const noMinifyCode = readFile(
      'dist/nominify/my-lib-custom-filename.iife.js',
    )
    const namedCode = readFile('dist/named/my-lib-named.iife.js')
    // esbuild helpers are injected inside of the IIFE wrapper
    expect(code).toMatch(/^\/\*[^*]*\*\/\s*var MyLib=\(function\(\)\{\s*/)
    expect(noMinifyCode).toMatch(
      /^\/\*[^*]*\*\/\s*var MyLib\s*=\s*\(function\(\)\s*\{\s*/,
    )
    expect(namedCode).toMatch(/^var MyLibNamed=\(function\([^()]+\)\{\s*/)
  })

  test('restrisct-helpers-injection', async () => {
    const code = readFile(
      'dist/helpers-injection/my-lib-custom-filename.iife.js',
    )
    expect(code).toMatch(
      `\\"use strict\\"; return (" + expressionSyntax + ").constructor;"`,
    )
  })

  test('Library mode does not include `preload`', async () => {
    await expect
      .poll(() => page.textContent('.dynamic-import-message'))
      .toMatch('hello vite')
    const code = readFile('dist/lib/dynamic-import-message.es.mjs')
    expect(code).not.toMatch('__vitePreload')

    // Test that library chunks are hashed
    expect(code).toMatch(/await import\("\.\/message-[-\w]{8}.js"\)/)
  })

  test('Library mode does not have any reference to pure CSS chunks', async () => {
    const code = readFile('dist/lib/dynamic-import-message.es.mjs')
// ... (82 more lines)

Dependencies

  • vitest
  • ~utils

Frequently Asked Questions

What does lib.spec.ts do?
lib.spec.ts is a source file in the vite codebase, written in typescript.
What does lib.spec.ts depend on?
lib.spec.ts imports 2 module(s): vitest, ~utils.
Where is lib.spec.ts in the architecture?
lib.spec.ts is located at playground/lib/__tests__/lib.spec.ts (directory: playground/lib/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free