Among the very first steps performed in Gatsby’s bootstrap is loading all the plugins configured in gatsby-config.js, as well as internal Gatsby plugins that come with the core framework. Gatsby saves these loaded plugins to Redux using the flattenedPlugins
namespace. In Redux, each plugin has the fields listed in Table 14-1.
NOTE
For more information about how Gatsby leverages Redux for data storage, consult the Gatsby documentation’s guide to data storage in Redux.
Field | Description |
---|---|
resolve | The absolute path to the plugin’s directory |
id | A concatenated string consisting of Plugin and a space followed by the name of the plugin; e.g., Plugin my-plugin |
name | The name of the plugin; e.g., my-plugin |
version | The version according to the plugin definition in package.json; if the plugin is a local plugin, one is generated from the file’s hash |
pluginOptions | The plugin options as configured in gatsby-config.js |
nodeAPIs | The list of Gatsby Node APIs implemented by the plugin, e.g., [`sourceNodes`, `onCreateNode` ...] |
browserAPIs | The list of Gatsby Browser APIs implemented by the plugin |
ssrAPIs | The list of Gatsby SSR APIs implemented by the plugin |
To view the Gatsby codebase itself, you can look at the GitHub repository, clone the Gatsby framework, or open node_modules/gatsby in any existing Gatsby project. The logic governing this portion of the Gatsby bootstrap can be found in the Gatsby framework within the src/bootstrap/load-plugins directory, where validate.js performs a lookup from each of the Gatsby APIs implemented by the plugins and saves the lookup result to Redux under api-to-plugins
.
Leave a Reply