UNPKG

react-imported-component

Version:
14 lines (13 loc) 621 B
import { markMeta } from './metadata'; import { markerOverlap } from './utils'; const getMarkedMeta = (marks, mapping) => { if (markMeta.length === 0) { throw new Error('react-imported-component: no import meta-information found. Have you imported async-requires?'); } return Array.from(new Set(markMeta .filter(meta => markerOverlap(meta.mark, marks)) .map(mapping) .filter(Boolean)).values()); }; export const getMarkedChunks = (marks) => getMarkedMeta(marks, meta => meta.chunkName); export const getMarkedFileNames = (marks) => getMarkedMeta(marks, meta => meta.fileName);