Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove definition to force reload #412

Closed
bazjapan opened this issue Aug 10, 2012 · 2 comments
Closed

remove definition to force reload #412

bazjapan opened this issue Aug 10, 2012 · 2 comments

Comments

@bazjapan
Copy link

Posted this on stackoverflow. Thought it best if I post it here too.

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

http://stackoverflow.com/questions/11899967/require-js-remove-definition-to-force-reload

@jrburke
Copy link
Member

jrburke commented Aug 10, 2012

requirejs.undef() will remove the module from the defined cache, but any existing modules that have been bound to it are not cleared. Is that what you want to do, also remove any modules that depend on the removed module (and modules that depend on that set, and so on)?

If so, then it is better to just start a new requirejs context:

http://requirejs.org/docs/api.html#multiversion

Otherwise, it is too messy to try to unbind the reverse dependency tree.

Closing this as part of bug triage, but we can continue discussion in this ticket. If there is a bug discovered we can reopen.

@jrburke jrburke closed this as completed Aug 10, 2012
@bazjapan
Copy link
Author

Thanks for the feedback James.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants