Expand description
The oxc boundary of skif: one JavaScript or TypeScript file in, skif-owned facts out.
parse_module returns a ModuleInfo (imports, exports, in-file references, removal ranges) and
extract_config_object statically evaluates the object a tool config file exports. extract_config returns an
ExtractedConfig: that value and the evaluated arguments of the calls the evaluator cannot follow that the file
exports, returns from its config function or merges, following imports when given a ModuleLoader. No oxc type
appears in the public API, every public type is Send + Sync, and no oxc value outlives the call that parsed it:
each thread parses into one arena it resets before every parse.
Supported inputs are .js .mjs .cjs .jsx .ts .mts .cts .tsx and declaration files (is_declaration_file),
plus the <script> blocks (and Astro frontmatter), the <style> imports and the markup identifiers of .vue,
.svelte and .astro files: component tags and the expressions of the template count as uses of the imports they
name, unless a template local of the same name (v-for, {#each}, an arrow parameter) shadows the import.
.mdx files yield the facts of their top-level import and export statements, and the components their markup
names count as uses.
.tsrx files yield their imports only, since their templates are no JavaScript, and .marko files their imports and
the imports of their style blocks. Stylesheets go through
parse_stylesheet. Other extensions yield SyntaxError::Unsupported. registered_components reads the
components a components.d.ts generated by unplugin-vue-components registers.
parse_cached parses through a ModuleCache the host supplies, keyed by a ModuleKey over everything a
parse depends on, so a long-lived or persisting host parses only the files that changed (ADR 0029).
Structs§
- Cached
Module - One cached parse result. Its fields are private: a host stores and serializes it without depending on the shape
of
ModuleInfo. - Config
Comments - The comments of a configuration file’s literals, from
extract_config_comments. - Element
Comment - The comment written next to one element of an array literal: on the lines directly above it, or after it on the line where it ends.
- Export
- One export of a module.
- Extracted
Config - What a config file exports, with the arguments of the calls it is made of that cannot be followed.
- Import
- A module reference.
- Imported
Call - A call, or a tagged template, of a function a module exports; see
extract_imported_calls. - Imported
Name - One binding brought in by an
Import. - Member
- A member of an enum or TypeScript namespace.
- Memory
Module Cache - An in-process
ModuleCachefor long-lived hosts (watch mode, the language server, the MCP server). - Module
Info - Everything skif needs to know about one source file.
- Module
Key - The key of one parse result: a 128-bit
SipHash-1-3of the schema, the crate version, the parser, the parse options, the file name and the text. The directory is not part of it, so identical files share an entry and a moved checkout keeps its cache. - Parse
Coalescer - Parses each key once while several threads ask for it: a lookup of a key another thread is parsing waits for that parse and is given its outcome instead of parsing the file again (ADR 0029).
- Parse
Issue - A syntax problem reported by the parser. The analysis of the file continues on the parser’s recovered program.
- Parse
Options - Options for
crate::parse_module. - Property
Comment - The comment written next to a property of an object literal: on the lines directly above it, after it on the line where it ends, or, when its value is an array literal, after the opening bracket on the bracket’s line.
- Registered
Component - A component registered globally by a generated declaration file:
AppButton: typeof import('./src/components/AppButton.vue')['default']. - Removal
- A byte range to delete to fix an unused export.
Enums§
- Config
Value - A statically known value from a config file.
- Export
Kind - What an export is.
- Import
Kind - How a module is pulled in.
- Imported
Kind - Which export of the target module a binding refers to.
- Mock
Call - A test-runner call that names a module, recorded on an
ImportKind::Mockimport. It serializes as the call is written ("vi.mock"). - Path
Segment - One step of the path from an outermost object or array literal to an array literal.
- Registration
- How a class is registered as a custom element (ADR 0020).
- Removal
Kind - What a removal edit deletes.
- Syntax
Error - Why a file could not be turned into a
crate::ModuleInfo.
Constants§
- CACHE_
SCHEMA - The version of the parse output. Raise it whenever
ModuleInfoor what the parsers put in it changes, so a cache written by an older build at the same crate version is not trusted; the testthe_cache_schema_matches_the_parse_outputfails untilCACHE_SCHEMA_DIGESTis updated with it. - CACHE_
SCHEMA_ DIGEST - The digest of the serialized parse results of a fixed probe corpus at
CACHE_SCHEMA. It is a test’s guard, not part of any key: when the parse output changes, the test reports the new digest and both constants move. - DECLARATION_
SUFFIXES - The suffixes of TypeScript declaration files:
.d.ts,.d.mtsand.d.cts. - FILE_
DIR - What the directory of the calling file reads as in the
cwdoption of anImportedCallthat the file’s own location computes (__dirname,import.meta.dirname,path.join(__dirname, 'fixtures')), followed by/and the path relative to the file’s directory ($__skif_file_dir__/./fixtures).command_in_call_dirchanges to it, andplace_file_dirputs the file’s directory in its place. - OWN_
SPREAD - Like
UNKNOWN_SPREAD, for an unknown value the module computes itself: a spread or merge of a call of, or a reference to, a function or constant it defines, or a binding of a function being evaluated (build: { ...makeLib() }). A value imported from another module records these asUNKNOWN_SPREADtoo. - TEMPLATE_
SUBSTITUTION - What a substitution of a tagged template reads as in
ImportedCall::template. - UNKNOWN_
SPREAD - The key under which an object records an unknown spread, or an unknown argument of a merge, of a value the module takes from elsewhere: an imported base config, a merge of imported ones, a global. It may add or replace any key.
Traits§
- Module
Cache - A store of parse results the host owns and gives the analysis.
- Module
Loader - Finds the modules a config file imports, so their values can be evaluated statically too.
Functions§
- cache_
version - The version a persisted cache records,
<crate version>+<CACHE_SCHEMA>: a store written under another version is discarded as a whole. - camelize
- Vue’s
camelize: each-before a word character is dropped and the character upper-cased (my-buttonasmyButton). - capitalize
- Vue’s
capitalize: the first character upper-cased (myButtonasMyButton). - coalesce_
ranges - Merges overlapping and touching byte ranges into sorted, disjoint ones.
- command_
in_ call_ dir commandas a call whose options object isoptionsruns it. Acwdoption the file’s own location computes (FILE_DIR) runs it in that directory, so the command line first changes to it (cd $__skif_file_dir__/. && …). Any othercwdruns it in a directory the script parser cannot place (a literal path is relative to the process, which the parser does not know), so the command line first changes to a directory a substitution names (cd $__skif__ && …): a package manager’s script run there is another package’s, as withbun --cwd.- command_
line_ call - The command of a
(command line, options)call such asexecSync('tsc -b', { cwd }), in the directory itscwdoption names (seecommand_in_call_dir);Noneunless the command line is a string. - extract_
array_ comments - The comments next to the elements of the array literals of
source, a JavaScript or TypeScript file whose extension (inpath) selects the dialect. Paths start at each outermost object or array literal, so the object a config file exports, directly or through a constant or a call such asdefineConfig({ ... }), is the root. A property or element whose value is the name of a top-levelconstbound to an object or array literal is followed into that literal, soconst deps = [...]; export default { ignoreDependencies: deps }puts the comments ofdepsunderignoreDependencies(they are also reported underdepsas a root of its own). A spread is not followed. A comment that is a tool directive (// eslint-disable-next-line,// @ts-expect-error) is left out. - extract_
command_ calls - The calls of
extract_imported_callsfor functions that run a command (execa,nano-spawn), whosecwdoption is read as the directory the command runs in (seeImportedCall::arguments). - extract_
config - Statically evaluates what
sourceexports, asextract_config_objectdoes, keeping the arguments of the calls it is made of that cannot be followed (ExtractedConfig::call_arguments). - extract_
config_ comments - The comments of
sourcethatextract_array_commentsreads, with anElementCommentunder a heading for every element whose only explanation is the comment above an earlier element of its array, and aPropertyCommentfor every property with a static key that has a comment. Properties are walked as elements are: a property whose value names a top-levelconstliteral is followed into it. - extract_
config_ object - Statically evaluates what
sourceexports:export default …,module.exports = …orexport = …. - extract_
config_ object_ with - The exported value
extract_configfinds withloader, following the imports it finds. - extract_
constructor_ options - Statically evaluates the option
keyof everynew constructor({ … })insource, however the constructor was imported (new NodejsFunction(…),new lambda_nodejs.NodejsFunction(…)). Path computations are relative to the directory ofpath. Returns nothing when the file does not parse. - extract_
imported_ calls - Every call and tagged template in
sourcewhose function is imported from one ofmodules(import,import * as, or a top-levelrequire, plain or destructured), with its arguments statically evaluated as inextract_config_object.globalsnames functions available without an import, as(name, module)pairs (the$of a zx script); a name writtenBun.*stands for the module object itself, soBun.$`…`andBun.build(…)call the exports$andbuildof the module. Shadowed names are not tracked. Returns nothing when the file does not parse. - extract_
method_ calls - Statically evaluates the arguments of every call of a method named
methodinsource, whatever object it is called on (eleventyConfig.addPassthroughCopy("img")), in source order: one list of arguments per call. Arguments are evaluated as inextract_config_object, so a top-level constant is known and a local of the enclosing function is not. Returns nothing when the file does not parse. - extract_
property_ calls - Statically calls every function that is the property
keyof an object literal insource, a method (configureWebpack(config) { … }) or a function or arrow value, withargumentas its first parameter, in source order. Each result is the value the function returns or, when its body finishes without areturn, what it leaves its first parameter as: a function that changes the object it is given (config.entry = { … }) yields the changed object. Calls are evaluated as inextract_config_object; a property that is not a function is left out. Returns nothing when the file does not parse. - extract_
property_ values - Statically evaluates the value of every property named
keyof every object literal insource, however deeply nested and wherever it appears (handler: "src/api.handler"inside a function body), in source order. Values are evaluated as inextract_config_object, against the top-level bindings, with paths relative to the directory ofpath; a name a function, block, loop orcatcharound the property declares is unknown, whatever top-level binding it shadows. Methods are left out. Returns nothing when the file does not parse. - file_
call_ options - The options object of a
(file, [arguments], options)call such asspawn('eslint', ['.'], { cwd }): the argument after the arguments array, or the second argument when that is no array. - is_
declaration_ file - Whether
path, a path or a file name, names a TypeScript declaration file (.d.ts,.d.mts,.d.cts). - is_
native_ tag - Whether
tagis an element of HTML, SVG orMathML, or thecomponentandslotof Vue’s compiler, as written: Vue never resolves such a tag to a registered component. The match is case-sensitive, as Vue’s:<Button>is a component. - is_
source_ query - Whether a query (
?raw,raw&inline, with or without its?) makes Vite load a file’s text instead of the module, by Vite’s own test: arawparameter with no value.?urlis not one: it names the file to load it some other way (a worklet, a worker), so the file still counts as used. - is_
stylesheet - Whether
pathhas a stylesheet extension. - literal_
command - The command line of a
(file, [arguments])call such asspawn('eslint', ['.']): the file and its literal arguments, a computed argument left out.Nonewhen the file or a literal argument is not a plain word, because dropping it would change what the command means. - parse_
cached - Parses
source, the text ofpath, withoptions, throughcache: a stored result is returned as it is, and a fresh parse is stored before it is returned. Stylesheets go toparse_stylesheetand everything else tocrate::parse_module. Without a cache this is a plain parse. - parse_
module - Parses
source(the content ofpath) into aModuleInfo. The extension ofpathselects the language. - parse_
stylesheet - Scans the stylesheet
source(the content ofpath) for the files and packages it imports. Every import hasImportKind::SideEffect. Nothing is reported for remote URLs,data:URLs, Sass built-in modules, specifiers with interpolation and Stylus globs (@import "mixins/*"). - place_
file_ dir commandwith the directory offile, the file that runs it as a/-separated path relative to the directory where the command starts, in place ofFILE_DIR, single-quoted so that a shell reads it as part of one word whatever it holds (cd 'my scripts'/../sub).- registered_
components - The components
source, the text of acomponents.d.tsthatunplugin-vue-componentsgenerated, registers from files of the project, in source order: each property ofGlobalComponentsand each globalconstwhose type istypeof import('./…')[…], as knip reads them. ALazyvariant of a registered name (LazyAppIconbesideAppIcon) is the same component and is left out; aLazyImageregistered on its own is a component of its own. Components of packages (typeof import('vant')['Button']) are left out too: the declaration file keeps importing them. - registered_
name - The registered component the tag
tagnames, byresolved_names, or by the name after aLazyprefix (LazyAppButton,lazy-app-button) as knip also matches it;Nonefor a native tag (is_native_tag). - resolved_
names - The names Vue looks a tag up by, in its order and without repeats: as written, camelized, and camelized and
capitalised (
my-button,myButton,MyButton). The compiler resolves a tag to a binding of the script this way, and the runtime (resolveAsset) to a registered component.