Skip to main content

fallow_types/
extract_dynamic_pattern.rs

1//! Dynamic import patterns of a module.
2
3use oxc_span::Span;
4
5use super::{ImportedName, ModuleLoadMechanism};
6
7/// A dynamic import with a partially resolved pattern.
8#[derive(Debug, Clone)]
9pub struct DynamicImportPattern {
10    /// Glob prefix of the import path (e.g., "./locales/"). An
11    /// `import.meta.glob` pattern is the full glob. For a template literal, a
12    /// string concatenation, or `require.context`, each glob metacharacter of
13    /// the literal text is escaped as a one-character class, such as `[[]`.
14    pub prefix: String,
15    /// Glob suffix of the import path (e.g., ".json"), if any.
16    pub suffix: Option<String>,
17    /// Globs of the files that the pattern does not load. Vite reads a
18    /// negative `import.meta.glob` array entry, such as `'!./a/skip.js'`, as
19    /// an exclude for every positive entry of the same call.
20    pub excludes: Vec<String>,
21    /// Source span in the original file.
22    pub span: Span,
23    /// Runtime mechanism used to load modules matching this pattern.
24    pub mechanism: ModuleLoadMechanism,
25    /// What each match gives the importer, which decides the exports that the
26    /// pattern credits. A pattern loads the whole module by default
27    /// (`Namespace`). The `import` option of `import.meta.glob` selects one
28    /// export (`Default` or `Named`). A raw or url query reads each
29    /// match as text or a URL, so the match stays in use but no export gets
30    /// credit (`SideEffect`).
31    pub imported_name: ImportedName,
32}