pub struct ModuleInfo {Show 15 fields
pub imports: Vec<Import>,
pub exports: Vec<Export>,
pub in_file_references: Vec<String>,
pub has_cjs_exports: bool,
pub has_jsx: bool,
pub jsx_import_source: Option<String>,
pub jsx_import_source_span: Option<Span>,
pub directives: Vec<String>,
pub unresolved_dynamic: Vec<Span>,
pub ambient_modules: Vec<String>,
pub augmented_modules: Vec<String>,
pub commands: Vec<String>,
pub template_tags: Vec<String>,
pub parse_diagnostics: Vec<ParseIssue>,
pub fatal: bool,
}Expand description
Everything skif needs to know about one source file.
Fields§
§imports: Vec<Import>Module references, in source order.
exports: Vec<Export>Exports, in source order.
in_file_references: Vec<String>Export names referenced inside the same file; sorted, deduplicated.
has_cjs_exports: boolmodule.exports = …, module.exports.x = … or exports.x = … anywhere in the file. The file is then a
CommonJS module whose export names are not tracked: treat all of its exports as used.
has_jsx: boolThe file contains JSX.
jsx_import_source: Option<String>Value of a @jsxImportSource pragma.
jsx_import_source_span: Option<Span>Location of the value of the @jsxImportSource pragma. Only a pragma in the comments before the first
statement counts.
directives: Vec<String>Directive prologue strings of the top level, such as use client and use server. See
ModuleInfo::is_client_boundary and ModuleInfo::is_server_actions.
unresolved_dynamic: Vec<Span>import(), require() and import.meta.glob() calls whose argument is not static.
ambient_modules: Vec<String>Names declared with declare module 'name' { … } in a script (a file without top-level import or
export): the declaration is the module, for every file of the program.
augmented_modules: Vec<String>Names augmented with declare module 'name' { … } in a module file: the block adds to a module that has to
exist already and declares nothing on its own.
commands: Vec<String>The command lines the file runs through node:child_process (execSync('tsc -b'), spawn('eslint', ['.'])),
in source order without duplicates; only literal commands. They are parsed like the scripts of package.json.
The tag names of the template of a .vue file as written (AppButton, app-card, div), with the static
values of its is attributes (is="AppButton", :is="'AppButton'"), and the names of the
resolveComponent('AppButton') calls of any file, sorted and without duplicates: unplugin-vue-components
imports the components it registers into the files that use them so (ADR 0020). Empty for other files.
parse_diagnostics: Vec<ParseIssue>Syntax errors the parser recovered from; the other fields describe the recovered program. For component files, the issues of every script block.
fatal: boolThe parser could not recover (or, for a component file, could not recover in at least one script block): the facts of the affected code are missing. Report the file as unparseable instead of treating it as empty.
Implementations§
Source§impl ModuleInfo
impl ModuleInfo
Sourcepub fn removal_ranges(&self) -> impl Iterator<Item = &Removal>
pub fn removal_ranges(&self) -> impl Iterator<Item = &Removal>
Removal edits of every export that has one, in source order.
Sourcepub fn is_client_boundary(&self) -> bool
pub fn is_client_boundary(&self) -> bool
The file starts with the "use client" directive: a React Server Components client boundary whose exports
are consumed by the framework.
Sourcepub fn is_server_actions(&self) -> bool
pub fn is_server_actions(&self) -> bool
The file starts with the "use server" directive: every export is a server action the framework calls.
Sourcepub fn removal_edits(
&self,
is_unused: impl Fn(&Export) -> bool,
) -> Vec<(u32, u32)>
pub fn removal_edits( &self, is_unused: impl Fn(&Export) -> bool, ) -> Vec<(u32, u32)>
Disjoint, sorted deletions that remove every export for which is_unused holds.
Specifier ranges of one statement are merged; a statement whose specifiers are all unused is deleted whole
instead of leaving export {}; a RemovalKind::SharedExportKeyword applies only when every sibling is
unused.
Trait Implementations§
Source§impl Clone for ModuleInfo
impl Clone for ModuleInfo
Source§impl Debug for ModuleInfo
impl Debug for ModuleInfo
Source§impl Default for ModuleInfo
impl Default for ModuleInfo
Source§impl<'de> Deserialize<'de> for ModuleInfo
impl<'de> Deserialize<'de> for ModuleInfo
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ModuleInfo
Source§impl PartialEq for ModuleInfo
impl PartialEq for ModuleInfo
Source§impl Serialize for ModuleInfo
impl Serialize for ModuleInfo
impl StructuralPartialEq for ModuleInfo
Auto Trait Implementations§
impl Forget for ModuleInfo
impl Freeze for ModuleInfo
impl Move for ModuleInfo
impl RefUnwindSafe for ModuleInfo
impl Send for ModuleInfo
impl Sync for ModuleInfo
impl Unpin for ModuleInfo
impl UnsafeUnpin for ModuleInfo
impl UnwindSafe for ModuleInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more