react-intl-auto-id-ppx

2.0.1 • Public • Published

react-intl-auto-id-ppx

Actions Status NPM Version

Reason/OCaml PPX generating ReactIntl id (short MD5) from defaultMessage.

This package provides also bindings overrides from bs-react-intl.

Example

Input:

// Demo.re
open 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 = require('react')
var ReactIntl = require('react-intl')
 
var Msg = {
  hello: {
    id: '_8b1a9953',
    defaultMessage: 'Hello',
  },
}
 
function Demo(Props) {
  return React.createElement(ReactIntl.FormattedMessage, {
    id: '_0beb880a',
    defaultMessage: 'Some default message',
  })
}
 
var make = Demo
 
exports.Msg = Msg
exports.make = make

Installation

With yarn or npm on Bucklescript projects

Install the PPX with yarn or npm

yarn add --dev react-intl-auto-id-ppx
# Or 
npm install --dev react-intl-auto-id-ppx

And add the PPX in your bsconfig.json file:

{
  "ppx-flags": ["react-intl-auto-id-ppx/react-intl-auto-id-ppx"]
}

Developing

After cloning the repository, you should run both esy and yarn to install dependencies. react-intl-auto-id-ppx 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 project
  • esy watch -> Watches for changes to Reason/OCaml files in the entire project, including in the /test directory
  • esy test_native -> Runs the native tests (in test/native)
  • esy test_bs -> Runs the BuckleScript tests (in test/bucklescript)

Releasing

  1. Bump the version of the ppx in esy.json on master (we use semantic versioning)
  2. Create and push a new tag
$ git checkout master
$ git tag vx.y.z
$ git push origin vx.y.z
  1. 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.

Background/Sources

Readme

Keywords

none

Package Sidebar

Install

npm i react-intl-auto-id-ppx

Weekly Downloads

3

Version

2.0.1

License

MIT

Unpacked Size

38.4 MB

Total Files

10

Last publish

Collaborators

  • simon.degraeve