Skip to content

Commit 4c929bd

Browse files
authored
Fixes #63
Append a the `react-intl` babel plugin only when the user didn’t already do this themself
1 parent c997462 commit 4c929bd

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/extract-react-intl/index.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,25 @@ 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+
presets.unshift({
110+
plugins: [
111+
[
112+
babelPluginReactIntl,
113+
Object.entries(pluginOptions).reduce((acc, [key, value]) => {
114+
if (babelPluginReactIntlOptions.includes(key)) {
115+
return { ...acc, [key]: value }
116+
}
117+
return acc
118+
}, {})
119+
]
114120
]
115-
]
116-
})
121+
})
122+
}
117123

118124
const extractFromFile = async (file: string) => {
119125
const babelOpts = {

0 commit comments

Comments
 (0)