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:
Jack Westbrook
2024-05-02 11:55:20 +02:00
committed by GitHub
parent 9f5ab38477
commit b5a084611f

View File

@@ -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;