2019-08-19 22:18:23 +02:00
|
|
|
export const loadLibs = async (appName, appPackage) => {
|
2020-02-03 10:24:25 +01:00
|
|
|
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
|
|
|
|
2020-02-03 10:24:25 +01: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) => {
|
2020-02-03 10:24:25 +01:00
|
|
|
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
|
|
|
|
2020-02-03 10:24:25 +01: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) => {
|
2020-02-03 10:24:25 +01:00
|
|
|
allLibs[lib] = await import(makeLibraryUrl(appName, lib))
|
|
|
|
return allLibs
|
2019-08-27 08:32:56 +02:00
|
|
|
}
|
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
export const makeLibraryUrl = (appName, lib) =>
|
|
|
|
`/_builder/${appName}/componentlibrary?lib=${encodeURI(lib)}`
|