Expand description
AST-based config file parser utilities.
Provides helpers to extract configuration values from JS/TS config files without evaluating them. Uses Oxc’s parser for fast, safe AST walking.
Common patterns handled:
export default { key: "value" }(default export object)export default defineConfig({ key: "value" })(factory function)module.exports = { key: "value" }(CJS)- Import specifiers (
import x from 'pkg') - Array literals (
["a", "b"]) - Object properties (
{ key: "value" })
Functions§
- config_
default_ export_ unreachable - True when a parsed config has neither an object default export
(
find_config_object) nor an array default export (find_default_export_array). Used to emit a diagnostic when a config shape such asmergeConfig(base, defineConfig({...}))or an imported-and-spread base config cannot be statically reached. - extract_
config_ aliases - Extract alias mappings from an object or array-based alias config.
- extract_
config_ aliases_ kinded - Like
extract_config_aliasesbut each tuple carries a third element:replacement_is_bare_string_literal, true ONLY when the replacement was written as a plain bare string literal (not starting with.//..///) rather than a path expression (path.resolve(...),path.join(...),fileURLToPath(...),new URL(...)). This is the filesystem-free discriminator between a package-to-package alias ('lodash-es' -> 'lodash', bare literal) and a directory/file alias ('@' -> path.resolve(__dirname, 'src'), path expression). Seetest_alias::process_test_alias. - extract_
config_ array_ nested_ aliases - Extract alias mappings nested inside an array of config objects.
- extract_
config_ array_ nested_ aliases_ kinded - Kinded variant of
extract_config_array_nested_aliases(seeextract_config_aliases_kindedfor the third tuple element). - extract_
config_ array_ nested_ string_ or_ array - Extract string values from a property path, also searching inside array elements.
- extract_
config_ array_ object_ string_ pairs - Extract paired
(primary, optional secondary)string values from each object element of an array atarray_path. - extract_
config_ array_ object_ strings - Extract string values from a nested array, supporting both string elements and object elements with a named string/path field.
- extract_
config_ nested_ shallow_ strings - Extract shallow strings from an array property inside a nested object path.
- extract_
config_ object_ keys - Extract keys of an object property at a nested path.
- extract_
config_ object_ nested_ string_ or_ array - Extract string values from a property path, searching inside all values of an object.
- extract_
config_ object_ nested_ strings - Extract string values from a property path, searching inside all values of an object.
- extract_
config_ path_ string - Extract a statically recoverable path-like string from a property path.
- extract_
config_ plugin_ option_ string - Extract a string-like option from a plugin tuple inside a config plugin array.
- extract_
config_ plugin_ option_ string_ from_ paths - Extract a string-like option from the first plugin array path that contains it.
- extract_
config_ property_ strings - Extract string values from top-level properties of the default export/module.exports object. Returns all string literal values found for the given property key, recursively.
- extract_
config_ require_ strings - Extract
require('...')call argument strings from a property’s value. - extract_
config_ shallow_ strings - Extract only top-level string values from a property’s array.
- extract_
config_ shallow_ strings_ or_ object_ property - Extract top-level string values from a config array, including object entries.
- extract_
config_ static_ dir_ entries - Extract Storybook-style static directory entries from an array.
- extract_
config_ string - Extract a single string from a property at a nested path.
- extract_
config_ string_ array - Extract string array from a property at a nested path in a config’s default export.
- extract_
config_ string_ or_ array - Extract a value that may be a single string, a string array, or an object with string/array values.
- extract_
config_ truthy_ bool_ or_ object - True when a nested config property is a static
trueboolean or object value. - extract_
default_ export_ array_ aliases_ kinded - Extract kinded aliases from a default-exported ARRAY config, the
defineWorkspace([...])/vitest.workspace.{ts,js}shape.find_config_objectonly finds an object default export, so the workspace array file is invisible to the object-based extractors; this walks each object element of the array and readsalias_pathfrom it. One level only (nestedtest.projectsinside an element is out of scope). - extract_
imports - Extract all import source specifiers from JS/TS source code.
- extract_
imports_ and_ requires - Extract all import sources AND top-level
require('...')expression statements. - extract_
lazy_ imports_ in_ array - Extract static specifiers from thunk-wrapped dynamic imports inside an array property.
- extract_
vite_ react_ babel_ dependencies - Extract Babel plugin and preset package names configured through
@vitejs/plugin-reactoptions in a Vite-stylepluginsarray. - find_
config_ object_ pub - Public wrapper for
find_config_objectfor plugins that need manual AST walking. - normalize_
config_ path - Normalize a config-relative path string to a project-root-relative path.