From b5a084611fc3ca470ae3fafb3a37b94979448fbe Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Thu, 2 May 2024 11:55:20 +0200 Subject: [PATCH] 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 --- public/app/features/plugins/plugin_loader.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/app/features/plugins/plugin_loader.ts b/public/app/features/plugins/plugin_loader.ts index 86fa82d8897..7cafe296a60 100644 --- a/public/app/features/plugins/plugin_loader.ts +++ b/public/app/features/plugins/plugin_loader.ts @@ -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;