Skip to content

Commit 5d7bcdc

Browse files
0x80KyleAMathews
authored andcommitted
Allow use of babel options (#830)
1 parent b0ce38b commit 5d7bcdc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/gatsby/lib/utils/babel-config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import apiRunnerNode from "./api-runner-node"
2121
*
2222
*/
2323
function resolvePlugin(pluginName, directory, type) {
24+
// When a plugin is specified with options in babelrc, the pluginName contains
25+
// the array with [name, options]. In that case we extract the name.
26+
pluginName = Array.isArray(pluginName) ? pluginName[0] : pluginName
27+
2428
const gatsbyPath = path.resolve(__dirname, `..`, `..`)
2529
const plugin =
2630
resolve(`babel-${type}-${pluginName}`, directory) ||
@@ -32,8 +36,9 @@ function resolvePlugin(pluginName, directory, type) {
3236
? pluginName
3337
: `babel-${type}-${pluginName}`
3438
const pluginInvariantMessage = `
35-
You are trying to use a Babel plugin which Gatsby cannot find. You
36-
can install it using "npm install --save ${name}".
39+
You are trying to use a Babel plugin or preset which Gatsby cannot find: ${pluginName}
40+
41+
You can install it using "npm install --save ${name}".
3742
3843
You can use any of the Gatsby provided plugins without installing them:
3944
- babel-plugin-add-module-exports

0 commit comments

Comments
 (0)