quangbuule / extract-hoc

A Babel plugin that enables react-hot-loader to work on HoCs.
25 stars 2 forks source link

Breaks react-intl defineMessages #2

Open jkettmann opened 6 years ago

jkettmann commented 6 years ago

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.

quangbuule commented 6 years ago

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

gatanasov1 commented 6 years ago

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