#[repr(u8)]pub enum ImportLoadKind {
Static = 0,
Dynamic = 1,
DynamicPattern = 2,
OutOfThread = 3,
PathReference = 4,
AssetReference = 5,
}Expand description
When the target of an import edge loads, relative to the importing module.
The startup weight report follows only Static edges to find the code that
loads before the entry module runs. The other kinds load later, or outside
the importing thread, except PathReference and AssetReference. These
two edges keep their target in use but do not run it: see
Self::loads_target. Only an asset reference also stops reachability:
see Self::runs_target_code.
Variants§
Static = 0
The target loads before the importer runs: import, export ... from,
require(), require.context and import.meta.glob(..., { eager: true }).
Dynamic = 1
The target loads on demand through import('./literal').
DynamicPattern = 2
The target is one match of an on-demand pattern: a template import()
or a lazy import.meta.glob.
OutOfThread = 3
The target runs on another thread or in another process: a
new URL(..., import.meta.url) reference (for example a worker URL),
a webpack worker loader request (worker-loader!./work.js),
child_process.fork, a pino transport or a module.register hook.
PathReference = 4
The importer gets only the path of the target and does not load it:
require.resolve('./file') or require.resolve(`./file`). The edge
keeps the target in use. The consumer of the path can run the target
later, so the imports of the target stay reachable.
AssetReference = 5
The importer reads the target as text, bytes or a URL through a
webpack asset loader, such as raw-loader!./file.js. The bundle never
runs the target as code, so the imports of the target are not
reachable through this edge. The graph sets this kind; extraction
never records it.
Implementations§
Source§impl ImportLoadKind
impl ImportLoadKind
Sourcepub const fn is_deferred(self) -> bool
pub const fn is_deferred(self) -> bool
Whether the target loads on demand on the importing thread.
Sourcepub const fn loads_target(self) -> bool
pub const fn loads_target(self) -> bool
Whether the edge runs its target. A path reference and an asset reference keep the target in use but do not run it, so the edge does not close a cycle, is not in the entry load closure, does not cross an architecture boundary and does not carry server code into a client bundle.
Sourcepub const fn runs_target_code(self) -> bool
pub const fn runs_target_code(self) -> bool
Whether the target can run as code at all, through this edge or through the consumer of a path reference. Only an asset reference never runs its target, so reachability does not continue through it.
Sourcepub const fn is_eager_value(self, is_type_only: bool) -> bool
pub const fn is_eager_value(self, is_type_only: bool) -> bool
Whether an import with this load kind puts a runtime value of the target on the startup path: the target loads before the importer runs and the import is not type-only.
Trait Implementations§
Source§impl Clone for ImportLoadKind
impl Clone for ImportLoadKind
impl Copy for ImportLoadKind
Source§impl Debug for ImportLoadKind
impl Debug for ImportLoadKind
impl<'__de> Decode<'__de> for ImportLoadKindwhere
'__de:,
Source§impl Default for ImportLoadKind
impl Default for ImportLoadKind
Source§impl<'de> Deserialize<'de> for ImportLoadKind
impl<'de> Deserialize<'de> for ImportLoadKind
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 Encode for ImportLoadKind
impl Eq for ImportLoadKind
Source§impl Hash for ImportLoadKind
impl Hash for ImportLoadKind
Source§impl Ord for ImportLoadKind
impl Ord for ImportLoadKind
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ImportLoadKind
impl PartialEq for ImportLoadKind
Source§impl PartialOrd for ImportLoadKind
impl PartialOrd for ImportLoadKind
Source§impl Serialize for ImportLoadKind
impl Serialize for ImportLoadKind
impl StructuralPartialEq for ImportLoadKind
Auto Trait Implementations§
impl Freeze for ImportLoadKind
impl RefUnwindSafe for ImportLoadKind
impl Send for ImportLoadKind
impl Sync for ImportLoadKind
impl Unpin for ImportLoadKind
impl UnsafeUnpin for ImportLoadKind
impl UnwindSafe for ImportLoadKind
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DecodeOwned for Twhere
T: for<'de> Decode<'de>,
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.