react-intl.macro
react-intl.macro copied to clipboard
Cannot use defineMessages on an object reference
I think this might be similar to #81, but I'm getting compiler errors instead of undefined keys.
Passing a predefined object reference to defineMessages fails, I'm guessing the code isn't following the reference in the Babel AST and instead assuming an object is directly defined:
import { defineMessages } from "react-intl.macro"
const messages = {
key: { id: "key", defaultMessage: "Default Message" }
}
defineMessages(messages)
this fails with:
TypeError: react-intl.macro: properties.map is not a function Learn more: https://www.npmjs.com/package/react-intl.macro
at Array.map (<anonymous>)
My use case is I have a shared library where the messages are defined, but the build process isn't working correctly for the sub module (different issues with Rollup). So I'm trying to import the messages in my app and forward them to defineMessages so they get picked up when I build the available translations.
This is unfortunately not possible. Macros are limited, they can hardly follow reference in same file. With import this is really mission impossible.