Skip to content

fix(ModuleScopePlugin): support pnp in workspaces #11237

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 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/react-dev-utils/ModuleScopePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class ModuleScopePlugin {
) {
return callback();
}
if (process.versions.pnp) {
const {findPackageLocator} = require('pnpapi');
if (findPackageLocator(request.__innerRequest_request) !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be true for any absolute path, not just workspaces

Copy link

Choose a reason for hiding this comment

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

This is not a complete check and most likely not even a part of a proper check. The idea was to see if file can be resolved to be belonging to one of the packages declared as a dependency, but that does not guarantee that it is required via dependency and not directly.
I assume that is what it does but I don't actually know.

return callback();
}
}
// Resolve the issuer from our appSrc and make sure it's one of our files
// Maybe an indexOf === 0 would be better?
if (
Expand Down