How the @intl.messages ppx is handled

Hi there !

I’m moving my projects to ReScript and I don’t understand how the ppx @intl.messages is interpreted without being in my config ?
As far I know, we have to add some config in bsconfig.json to make it works right ?

For the context, we were using our own fork of https://github.com/cknitt/bs-react-intl-extractor (we removed the needs of id) but transitioning to ReScript was a bit hard since I have no knowledge of this kind of dev. Btw I made a PR to the initial project https://github.com/cknitt/bs-react-intl-extractor/pull/70

Thanks !

Probably @cknitt can give the most qualified answer.

I just briefely checked the source code: it looks like @@​intl.messages isn’t used for a ppx. If there isn’t any ppx setup to handle this extension the compiler ignores it I believe?
This means the rescript compiler doesn’t act on this extension.

The extractor CLI uses the rescript parser. The CLI now does look for such extensions to identified value bindings which shall be extracted.

Edit: Thanks for the link to the repo btw. It tried to use the rescript parser as a libraray some time ago and failed miserably. Hopefully this gives me some new ideas. :smiley:

Exactly, this is not a PPX but a standalone extraction utility.

The compiler ignores the @intl.messages attribute. The separately run bs-react-intl-extractor utility parses the source files and traverses the AST of each file to extract all the messages.

3 Likes

That’s why ! :smiley:

Thanks for your response it’s more clear now