evenchange4 / react-intl.macro

Extract react-intl messages with babel-plugin-macros.
MIT License
37 stars 6 forks source link

Errors with untranspiled code in `intl-messageformat-parser` #84

Closed MrToph closed 5 years ago

MrToph commented 5 years ago

I'm using create-react-app with typescript and react-intl.

When running the build / extract script with imports from react-intl everything works fine. As soon as I change it to react-intl.macro the scripts fail:

app/node_modules/babel-plugin-react-intl/lib/print-icu-message.js:6
import parser from 'intl-messageformat-parser';
       ^^^^^^

SyntaxError: Unexpected identifier
jeffsheets commented 5 years ago

I'm seeing the same error today after upgrading the Create React App react-scripts from 3.0.0 to 3.0.1. The error did not exist in react-scripts 3.0.0. Rolling back to 3.0.0 seems to be working so far

liemdo commented 5 years ago

Mine doesn't work even after rolling back to 3.0.0.

KyorCode commented 5 years ago

Same problem here.

wittlesouth commented 5 years ago

Same here

Anticom commented 5 years ago

Changing the import to an ES5 import using require fixes it but i can't rely on patching my dependencies. There's an issue over at babel-plugin-react-intl but i think the issue lies in this package.

jeffsheets commented 5 years ago

I was able to temporarily get around this by using a yarn resolution block like this:

  "resolutions": {
    "react-intl.macro/babel-plugin-react-intl": "3.0.1"
  },
juanghurtado commented 5 years ago

Same problem here:

node_modules/babel-plugin-react-intl/lib/print-icu-message.js:6
import parser from 'intl-messageformat-parser';
       ^^^^^^

SyntaxError: Unexpected identifier

Any updates?

I'm not using yarn, so the resolution block is not an option to me. I know there are solutions like that for NPM, but I would prefer not to mess around to fix something that should be handled by the dependency itself.

evenchange4 commented 5 years ago

The import issue should be fixed by https://github.com/evenchange4/react-intl.macro/commit/a7fa61192ef75bdfc61fc9db6a880329be7dc2e0 . Please try version v0.3.7.

MrToph commented 5 years ago

This solved the issue for me, thanks! @evenchange4