feat: gatherComponents
This commit is contained in:
parent
442826f287
commit
feb6feabf9
|
@ -13,7 +13,7 @@ const debug = D('@latus/core/gather');
|
||||||
|
|
||||||
export const hotGathered = new Map();
|
export const hotGathered = new Map();
|
||||||
|
|
||||||
const transformPath = (transformer, path) => {
|
export const transformPath = (transformer, path) => {
|
||||||
const parts = dirname(path).split('/');
|
const parts = dirname(path).split('/');
|
||||||
if ('.' === parts[0]) {
|
if ('.' === parts[0]) {
|
||||||
parts.shift();
|
parts.shift();
|
||||||
|
|
|
@ -16,6 +16,7 @@ export {
|
||||||
gatherFlat,
|
gatherFlat,
|
||||||
gatherWithLatus,
|
gatherWithLatus,
|
||||||
default as gather,
|
default as gather,
|
||||||
|
transformPath,
|
||||||
} from './gather';
|
} from './gather';
|
||||||
export {default as Middleware} from './middleware';
|
export {default as Middleware} from './middleware';
|
||||||
export {default as Latus} from './latus';
|
export {default as Latus} from './latus';
|
||||||
|
|
24
packages/react/src/gather-components.js
Normal file
24
packages/react/src/gather-components.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import {
|
||||||
|
camelCase,
|
||||||
|
transformPath,
|
||||||
|
} from '@latus/core';
|
||||||
|
|
||||||
|
export default (
|
||||||
|
context,
|
||||||
|
{
|
||||||
|
transformer = camelCase,
|
||||||
|
} = {},
|
||||||
|
) => () => (
|
||||||
|
Object.fromEntries(
|
||||||
|
context.keys()
|
||||||
|
.map(
|
||||||
|
(path) => {
|
||||||
|
const {default: Component} = context(path);
|
||||||
|
return [
|
||||||
|
transformPath(transformer, path),
|
||||||
|
Component,
|
||||||
|
];
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
|
@ -1,10 +1,12 @@
|
||||||
export {default as React} from 'react';
|
export {default as React} from 'react';
|
||||||
export * from 'react';
|
export * from 'react';
|
||||||
export {default as ReactDom} from 'react-dom';
|
export {default as ReactDom} from 'react-dom';
|
||||||
|
export {hot} from 'react-hot-loader';
|
||||||
export {default as PropTypes} from 'prop-types';
|
export {default as PropTypes} from 'prop-types';
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
export {LatusContext} from '@latus/react/client';
|
export {LatusContext} from '@latus/react/client';
|
||||||
|
export {default as gatherComponents} from './gather-components';
|
||||||
export {default as useEvent} from './hooks/use-event';
|
export {default as useEvent} from './hooks/use-event';
|
||||||
export {default as useLatus} from './hooks/use-latus';
|
export {default as useLatus} from './hooks/use-latus';
|
||||||
export {default as usePrevious} from './hooks/use-previous';
|
export {default as usePrevious} from './hooks/use-previous';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user