Fix cache busting for systemjs imports for plugins

* everything imported via systemjs in the path `plugin/` will get a
 timestamp appended for cache busting
* timestamp is set once on page load
* plugin css loader gets cache buster too
This commit is contained in:
David Kaltschmidt
2018-05-29 12:01:10 +02:00
parent 2d5ec9b9e4
commit 8bcd55d221
2 changed files with 22 additions and 23 deletions

View File

@@ -27,6 +27,13 @@ import 'rxjs/add/observable/from';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/combineAll';
// add cache busting
const bust = `?_cache=${Date.now()}`;
function locate(load) {
return load.address + bust;
}
System.registry.set('plugin-loader', System.newModule({ locate: locate }));
System.config({
baseURL: 'public',
defaultExtension: 'js',
@@ -40,23 +47,14 @@ System.config({
css: 'vendor/plugin-css/css.js',
},
meta: {
'*': {
'plugin*': {
esModule: true,
authorization: true,
loader: 'plugin-loader',
},
},
});
// add cache busting
var systemLocate = System.locate;
System.cacheBust = '?bust=' + Date.now();
System.locate = function(load) {
var System = this;
return Promise.resolve(systemLocate.call(this, load)).then(function(address) {
return address + System.cacheBust;
});
};
function exposeToPlugin(name: string, component: any) {
System.registerDynamic(name, [], true, function(require, exports, module) {
module.exports = component;