babel-plugin-object-to-json-parse 🚀
This repository is inspired by this article
As long as the JSON string is only evaluated once, the JSON.parse approach is much faster compared to the JavaScript object literal, especially for cold loads.
Object to JSON.parse
This plugin converts from object literal to JSON.parse (example)
const data = { foo: 42, bar: 1337 };
const data = JSON.parse('{"foo":42,"bar":1337}');
How to use
Install
$ npm install babel-plugin-object-to-json-parse -D
or
$ yarn babel-plugin-object-to-json-parse -D
setup .babelrc
{
"plugins": ["object-to-json-parse"]
}
Development
Setup
$ git clone git@github.com:nd-02110114/babel-plugin-object-to-json-parse.git
$ cd babel-plugin-object-to-json-parse
$ yarn install
Tips
// example
$ yarn build && yarn example
// test
$ yarn test