fix: use `Weak` references for `CachedPath` to enable proper drop (#727)
Related:
* https://github.com/oxc-project/oxc/issues/10627
The resolver was experiencing memory leaks due to circular strong references between `CachedPath` objects. Even after the resolver was dropped, `CachedPath` instances (and their associated `PackageJson` data) remained in memory due to reference cycles created by Arc (reference-counted) pointers.
The memory leak was caused by circular references in three fields of `CachedPathImpl`:
1. `parent: Option<CachedPath>` - Child paths held strong references to parent paths
2. `canonicalized: OnceLock<Result<CachedPath, ResolveError>>` - Paths held strong references to their canonicalized versions
3. `node_modules: OnceLock<Option<CachedPath>>` - Parent directories held strong references to their node_modules subdirectories
These created reference cycles preventing Arc reference counts from reaching zero.
Converted all fields that could create circular references to use `Weak` references:
- `parent: Option<Weak<CachedPathImpl>>`
- `canonicalized: OnceLock<Result<Weak<CachedPathImpl>, ResolveError>>`
- `node_modules: OnceLock<Option<Weak<CachedPathImpl>>>`
Updated all accessor methods to upgrade Weak references when needed:
- `parent()` - Upgrades weak parent reference
- `cached_node_modules()` - Stores and retrieves weak references
- `canonicalize_impl()` - Stores canonicalized paths as weak references
Passes `test_memory_leak_arc_cycles` that failed in the previous stack.