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

Skip to content

Commit 70938cd

Browse files
committed
conditionally pass through the preset option rather than undefined
1 parent ac6de4f commit 70938cd

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,17 @@ describe(`babel-preset-gatsby`, () => {
4040
}),
4141
])
4242
})
43+
44+
it(`Allows to configure react importSource`, () => {
45+
const { presets } = preset(null, {
46+
reactImportSource: `@emotion/react`,
47+
})
48+
49+
expect(presets[1]).toEqual([
50+
expect.stringContaining(path.join(`@babel`, `preset-react`)),
51+
expect.objectContaining({
52+
importSource: `@emotion/react`,
53+
}),
54+
])
55+
})
4356
})

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ export default function preset(_, options = {}) {
8383
: `React.createElement`,
8484
development: stage === `develop`,
8585
runtime: options.reactRuntime || `classic`,
86-
importSource: options.reactImportSource,
86+
...(options.reactImportSource
87+
? { importSource: options.reactImportSource }
88+
: {}),
8789
},
8890
],
8991
],

0 commit comments

Comments
 (0)