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

31 lines
872 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
2019-09-22 06:02:33 +02:00
export const loadLibUrls = (appName, appPackage) => {
const allLibraries = [];
for(let lib of appPackage.pages.componentLibraries) {
const libUrl = makeLibraryUrl(appName, lib);
allLibraries.push({libName:lib, importPath:libUrl});
}
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-09 06:23:41 +02:00
`/_builder/${appName}/componentlibrary?lib=${encodeURI(lib)}`