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

28 lines
794 B
JavaScript
Raw Normal View History

2019-08-19 22:18:23 +02:00
export const loadLibs = async (appName, appPackage) => {
const allLibraries = {}
for (let lib of appPackage.pages.componentLibraries) {
const libModule = await import(makeLibraryUrl(appName, lib))
allLibraries[lib] = libModule
}
2019-08-19 22:18:23 +02:00
return allLibraries
2019-08-19 22:18:23 +02:00
}
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 })
}
2019-09-22 06:02:33 +02:00
return allLibraries
2019-09-22 06:02:33 +02:00
}
2019-08-27 08:32:56 +02:00
export const loadLib = async (appName, lib, allLibs) => {
allLibs[lib] = await import(makeLibraryUrl(appName, lib))
return allLibs
2019-08-27 08:32:56 +02:00
}
export const makeLibraryUrl = (appName, lib) =>
`/_builder/${appName}/componentlibrary?lib=${encodeURI(lib)}`