1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/// Internal helpers for ModuleGraph that should only be used by specific modules.
///
/// **DO NOT USE THESE FUNCTIONS** unless you're in the appropriate restricted context.
///
/// This module provides restricted access to potentially unsafe ModuleGraph operations
/// that should only be used in specific contexts where items may legitimately not exist.
use crate::;
/// Try to get a dependency by ID, returning None if not found.
///
/// # Restricted Use - BINDING LAYER ONLY
///
/// **WARNING**: This function should ONLY be used in the `rspack_binding_api` crate
/// for JavaScript/Node.js API bindings that need to handle missing dependencies
/// gracefully for external API consumers.
///
/// **All internal Rust code must use `ModuleGraph::dependency_by_id()`** instead,
/// which enforces the invariant that dependencies exist and provides clear panic
/// messages when this expectation is violated.
///
/// # When to Use
///
/// Only use in binding layer code where:
/// - You're exposing APIs to JavaScript/Node.js
/// - External consumers might query non-existent dependencies
/// - Graceful None handling is appropriate for the external API contract
///
/// If you're writing internal Rust code, use `dependency_by_id()` instead.
/// Try to get a mutable module graph module by identifier, returning None if not found.
///
/// # Restricted Use - DO NOT USE
///
/// **WARNING**: This function should ONLY be used in `compilation::build_module_graph`
/// for handling module removal during graph updates where modules may have been removed
/// during incremental compilation.
///
/// **All other code must use `ModuleGraph::module_graph_module_by_identifier_mut()`**
/// which enforces the invariant that the module exists with a clear panic message.
///
/// # When to Use (only in build_module_graph)
///
/// Only use when you have a legitimate reason to expect the module might not exist:
/// - During incremental compilation where modules may have been removed
/// - During graph cleanup operations where referenced modules may already be deleted
///
/// If you're unsure, use `module_graph_module_by_identifier_mut()` instead.
pub