-
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
refactor(core): Make load plugins modular, prepare for TS #34813
Conversation
ecc45f6
to
9e187e9
Compare
ee33e48
to
ae796a0
Compare
ae796a0
to
a6f5d38
Compare
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.
I didn't do a full review yet but this caught my eye :)
@@ -1,29 +1,23 @@ | |||
import reporter from "gatsby-cli/lib/reporter" |
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 file was renamed from load-config-and-plugins
to load-config/index.ts
and now exports loadConfig
@@ -1,105 +1,23 @@ | |||
import _ from "lodash" |
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.
Only functions were extracted out of this file and put into their own files
@@ -0,0 +1,154 @@ | |||
import { slash } from "gatsby-core-utils" |
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 file used to be load-plugins/load
and was imported elsewhere like import { loadPlugins as loadPluginsInternal } from "./load"
. Name is was changed to be explicit
@@ -0,0 +1,90 @@ | |||
import { IPluginInfo, PluginRef } from "./types" |
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 function used to be nested in loadPlugins
and was moved to own file
const pluginName = isString(plugin) ? plugin : plugin.resolve | ||
|
||
// Handle local plugins | ||
const { validLocalPlugin, localPluginPath = `` } = checkLocalPlugin( |
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 file is the same except the check logic for local plugins was moved to a util (checkLocalPlugin
) so it can be re-used in the TS feature later
@@ -0,0 +1,41 @@ | |||
import { PluginRef } from "../types" |
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 file has the same logic as that that existed before but flattened with early returns instead of nested conditionals
@@ -0,0 +1,17 @@ | |||
import fs from "fs" |
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.
No change, createFileContentHash
was extracted out and pasted in own file
@@ -0,0 +1,19 @@ | |||
import { createNodeId } from "../../../utils/create-node-id" |
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.
No change, createPluginId
was extracted out and pasted in own file
@@ -0,0 +1,42 @@ | |||
import { IPluginInfo } from "../types" |
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.
No change, flattenPlugins
was extracted out and pasted in own file
@@ -0,0 +1,10 @@ | |||
import { ExportType, ICurrentAPIs } from "../validate" |
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.
No change, getAPI
was extracted out and pasted in own file
@@ -0,0 +1,39 @@ | |||
import { silent as resolveFromSilent } from "resolve-from" |
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.
No change, cloud related functions were extracted out and pasted in this file
@@ -0,0 +1,35 @@ | |||
import { ISiteConfig, IRawSiteConfig } from "../types" |
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.
No change, normalize functions were extracted out and pasted in this file
Description
This refactors parts of our core Gatsby bootstrap load plugins logic to prepare for local plugin TS support in #34776.
Put up against
master
since tests are not passing yet in the TS feature branch, and we want to make sure this does not change any existing behavior.What this PR does:
loadConfigAndPlugins
into two functions so we can compile local plugin gatsby files afterloadConfig
and beforeloadPlugins
After merging, we can:
Documentation
No docs change needed, internal