Implementing yarn PnP #10245
Replies: 23 comments
-
So glad you opened this! I have the bulk of the functionality built out in #9897 so we can iterate further on any core changes required there once the issues you've identified are solved 😅 |
Beta Was this translation helpful? Give feedback.
-
No problem @DSchau ! My theory is that specifying the transitive dependencies fixed it. |
Beta Was this translation helpful? Give feedback.
-
I think that's probably safe as long as we validate locally and with a real project. See also gatsbyjs/gatsby/pull#9914 for some related discussion re: that package and the graphql package. It looks like we really need a |
Beta Was this translation helpful? Give feedback.
-
@DSchau Did you run into any issues relating to the way Gatsby copies all files in I just got Gatsby working with pnpm which requires dependencies to be strictly defined (no hoisting to root NM). I had issues with Just wondering if you had a similar issue. |
Beta Was this translation helpful? Give feedback.
-
@vjpr I got the same error message once I patched manually some errors with the babel dependencies, did you have to modify anything related to babel to get pnpm to get to that error? |
Beta Was this translation helpful? Give feedback.
-
Just added an entry to webpack |
Beta Was this translation helpful? Give feedback.
-
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! Thanks for being a part of the Gatsby community! 💪💜 |
Beta Was this translation helpful? Give feedback.
-
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m Thanks again for being part of the Gatsby community! |
Beta Was this translation helpful? Give feedback.
-
Hey! I'm playing a bit with Gatsby and I think I could help with this issue (I'm also Yarn's maintainer and PnP's author, which helps)! 🙂 So far the main issue I have is related to the I'll try to figure out a way to solve this, but the problem is that it's not really a PnP bug: even under the regular install strategy there's nothing that guarantees that the dependencies that will be required by those files will be the one that you expect - hoisting makes it kinda work, but under some circumstances might end up requiring the wrong versions. |
Beta Was this translation helpful? Give feedback.
-
@arcanis wow - well this would be amazing :) We'd certainly appreciate any help in this space. For some prior art here, I did have a PR that mostly implemented this functionality, but ran into some intractable issues. See: #9897 |
Beta Was this translation helpful? Give feedback.
-
To give you an idea this is the exception thrown. As you can see PnP thinks that the @DSchau From which package should the dependencies listed by |
Beta Was this translation helpful? Give feedback.
-
One relatively simple way I can see to solve this would be to have a Webpack resolver exported by the const plugin = (request, issuer, next) => {
if (issuer.startsWith('.cache/')) {
return require.resolve(request);
} else {
return next(request, issuer);
}
}; This way, all files built by Webpack from within the cache folder would see their dependencies resolved relative to the |
Beta Was this translation helpful? Give feedback.
-
I've made it work with our v2! I wrote the steps I took here, can be useful for later: yarnpkg/berry#9 If someone with a stronger Gatsby background than me can give it a look I'd be grateful! |
Beta Was this translation helpful? Give feedback.
-
I've found an issue in I'd recommend to slightly change the require.resolve(pluginName, {
paths: require.resolve.paths(projectRoot),
}) The require call would be disambiguated and PnP would return the expected location. Unfortunately it seems that |
Beta Was this translation helpful? Give feedback.
-
@arcanis awesome (on all accounts!). We'll need to make sure that implementing that functionality doesn't break something unrelated, but that looks good to me. Would you be interested in PRing anything necessary to get this functionality up and running? We could expose a |
Beta Was this translation helpful? Give feedback.
-
@DSchau sure, I'll open a PR once I'm done investigating. I'm currently blocked on the following error. I don't have any other error log, so I'm not sure where to look for explanation. Would you have any tip, like the location where
|
Beta Was this translation helpful? Give feedback.
-
I think the problem was at this line - for some reason |
Beta Was this translation helpful? Give feedback.
-
Update: now works almost out of the box (note that I test using our v2 trunk). Current blockers:
No real blocker at the horizon 😊 |
Beta Was this translation helpful? Give feedback.
-
One remark: because some modules are flagged externals (implementation here: #7245, cc @pieh), Gatsby+PnP users will have to add them to their own dependencies if a Gatsby plugin happens to depend on them transitively 😢 |
Beta Was this translation helpful? Give feedback.
-
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m Thanks again for being part of the Gatsby community! |
Beta Was this translation helpful? Give feedback.
-
For me at least, with Yarn PnP enabled on a project & Gatsby 2.13.58 or later (tried up to 2.13.75), yarn build gives an error of "gatsby: not found". Reverting to Gatsby 2.13.57 or disabling Yarn PnP makes it work again. I think I, or someone else, should verify the issue on another project, especially a blank new one. |
Beta Was this translation helpful? Give feedback.
-
Hurray, new project works. Must be a complicated dependency issue that none of my meddling has been able to fix yet. Am sticking with non-pnp for now because it also fixed a style application bug with Material-UI... |
Beta Was this translation helpful? Give feedback.
-
ERROR There was a problem loading the local develop command. Gatsby may not be installed. Perhaps you need to run "npm Error: Package "[email protected]" (via "C:\Website\website.pnp\unplugged\npm-gatsby-cli-3.0.0-76842780971a15e78c82191
error Command failed with exit code 1. |
Beta Was this translation helpful? Give feedback.
-
In order to implement yarn plug and play with Gatsby some tasks need to be completed first
Even if the task is practically unattainable (specially from the third step) the other steps are intrinsically worth it.
Beta Was this translation helpful? Give feedback.
All reactions