Skip to content

Commit f17c6fc

Browse files
authored
Merge pull request #64 from lensbart/patch-1
Fixes #63
2 parents 36aef16 + 4b83d8c commit f17c6fc

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
201201
<td align="center"><a href="http://ddem.us/"><img src="https://avatars1.githubusercontent.com/u/290457?v=4" width="100px;" alt="Gregor MacLennan"/><br /><sub><b>Gregor MacLennan</b></sub></a><br /><a href="https://github.com/akameco/extract-react-intl-messages/commits?author=gmaclennan" title="Code">💻</a></td>
202202
<td align="center"><a href="https://github.com/zarv1k"><img src="https://avatars1.githubusercontent.com/u/6296643?v=4" width="100px;" alt="Dmitry Zarva"/><br /><sub><b>Dmitry Zarva</b></sub></a><br /><a href="https://github.com/akameco/extract-react-intl-messages/commits?author=zarv1k" title="Code">💻</a></td>
203203
<td align="center"><a href="https://github.com/panpanc"><img src="https://avatars2.githubusercontent.com/u/29132669?v=4" width="100px;" alt="Michael Pan"/><br /><sub><b>Michael Pan</b></sub></a><br /><a href="#example-panpanc" title="Examples">💡</a></td>
204+
<td align="center"><a href="https://github.com/lensbart"><img src="https://avatars2.githubusercontent.com/u/20876627?s=460&v=4" width="100px;" alt="Bart Lens"/><br /><sub><b>Bart Lens</b></sub></a><br /><a href="https://github.com/akameco/extract-react-intl-messages/commits?author=lensbart" title="Code">💻</a></td>
204205
</tr>
205206
</table>
206207

src/extract-react-intl/index.ts

+19-12
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,26 @@ export default async (
101101
const presets = babelrc.presets || []
102102
const plugins = babelrc.plugins || []
103103

104-
presets.unshift({
105-
plugins: [
106-
[
107-
babelPluginReactIntl,
108-
Object.entries(pluginOptions).reduce((acc, [key, value]) => {
109-
if (babelPluginReactIntlOptions.includes(key)) {
110-
return { ...acc, [key]: value }
111-
}
112-
return acc
113-
}, {})
104+
if (
105+
!plugins.find(plugin =>
106+
(Array.isArray(plugin) ? plugin[0] : plugin) === 'react-intl'
107+
)
108+
) {
109+
// Append a the `react-intl` babel plugin only when it isn’t already included in the babel config
110+
presets.unshift({
111+
plugins: [
112+
[
113+
babelPluginReactIntl,
114+
Object.entries(pluginOptions).reduce((acc, [key, value]) => {
115+
if (babelPluginReactIntlOptions.includes(key)) {
116+
return { ...acc, [key]: value }
117+
}
118+
return acc
119+
}, {})
120+
]
114121
]
115-
]
116-
})
122+
})
123+
}
117124

118125
const extractFromFile = async (file: string) => {
119126
const babelOpts = {

0 commit comments

Comments
 (0)