-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Remove obsolete
unstable_onPluginInit
codepaths (#37176)
- Loading branch information
Showing
5 changed files
with
34 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,13 @@ | ||
import { NodePluginArgs } from "gatsby" | ||
|
||
import type { GatsbyNode } from "gatsby" | ||
import { ERROR_MAP } from "./error-map" | ||
|
||
export { sourceNodes } from "./source-nodes" | ||
export { createResolvers } from "./create-resolvers" | ||
export { pluginOptionsSchema } from "./plugin-options-schema" | ||
export { createSchemaCustomization } from "./create-schema-customization" | ||
|
||
const initializePlugin = ({ reporter }: NodePluginArgs): void => { | ||
export const onPluginInit: GatsbyNode["onPluginInit"] = ({ | ||
reporter, | ||
}): void => { | ||
reporter.setErrorMap(ERROR_MAP) | ||
} | ||
|
||
let coreSupportsOnPluginInit: `unstable` | `stable` | undefined | ||
|
||
try { | ||
const { isGatsbyNodeLifecycleSupported } = require(`gatsby-plugin-utils`) | ||
if (isGatsbyNodeLifecycleSupported(`onPluginInit`)) { | ||
coreSupportsOnPluginInit = `stable` | ||
} else if (isGatsbyNodeLifecycleSupported(`unstable_onPluginInit`)) { | ||
coreSupportsOnPluginInit = `unstable` | ||
} | ||
} catch (e) { | ||
console.error(`Could not check if Gatsby supports onPluginInit lifecycle`) | ||
} | ||
|
||
if (coreSupportsOnPluginInit === `unstable`) { | ||
// need to conditionally export otherwise it throws an error for older versions | ||
exports.unstable_onPluginInit = initializePlugin | ||
} else if (coreSupportsOnPluginInit === `stable`) { | ||
exports.onPluginInit = initializePlugin | ||
} else { | ||
exports.onPreInit = initializePlugin | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters