MCPcopy Create free account
hub / github.com/alibaba/lowcode-engine / findComponent

Function findComponent

packages/utils/src/build-components.ts:60–80  ·  view source on GitHub ↗
(libraryMap: LibraryMap, componentName: string, npm?: IPublicTypeNpmInfo)

Source from the content-addressed store, hash-verified

58}
59
60function findComponent(libraryMap: LibraryMap, componentName: string, npm?: IPublicTypeNpmInfo) {
61 if (!npm) {
62 return accessLibrary(componentName);
63 }
64 // libraryName the key access to global
65 // export { exportName } from xxx exportName === global.libraryName.exportName
66 // export exportName from xxx exportName === global.libraryName.default || global.libraryName
67 // export { exportName as componentName } from package
68 // if exportName == null exportName === componentName;
69 // const componentName = exportName.subName, if exportName empty subName donot use
70 const exportName = npm.exportName || npm.componentName || componentName;
71 const libraryName = libraryMap[npm.package] || exportName;
72 const library = accessLibrary(libraryName);
73 const paths = npm.exportName && npm.subName ? npm.subName.split('.') : [];
74 if (npm.destructuring) {
75 paths.unshift(exportName);
76 } else if (isESModule(library)) {
77 paths.unshift('default');
78 }
79 return getSubComponent(library, paths);
80}
81
82/**
83 * 判断是否是一个混合组件,即 components 是一个对象,对象值是 React 组件

Callers 1

buildComponentsFunction · 0.85

Calls 3

isESModuleFunction · 0.90
accessLibraryFunction · 0.85
getSubComponentFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…