Sandbox: Fix sandbox not loading SystemJs.module objects correctly inside plugins (#74445)

This commit is contained in:
Esteban Beltran 2023-09-06 15:46:31 +02:00 committed by GitHub
parent 4a4f759b2a
commit ae858fcdd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -2,4 +2,4 @@
* Map with all dependencies that are exposed to plugins sandbox * Map with all dependencies that are exposed to plugins sandbox
* e.g.: @grafana/ui, @grafana/data, etc... * e.g.: @grafana/ui, @grafana/data, etc...
*/ */
export const sandboxPluginDependencies = new Map<string, unknown>([]); export const sandboxPluginDependencies = new Map<string, System.Module>([]);

View File

@ -189,7 +189,11 @@ function resolvePluginDependencies(deps: string[]) {
// resolve dependencies // resolve dependencies
const resolvedDeps: CompartmentDependencyModule[] = []; const resolvedDeps: CompartmentDependencyModule[] = [];
for (const dep of deps) { for (const dep of deps) {
const resolvedDep = sandboxPluginDependencies.get(dep); let resolvedDep = sandboxPluginDependencies.get(dep);
if (resolvedDep?.__useDefault) {
resolvedDep = resolvedDep.default;
}
if (!resolvedDep) { if (!resolvedDep) {
throw new Error(`[sandbox] Could not resolve dependency ${dep}`); throw new Error(`[sandbox] Could not resolve dependency ${dep}`);
} }