JSON to JavaScript tree-shakeable constants.
npm add json-to-js-const
const convert from 'json-to-js-const';
const result = convert({ intValue: -12, strValue: 'haha"\'', nullValue: null, arrayValue: [32, 'wow', null] });
console.log(result);
It prints:
/******************************************************************************************
* This code was automatically generated by json-to-js-const.
* Do not edit this file manually, your changes will be overwritten.
******************************************************************************************/
export const intValue = -12;
export const strValue = 'haha"\'';
export const nullValue = null;
export const arrayValue = [32, 'wow', null];