res-react-intl
Reason/OCaml PPX generating ReactIntl id
(short MD5) from defaultMessage
.
Example
Input:
// Demo.reopen ReactIntl; module Msg = { [@intl.messages]; let hello = {defaultMessage: "Hello"};}; [@react.component]let make = () => { <FormattedMessage defaultMessage="Some default message" />;};
Output:
// Demo.bs.js// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE'use strict' var React = var ReactIntl = var Msg = hello: id: '_8b1a9953' defaultMessage: 'Hello' { return React} var make = Demo exportsMsg = Msgexportsmake = make
Installation
yarn
or npm
on Bucklescript projects
With Install the PPX with yarn
or npm
yarn add res-react-intl bs-react-intl# Or npm install res-react-intl bs-react-intl
And add the PPX in your bsconfig.json
file:
Extract the messages:
res-react-intl-extract --allow-duplicates src
Developing
After cloning the repository, you should run both esy
and yarn
to install
dependencies. res-react-intl
uses esy
for managing the important dependencies,
and yarn
is used solely for pre-commit linting/formatting of Reason files.
Relevant commands
esy build
-> Builds the projectesy watch
-> Watches for changes to Reason/OCaml files in the entire project, including in the/test
directoryesy test_native
-> Runs the native tests (intest/native
)esy test_bs
-> Runs the BuckleScript tests (intest/bucklescript
)
Releasing
- Bump the version of the ppx in
esy.json
onmaster
(we use semantic versioning) - Create and push a new tag
$ git checkout master
$ git tag vx.y.z
$ git push origin vx.y.z
- Create detailed release notes for the new version, following the
Added/Changed/Fixed/Removed
format. Note that the new version of the PPX will automatically be pushed to NPM and a release will be created on GitHub.