UNPKG

babel-plugin-react-css-modules

Version:

Transforms styleName to className using compile time CSS module resolution.

42 lines (31 loc) 1.17 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _babelTypes = require('babel-types'); var _babelTypes2 = _interopRequireDefault(_babelTypes); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Creates an AST representation of an InputObjectType shape object. */ const createObjectExpression = (t, object) => { const properties = []; for (const name of Object.keys(object)) { const value = object[name]; let newValue; // eslint-disable-next-line no-empty if (t.isAnyTypeAnnotation(value)) {} else if (typeof value === 'string') { newValue = t.stringLiteral(value); } else if (typeof value === 'object') { newValue = createObjectExpression(t, value); } else if (typeof value === 'boolean') { newValue = t.booleanLiteral(value); } else { throw new TypeError('Unexpected type: ' + typeof value); } properties.push(t.objectProperty(t.stringLiteral(name), newValue)); } return t.objectExpression(properties); }; exports.default = createObjectExpression; //# sourceMappingURL=createObjectExpression.js.map