-
Notifications
You must be signed in to change notification settings - Fork 193
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
Builtin pnp resolver #162
Comments
Ping @sokra @TheLarkInn, at least to start a discussion? 😃 |
Wow sorry this repo is watched a lot less. I can take a look at this tomorrow! |
No worry, thanks! 😃👍 |
@TheLarkInn I went ahead and put up a PR at #168 😃 |
I appreciate that we're all busy, but together with #168 it's been two months this issue has been opened with little to no feedback - I can only guess that you're unsatisfied with something, but unless you express it clearly it will be hard for me to adress your concerns in a productive way. |
@arcanis sorry I'm in parental leave currently. This would be a breaking change anyway, so no need to hurry, since it would be webpack 5 anyway. |
I see, no worries then, it certainly can wait! Thanks for the update 😊 |
Coming to the news! Since the last time Gatsby and Jest (and some less-known tools) now have builtin support, and Parcel signaled interest. Additionally we've announced Yarn 2, which will use PnP by default. We would appreciate a ton any help ensuring a smooth migration path to our user 🙂 |
Thanks for helping us 👍 |
I have a few questions:
|
Short answer: you don't 😛 The PnP API exposes three resolution functions, but only one is required. The other two are mostly here for convenience for when the resolution pipeline only allow to replace the resolution on a "all or nothing" basis. This isn't the case of So in your case, you'd only need the In fact, if you look at my PR, you'll see that it's exactly what I do: the plugin is injected where
If you point me to the location where you have this logic implemented I probably can be more precise, but there are two ways. The hacky way is that you don't change anything. Assuming that you find the nearest The correct way would be to simply ask the PnP API to tell you what package owns a file, and where is located its root: let nearestPackageJson;
if (process.versions.pnp) {
const {findPackageLocator, getPackageInformation} = require(`pnpapi`);
const filePath = `/cache/lodash-1.0.0/foo/bar/hello/world.js`;
const ownerPackage = findPackageLocator(filePath);
const {packageLocation} = getPackageInformation(ownerPackage);
nearestPackageJson = `${packageLocation}/package.json`;
}
if (!nearestPackageJson) {
// ... regular logic you apply
} |
fixed |
I've wrote the following plugin to make it easy to use PnP with Webpack. Would you be interested to move it in
enhanced-resolve
in a later version? I think this would prove useful from a DevX perspective, one less configuration required, which would likely help adoption.The only one issue I'm aware of is arcanis/pnp-webpack-plugin#3, but I'm confident a solution can be easily found (we actually already have one, the main issue is that it suppresses the semantic errors that PnP can throw).
The text was updated successfully, but these errors were encountered: