Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6007072

Browse files
author
Laurie
committed
throwing if runtime is wrong, move the logic out of the object
1 parent 70938cd commit 6007072

File tree

1 file changed

+11
-3
lines changed
  • packages/babel-preset-gatsby/src

1 file changed

+11
-3
lines changed

packages/babel-preset-gatsby/src/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ export default function preset(_, options = {}) {
5050
}
5151
}
5252

53+
let importSource = undefined
54+
55+
if (options.reactImportSource && options.reactRuntime !== `automatic`) {
56+
throw Error(
57+
`\`@babel/preset-react\` requires reactRuntime \`automatic\` in order to use \`importSource\`.`
58+
)
59+
} else if (options.reactImportSource) {
60+
importSource = options.reactImportSource
61+
}
62+
5363
return {
5464
presets: [
5565
[
@@ -83,9 +93,7 @@ export default function preset(_, options = {}) {
8393
: `React.createElement`,
8494
development: stage === `develop`,
8595
runtime: options.reactRuntime || `classic`,
86-
...(options.reactImportSource
87-
? { importSource: options.reactImportSource }
88-
: {}),
96+
importSource,
8997
},
9098
],
9199
],

0 commit comments

Comments
 (0)