Skip to content

Commit c947568

Browse files
authored
fix(gatsby): print real plugin loading error in verbose (#27664)
* fix(gatsby): print real plugin loading error in verbose * Use the reporter * Check for verbose
1 parent 21f24f8 commit c947568

File tree

1 file changed

+12
-3
lines changed
  • packages/gatsby/src/bootstrap/load-plugins

1 file changed

+12
-3
lines changed

packages/gatsby/src/bootstrap/load-plugins/load.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
ISiteConfig,
1818
} from "./types"
1919
import { PackageJson } from "../../.."
20+
import reporter from "gatsby-cli/lib/reporter"
2021

2122
function createFileContentHash(root: string, globPattern: string): string {
2223
const hash = crypto.createHash(`md5`)
@@ -118,9 +119,17 @@ export function resolvePlugin(
118119
version: packageJSON.version,
119120
}
120121
} catch (err) {
121-
throw new Error(
122-
`Unable to find plugin "${pluginName}". Perhaps you need to install its package?`
123-
)
122+
if (process.env.gatsby_log_level === `verbose`) {
123+
reporter.panicOnBuild(
124+
`plugin "${pluginName} threw the following error:\n`,
125+
err
126+
)
127+
} else {
128+
reporter.panicOnBuild(
129+
`There was a problem loading plugin "${pluginName}". Perhaps you need to install its package?\nUse --verbose to see actual error.`
130+
)
131+
}
132+
throw new Error(`unreachable`)
124133
}
125134
}
126135

0 commit comments

Comments
 (0)