Skip to content

Commit

Permalink
Fixes #63
Browse files Browse the repository at this point in the history
Append a the `react-intl` babel plugin only when the user didn’t already do this themself
  • Loading branch information
lensbart committed Jan 14, 2020
1 parent c997462 commit 4c929bd
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/extract-react-intl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,25 @@ export default async (
const presets = babelrc.presets || []
const plugins = babelrc.plugins || []

presets.unshift({
plugins: [
[
babelPluginReactIntl,
Object.entries(pluginOptions).reduce((acc, [key, value]) => {
if (babelPluginReactIntlOptions.includes(key)) {
return { ...acc, [key]: value }
}
return acc
}, {})
if (
!plugins.find(plugin =>
(Array.isArray(plugin) ? plugin[0] : plugin) === 'react-intl'
)
) {
presets.unshift({
plugins: [
[
babelPluginReactIntl,
Object.entries(pluginOptions).reduce((acc, [key, value]) => {
if (babelPluginReactIntlOptions.includes(key)) {
return { ...acc, [key]: value }
}
return acc
}, {})
]
]
]
})
})
}

const extractFromFile = async (file: string) => {
const babelOpts = {
Expand Down

0 comments on commit 4c929bd

Please sign in to comment.