wix-style-react
Version:
20 lines (14 loc) • 556 B
JavaScript
const path = require('path');
const components = require('../.wuf/components.json');
const componentsList = Object.entries(components).reduce(
(a, [name, definition]) => [...a, { name, componentPath: definition.path }],
[],
);
const cwd = path.resolve(__dirname, '..');
const defaultOrRoot = object => object.default || object;
const allComponents = componentsList.reduce((a, { name, componentPath }) => {
const ref = require(path.resolve(cwd, componentPath));
a[name] = defaultOrRoot(ref);
return a;
}, {});
module.exports = allComponents;