require js remove definition to force reload

Viewed 7984

For testing purposes I am trying to remove some amd modules and reload updated versions from the server - with the goal of not refreshing the browser.

I am currently doing the following but the browser still doesn't reload the items from the network.

var scripts = document.getElementsByTagName('script');
var context = require.s.contexts['_'];
for (var key in context.defined) {
  if(key.indexOf("tests")>-1){
  requirejs.undef(key);
  for (var i = scripts.length - 1; i >= 0; i--) {
  var script = scripts[i];
  var attr = script.getAttribute('data-requiremodule')
    if (attr === key){
    script.parentNode.removeChild(script);
    }
  }}

It deletes the references from the context and removes the script tags successfully. But alas...

Does anyone know the mechanism to clear all the references from requirejs?

Any help much appreciated

2 Answers
Related