-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
fix(gatsby): fix webpack compilation when pnpm is used #38757
Conversation
cacheDirReq.resolve(cacheDirDep) | ||
} catch { | ||
// something is not resolable from the cache folder, so we should not enable this plugin | ||
isEverythingResolvableFromCacheDir = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is false, could break out of the for loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we would need 2 separate loops for checking if tested dependency is resolvable from .cache
and from `gatsby package - which I think probably makes more sense than current single loop, so I will make the change to run those checks in separate loops and just break the loops on first unresolvable module
packages/gatsby/src/utils/webpack/plugins/cache-folder-resolver.ts
Outdated
Show resolved
Hide resolved
…r.ts Co-authored-by: Katherine Beck <49894658+kathmbeck@users.noreply.github.com>
…d gatsby package, break on first unresolvable module
* fix: use different method of figuring out wether to enable .cache resolver plugin * use multiple conditions when deciding wether to enable .cache folder resolver plugin * feat(gatsby-dev-cli): allow using pnpm for installing deps * test: add pnpm test * test: test api functions for pnp and pnpm * fix: api functions * Update packages/gatsby/src/utils/webpack/plugins/cache-folder-resolver.ts Co-authored-by: Katherine Beck <49894658+kathmbeck@users.noreply.github.com> * chore: separate test loops for trying to resolve from cache folder and gatsby package, break on first unresolvable module --------- Co-authored-by: Katherine Beck <49894658+kathmbeck@users.noreply.github.com> (cherry picked from commit d2ffc2a)
* fix: use different method of figuring out wether to enable .cache resolver plugin * use multiple conditions when deciding wether to enable .cache folder resolver plugin * feat(gatsby-dev-cli): allow using pnpm for installing deps * test: add pnpm test * test: test api functions for pnp and pnpm * fix: api functions * Update packages/gatsby/src/utils/webpack/plugins/cache-folder-resolver.ts Co-authored-by: Katherine Beck <49894658+kathmbeck@users.noreply.github.com> * chore: separate test loops for trying to resolve from cache folder and gatsby package, break on first unresolvable module --------- Co-authored-by: Katherine Beck <49894658+kathmbeck@users.noreply.github.com> (cherry picked from commit d2ffc2a) Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
Description
Our "cache folder resolver" (webpack plugin that resolves gatsby dependencies for files copied from gatsby package to .cache directory) is currently only being enabled for Yarn PnP.
process.versions.pnp
check is only ever used for yarn, pnpm doesn't use so this PR adds more conditions that allow enablement of the plugin:NODE_PATH
env var - this is used when running things throughpnpm
CLI.cache
directory - this path would be used when deps where installed with pnpm (tho it's possible other package managers can createnode_modules
structures that would hit same case too) and then regulargatsby
CLI (and not viapnpm
CLI) would be used to run gatsby - note that this path would NOT enable the plugin when usingpnpm
cli - becauseNODE_PATH
is set therequire.resolve
tests would report that required deps are resolvable from.cache
, but webpack resolver doesn't honor NODE_PATH so compilation would fail. (possible alternative would be to adjust webpack config to honor NODE_PATH but this is discouraged)This fixes errors like:
when using pnpm (and possible others)
-- update
API functions compilation is also currently broken when using
pnpm
oryarn pnp
so this is being fixed in this PR as wellCan be tested with
gatsby@5.13.0-alpha-fix-pnpm.21
canaryTests
Added test for
pnpm
similar as one we have for yarn PnP - tested in separate draft PRs:Related Issues
https://linear.app/netlify/issue/FRA-179/fix-using-gatsby-with-pnpm