extract-hoc icon indicating copy to clipboard operation
extract-hoc copied to clipboard

Breaks react-intl defineMessages

Open jkettmann opened this issue 7 years ago • 2 comments

This plugin seems to change unwanted functions, in my case defineMessages from react-intl.

My app contains code like following.

const messages = defineMessages({
  pageTitle: { id: 'App.pageTitle', defaultMessage: 'Page title' },
  metaDescription: { id: 'App.metaDescription', defaultMessage: 'The description to be displayed in google search results' },
})

When I start my app I get following error.

ERROR in ./client/pages/App/App.js
    Module build failed: SyntaxError: [React Intl] `defineMessages()` must be called with an object expression with values that are React Intl Message Descriptors, also defined as object expressions.

      12 | import Dialog from '../../components/Dialog'
      13 |
    > 14 | const messages = defineMessages({
         |                  ^
      15 |   pageTitle: { id: 'App.pageTitle', defaultMessage: 'Universal Relay Starter Kit' },
      16 |   metaDescription: { id: 'App.metaDescription', defaultMessage: 'The description to be displayed in google search results' },
      17 | })

You can run this branch to reproduce the error.

jkettmann avatar Nov 26 '17 09:11 jkettmann

This is very edge case, a PR for this is welcome.

quangbuule avatar Dec 08 '17 11:12 quangbuule

We've encountered this problem as well. Is there a known workaround?

gatanasov1 avatar Apr 19 '18 14:04 gatanasov1