The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/plugins/loader/utils.ts

24 lines
863 B

import { SystemJS, config } from '@grafana/runtime';
import { sandboxPluginDependencies } from '../sandbox/plugin_dependencies';
import { SHARED_DEPENDENCY_PREFIX } from './constants';
export function buildImportMap(importMap: Record<string, System.Module>) {
return Object.keys(importMap).reduce<Record<string, string>>((acc, key) => {
// Use the 'package:' prefix to act as a URL instead of a bare specifier
const module_name = `${SHARED_DEPENDENCY_PREFIX}:${key}`;
// expose dependency to SystemJS
SystemJS.set(module_name, importMap[key]);
// expose dependency to sandboxed plugins
sandboxPluginDependencies.set(key, importMap[key]);
acc[key] = module_name;
return acc;
}, {});
}
export function isHostedOnCDN(path: string) {
return Boolean(config.pluginsCDNBaseURL) && path.startsWith(config.pluginsCDNBaseURL);
}