mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix: Always fetch plugin css with Systemjs (#87211)
* fix(plugins): fetch strategy should always be used for css/json/wasm/html * refactor(plugins): prefer checking for js file type rather than list of other file types
This commit is contained in:
@@ -28,12 +28,14 @@ SystemJS.addImportMap({ imports });
|
||||
|
||||
const systemJSPrototype: SystemJSWithLoaderHooks = SystemJS.constructor.prototype;
|
||||
|
||||
// This instructs SystemJS to load a plugin using fetch and eval if it returns a truthy value, otherwise it will load the plugin using a script tag.
|
||||
// We only want to fetch and eval plugins that are hosted on a CDN or are Angular plugins.
|
||||
// This instructs SystemJS to load plugin assets using fetch and eval if it returns a truthy value, otherwise
|
||||
// it will load the plugin using a script tag. We only want to fetch and eval files that are
|
||||
// hosted on a CDN, are related to Angular plugins or are not js files.
|
||||
systemJSPrototype.shouldFetch = function (url) {
|
||||
const pluginInfo = getPluginFromCache(url);
|
||||
const jsTypeRegEx = /^[^#?]+\.(js)([?#].*)?$/;
|
||||
|
||||
return isHostedOnCDN(url) || Boolean(pluginInfo?.isAngular);
|
||||
return isHostedOnCDN(url) || Boolean(pluginInfo?.isAngular) || !jsTypeRegEx.test(url);
|
||||
};
|
||||
|
||||
const originalImport = systemJSPrototype.import;
|
||||
|
||||
Reference in New Issue
Block a user