budibase/packages/builder/src/builderStore/loadComponentLibraries.js

20 lines
572 B
JavaScript
Raw Normal View History

2019-08-19 22:18:23 +02:00
import { map } from "lodash/fp";
export const loadLibs = async (appName, appPackage) => {
const allLibraries = {};
for(let lib of appPackage.pages.componentLibraries) {
2019-08-27 08:32:56 +02:00
const libModule = await import(makeLibraryUrl(appName, lib));
2019-08-19 22:18:23 +02:00
allLibraries[lib] = libModule;
}
return allLibraries;
}
2019-08-27 08:32:56 +02:00
export const loadLib = async (appName, lib, allLibs) => {
allLibs[lib] = await import(makeLibraryUrl(appName, lib));
return allLibs;
}
export const makeLibraryUrl = (appName, lib) =>
2019-09-06 14:04:23 +02:00
`/${appName}/componentlibrary?lib=${encodeURI(lib)}`