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

index.spec.ts — vite Source File

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

File typescript ViteCore ConfigEngine 4 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  5b8de257_15d5_37a3_6c47_a32e7a9e9038["index.spec.ts"]
  8377ae20_ffba_2f9c_bded_58742b7f1c3b["index.ts"]
  5b8de257_15d5_37a3_6c47_a32e7a9e9038 --> 8377ae20_ffba_2f9c_bded_58742b7f1c3b
  693ca867_249b_3e5a_0ce1_8930413b7fcd["rolldown"]
  5b8de257_15d5_37a3_6c47_a32e7a9e9038 --> 693ca867_249b_3e5a_0ce1_8930413b7fcd
  db4d54eb_be78_e7bb_fac3_7f8913198d1d["filter"]
  5b8de257_15d5_37a3_6c47_a32e7a9e9038 --> db4d54eb_be78_e7bb_fac3_7f8913198d1d
  a340ba46_b2b7_3048_3bb3_6907a74c8464["vitest"]
  5b8de257_15d5_37a3_6c47_a32e7a9e9038 --> a340ba46_b2b7_3048_3bb3_6907a74c8464
  style 5b8de257_15d5_37a3_6c47_a32e7a9e9038 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { RUNTIME_MODULE_ID } from 'rolldown'
import { exactRegex } from 'rolldown/filter'
import { afterAll, describe, expect, test, vi } from 'vitest'
import { type InlineConfig, type Plugin, build, createServer } from '../..'

const getConfigWithPlugin = (
  plugins: Plugin[],
  input?: string[],
): InlineConfig => {
  return {
    configFile: false,
    server: { middlewareMode: true, ws: false },
    optimizeDeps: { noDiscovery: true, include: [] },
    build: { rollupOptions: { input }, write: false },
    plugins,
    logLevel: 'silent',
  }
}

describe('hook filter with plugin container', async () => {
  const resolveId = vi.fn()
  const load = vi.fn()
  const transformWithId = vi.fn()
  const transformWithCode = vi.fn()
  const any = expect.toSatisfy(() => true) // anything including undefined and null
  const config = getConfigWithPlugin([
    {
      name: 'test',
      resolveId: {
        filter: { id: /\.js$/ },
        handler: resolveId,
      },
      load: {
        filter: { id: '**/*.js' },
        handler: load,
      },
      transform: {
        filter: { id: '**/*.js' },
        handler: transformWithId,
      },
    },
    {
      name: 'test2',
      transform: {
        filter: { code: 'import.meta' },
        handler: transformWithCode,
      },
    },
  ])
  const server = await createServer(config)
  afterAll(async () => {
    await server.close()
  })
  const pluginContainer = server.environments.ssr.pluginContainer

  test('resolveId', async () => {
    await pluginContainer.resolveId('foo.js')
    await pluginContainer.resolveId('foo.ts')
    expect(resolveId).toHaveBeenCalledTimes(1)
    expect(resolveId).toHaveBeenCalledWith('foo.js', any, any)
// ... (110 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does index.spec.ts do?
index.spec.ts is a source file in the vite codebase, written in typescript. It belongs to the ViteCore domain, ConfigEngine subdomain.
What functions are defined in index.spec.ts?
index.spec.ts defines 1 function(s): getConfigWithPlugin.
What does index.spec.ts depend on?
index.spec.ts imports 4 module(s): filter, index.ts, rolldown, vitest.
Where is index.spec.ts in the architecture?
index.spec.ts is located at packages/vite/src/node/__tests__/plugins/index.spec.ts (domain: ViteCore, subdomain: ConfigEngine, directory: packages/vite/src/node/__tests__/plugins).

Analyze Your Own Codebase

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

Try Supermodel Free