gatsby icon indicating copy to clipboard operation
gatsby copied to clipboard

fix(gatsby): framework bundling compatibility with multiple package managers

Open Js-Brecht opened this issue 4 years ago • 1 comments

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 in commons.js, which results in some runtime errors because framework.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

https://github.com/Js-Brecht/gatsby-plugin-pnpm/issues/8 https://github.com/Js-Brecht/gatsby-plugin-pnpm/pull/10

Js-Brecht avatar Aug 04 '21 22:08 Js-Brecht

Not sure what's going on with the tests; some problem with cache-dir/production-app.js... I can reproduce the problem locally, but reverting these changes doesn't seem to make a difference, so I don't really think it's related.

Js-Brecht avatar Aug 05 '21 02:08 Js-Brecht