fix(gatsby): framework bundling compatibility with multiple package managers #32701
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This changes the test performed for the
framework
cache group, so that it is compatible with more than just yarn 1 or npm.Primary issue with the regular expression is that pnpm in particular always has two levels of
node_modules
. There is not, however, a good regular expression that will detect if the module being tested is the one that belongs to the default site when using pnpm. This is an issue because the framework packages are now always being bundled incommons.js
, which results in some runtime errors becauseframework.js
doesn't exist.To fix this, I compile a list of framework locations that only belong to the default site, and then change the cache group
test
to a function that is able to compare against that list of valid framework directories.I was initially going to handle this fix in
gatsby-plugin-pnpm
alone, but it makes as much sense to do it here, so that there is only one source of truth for the framework bundle names.This shouldn't cause any issues with npm, yarn 1, or yarn 2.
Related Issues
Js-Brecht/gatsby-plugin-pnpm#8
Js-Brecht/gatsby-plugin-pnpm#10