Skip to content

fix: add yarn pnp support to read_dir #11124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

elbywan
Copy link

@elbywan elbywan commented Jul 22, 2025

Summary

Makes read_dir work when using yarn pnp, preventing a crash when a third party module contains a dynamic require and making it properly the zip crawl directories.

I do not think that the require context ever worked with yarn pnp before anyway, but at least it did not crash prior to #10960.

This is not efficient at all because it iterates over the whole index of the zip file every time, the proper fix would be to add a mapping between folders and children directly in the pnp-rs crate (cc @arcanis 👋) but at least it should stop rspack from crashing in the meantime:

[rspack-cli] [Error:   × Rspack FS Error: Not a directory (os error 20)
  ╰─▶ Not a directory (os error 20)
] {
  code: 'GenericFailure'
}

Related links

Should solve #11123

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@Copilot Copilot AI review requested due to automatic review settings July 22, 2025 07:26
Copy link

netlify bot commented Jul 22, 2025

Deploy Preview for rspack ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 14c9a07
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/6883900182744900085308a7
😎 Deploy Preview https://deploy-preview-11124--rspack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the release: bug fix release: bug related release(mr only) label Jul 22, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Yarn PnP (Plug'n'Play) support to the read_dir functionality in rspack's filesystem layer to prevent crashes when third-party modules contain dynamic requires. The implementation provides a temporary workaround by iterating through zip file indices to find directory contents.

  • Adds PnP-aware directory reading logic that handles zip-based module resolution
  • Implements fallback to native filesystem operations when not using PnP
  • Provides crash prevention for dynamic require scenarios in Yarn PnP environments

@CPunisher CPunisher requested a review from stormslowly July 22, 2025 11:48
Copy link

codspeed-hq bot commented Jul 25, 2025

CodSpeed Performance Report

Merging #11124 will not alter performance

Comparing elbywan:fix-read_dir-yarn-pnp (14c9a07) with main (bc0fb4b)

Summary

✅ 16 untouched benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: bug fix release: bug related release(mr only)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant