fix: 🐛 edge case one package cached and unplugged in same time #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
problem
in this rspack issue's reproduction pnp-rs resolves successfully by chance
reproduce steps
git cloen [email protected]:kubijo/rspack-link-repro.git
cargo run -- @carbon/icon-helpers /path/to/rspack-link-repro/.yarn/unplugged/@carbon-icons-react-virtual-379302d360/node_modules/@carbon/icons-react/es/
if we get luck, it will shows
root cause
in this case https://github.com/kubijo/rspack-link-repro/blob/70339cbc0911432f1a5dfdbf497f1e7b44606c36/.pnp.cjs#L2104-L2128
pkg
@carbon/icons-react
has both cached and unplugged dir, so it have two package infos, in the state jsonthen
manifest.location_trie.insert
depends on the iteration order of rangespnp-rs/src/lib.rs
Lines 263 to 278 in cbfa5be
if
@carbon/icons-react
'svirtual:ed977161de6
package info comes last, resolve success; ifnpm:11.54.0
comes last, resolve failed.so we need to keep the package info's order as them are in json state.
solution
Just use IndexMap instead of Hashmap.