-
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): handle initializing multiple instances of gatsby-plugin-sharp #37306
fix(gatsby): handle initializing multiple instances of gatsby-plugin-sharp #37306
Conversation
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.
Looks great, one question and then I'll approve!
@@ -26,6 +26,7 @@ import { store } from "../../redux" | |||
import { validateEngines } from "../../utils/validate-engines" | |||
|
|||
async function run(): Promise<void> { | |||
process.env.GATSBY_SLICES = `1` |
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.
Double checking, is this change also required for the fix or left in accidentally?
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.
This is not needed for a fix as we don't actually use this file in regular usage.
I just noticed problems with trying to use engines regenerated with this script manually as I was iterating on this PR and testing produced engines
…sharp (#37306) * fix(gatsby): handle initializing multiple instances of gatsby-plugin-sharp * fix(gatsby): handle initializing multiple instances of gatsby-plugin-sharp in engines * update standalone-regenerate * normalize main config when loading themes * move deduplicaiton to plugin loading instead of themes loading * convert load-themes to TS * lint * update assertions * remove test that no longer make sense (cherry picked from commit 26f2b72)
…sharp (#37306) * fix(gatsby): handle initializing multiple instances of gatsby-plugin-sharp * fix(gatsby): handle initializing multiple instances of gatsby-plugin-sharp in engines * update standalone-regenerate * normalize main config when loading themes * move deduplicaiton to plugin loading instead of themes loading * convert load-themes to TS * lint * update assertions * remove test that no longer make sense (cherry picked from commit 26f2b72)
…sharp (#37306) * fix(gatsby): handle initializing multiple instances of gatsby-plugin-sharp * fix(gatsby): handle initializing multiple instances of gatsby-plugin-sharp in engines * update standalone-regenerate * normalize main config when loading themes * move deduplicaiton to plugin loading instead of themes loading * convert load-themes to TS * lint * update assertions * remove test that no longer make sense (cherry picked from commit 26f2b72)
Description
Fix for
errors when there's multiple instances of gatsby-plugin-sharp package (for themes scenarios, when there might be different versions and package manager doesn't or can't dedupe)
Explanation of changes:
gatsby-plugin-sharp
which most often doesn't have any options and was deduped because it's specified just asgatsby-plugin-sharp
- this meant that some instances ofgatsby-plugin-sharp
were not initiated at all. This PR moves it to after we resolve plugins where we can check actual plugin packages instances when deduping. This also required update toimport-gatsby-plugin
to be able to not just use plugin name, but different identifier - forgatsby build/develop
we rely onplugin.resolve
property. I did have to keep fallback toname
forgatsby-worker
, as when trying to use it we are losing which instance it is for.resolve
property from engines I needed yet another way to adjustimport-gatsby-plugin
and used simpleimportKey
which is 1-indexed counter (and it represent just the index of plugin in the plugins listload-themes/index.js
to typescriptDocumentation
Related Issues