Skip to content
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): don't remove onPluginInit in graphql-engine #34558

Merged
merged 1 commit into from
Jan 21, 2022

Conversation

pieh
Copy link
Contributor

@pieh pieh commented Jan 21, 2022

Description

#33484 introduced a regression where gatsby-plugin-sharp doesn't init in engine and that result in errors on usage:

error Gatsby-plugin-sharp wasn't setup correctly in gatsby-config.js. Make sure you add it to the plugins array.

Currently

if (coreSupportsOnPluginInit) {
// to properly initialize plugin in worker (`onPreBootstrap` won't run in workers)
if (_CFLAGS_.GATSBY_MAJOR === `4`) {
exports.onPluginInit = async ({ actions }, pluginOptions) => {
setActions(actions)
setPluginOptions(pluginOptions)
}
} else {
exports.unstable_onPluginInit = async ({ actions }, pluginOptions) => {
setActions(actions)
setPluginOptions(pluginOptions)
}
}
}

is getting bundled as

if (coreSupportsOnPluginInit) {
  // to properly initialize plugin in worker (`onPreBootstrap` won't run in workers)
  if (true) {} else {}
}

With this change it becomes

if (coreSupportsOnPluginInit) {
  // to properly initialize plugin in worker (`onPreBootstrap` won't run in workers)
  if (true) {
    exports.onPluginInit = async ({
      actions
    }, pluginOptions) => {
      setActions(actions);
      setPluginOptions(pluginOptions);
    };
  } else {}
}

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jan 21, 2022
@pieh pieh added topic: render-mode Related to Gatsby's different rendering modes and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jan 21, 2022
@wardpeet wardpeet added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Jan 21, 2022
@pieh pieh merged commit 135e080 into master Jan 21, 2022
@pieh pieh deleted the fix/engines/plugin-init branch January 21, 2022 14:25
LekoArts pushed a commit that referenced this pull request Jan 24, 2022
LekoArts pushed a commit that referenced this pull request Jan 24, 2022
…4573)

Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
@LekoArts
Copy link
Contributor

Published in gatsby@4.5.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes topic: render-mode Related to Gatsby's different rendering modes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants