Home / File/ pluginFilter.ts — vite Source File

pluginFilter.ts — vite Source File

Architecture documentation for pluginFilter.ts, a typescript file in the vite codebase. 7 imports, 3 dependents.

File typescript PluginSystem LegacySupport 7 imports 3 dependents 11 functions

Entity Profile

Dependency Diagram

graph LR
  ed570918_8c20_047e_d700_db6178114e8f["pluginFilter.ts"]
  031bc221_67a8_c579_f2bf_bb30a08beeb2["utils.ts"]
  ed570918_8c20_047e_d700_db6178114e8f --> 031bc221_67a8_c579_f2bf_bb30a08beeb2
  19ce2051_6a74_4b8b_104d_ec006cd7075f["arraify"]
  ed570918_8c20_047e_d700_db6178114e8f --> 19ce2051_6a74_4b8b_104d_ec006cd7075f
  abfc9e70_3c15_b3f0_a595_3cf27afb7e64["utils.ts"]
  ed570918_8c20_047e_d700_db6178114e8f --> abfc9e70_3c15_b3f0_a595_3cf27afb7e64
  f094d39d_cd97_2548_86c3_38902c2f3301["slash"]
  ed570918_8c20_047e_d700_db6178114e8f --> f094d39d_cd97_2548_86c3_38902c2f3301
  51e96894_3556_ed5c_1ede_97d449867adf["node:path"]
  ed570918_8c20_047e_d700_db6178114e8f --> 51e96894_3556_ed5c_1ede_97d449867adf
  9511c833_0637_2831_212c_aa3860d6fb17["picomatch"]
  ed570918_8c20_047e_d700_db6178114e8f --> 9511c833_0637_2831_212c_aa3860d6fb17
  693ca867_249b_3e5a_0ce1_8930413b7fcd["rolldown"]
  ed570918_8c20_047e_d700_db6178114e8f --> 693ca867_249b_3e5a_0ce1_8930413b7fcd
  b0896fc6_000a_3898_27ef_397aecd8e155["pluginFilter.spec.ts"]
  b0896fc6_000a_3898_27ef_397aecd8e155 --> ed570918_8c20_047e_d700_db6178114e8f
  5abb8c87_ffcb_f2d4_7421_e36705d9e5c7["plugin.ts"]
  5abb8c87_ffcb_f2d4_7421_e36705d9e5c7 --> ed570918_8c20_047e_d700_db6178114e8f
  3bf7f0de_2a9f_6f04_cead_0321b3b7af01["index.ts"]
  3bf7f0de_2a9f_6f04_cead_0321b3b7af01 --> ed570918_8c20_047e_d700_db6178114e8f
  style ed570918_8c20_047e_d700_db6178114e8f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import path from 'node:path'
import picomatch from 'picomatch'
import type { ModuleTypeFilter } from 'rolldown'
import { arraify } from '../utils'
import { slash } from '../../shared/utils'

export type PluginFilter = (input: string) => boolean
export type TransformHookFilter = (
  id: string,
  code: string,
  moduleType: string,
) => boolean

export type StringFilter<Value = string | RegExp> =
  | Value
  | Array<Value>
  | {
      include?: Value | Array<Value>
      exclude?: Value | Array<Value>
    }

type NormalizedStringFilter = {
  include?: Array<string | RegExp>
  exclude?: Array<string | RegExp>
}

function getMatcherString(glob: string, cwd: string) {
  if (glob.startsWith('**') || path.isAbsolute(glob)) {
    return slash(glob)
  }

  const resolved = path.join(cwd, glob)
  return slash(resolved)
}

function patternToIdFilter(
  pattern: string | RegExp,
  cwd: string,
): PluginFilter {
  if (pattern instanceof RegExp) {
    return (id: string) => {
      const normalizedId = slash(id)
      const result = pattern.test(normalizedId)
      pattern.lastIndex = 0
      return result
    }
  }

  const glob = getMatcherString(pattern, cwd)
  const matcher = picomatch(glob, { dot: true })
  return (id: string) => {
    const normalizedId = slash(id)
    return matcher(normalizedId)
  }
}

function patternToCodeFilter(pattern: string | RegExp): PluginFilter {
  if (pattern instanceof RegExp) {
    return (code: string) => {
      const result = pattern.test(code)
// ... (102 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does pluginFilter.ts do?
pluginFilter.ts is a source file in the vite codebase, written in typescript. It belongs to the PluginSystem domain, LegacySupport subdomain.
What functions are defined in pluginFilter.ts?
pluginFilter.ts defines 11 function(s): createCodeFilter, createFilter, createFilterForTransform, createIdFilter, createModuleTypeFilter, getMatcherString, id, input, normalizeFilter, patternToCodeFilter, and 1 more.
What does pluginFilter.ts depend on?
pluginFilter.ts imports 7 module(s): arraify, node:path, picomatch, rolldown, slash, utils.ts, utils.ts.
What files import pluginFilter.ts?
pluginFilter.ts is imported by 3 file(s): index.ts, plugin.ts, pluginFilter.spec.ts.
Where is pluginFilter.ts in the architecture?
pluginFilter.ts is located at packages/vite/src/node/plugins/pluginFilter.ts (domain: PluginSystem, subdomain: LegacySupport, directory: packages/vite/src/node/plugins).

Analyze Your Own Codebase

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

Try Supermodel Free