Package Exports
- babel-plugin-jsx-attributes-array-to-object
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-plugin-jsx-attributes-array-to-object) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
babel-plugin-jsx-attributes-array-to-object
A tool for transforming jsx attributes array to object.
example
var a = { color: 'red' };
<div style={[a, { color: 'gray' }]}></div>and the configure like this:
// .babelrc
[
syntaxJSX,
[require('babel-plugin-jsx-attributes-array-to-object
'), { attributes: ['style'] }],
]the code will be transformed:
var a = {
color: 'red'
};
<div style={__mergeObject(a, {
color: 'gray'
})}></div>;
function __mergeObject(...args) {
return args.reduce((obj, next) => {
obj = Object.assign(Object.assign({}, obj), next);
return obj;
}, {});
}Usage
Step 1: Install
yarn add --dev babel-plugin-jsx-attributes-array-to-objector
npm install --save-dev babel-plugin-jsx-attributes-array-to-objectStep 1: Configure .babelrc
{
plugins: [
[require('babel-plugin-jsx-attributes-array-to-object')]
]
}