Closed Bug 564674 Opened 14 years ago Closed 13 years ago

Need a way to unload/reload JavaScript modules (JSM)


(Toolkit :: Add-ons Manager, enhancement)

Not set





(Reporter: jwkbugzilla, Unassigned)



(Whiteboard: [rewrite])


(1 file)

Bootstrapped add-ons are supposed to revert everything when they are shut down. This is not possible in case of JavaScript modules however - once the JavaScript modules of the add-on are loaded there is no way to remove them from memory. At the moment I am simply telling these modules to play dead but this will most likely not be sufficient when updating the add-on.
Whiteboard: [rewrite]
This bug is somewhat similar to Bug 535010 - [Enh] Reloading of JS Modules, as a reload is nothing but unload and import again.
Similar enough to call them the same issue for the purposes of this bug.
Summary: Need a way to unload JavaScript modules → Need a way to unload/reload JavaScript modules (JSM)
This bug is similar to Bug 481603 - Add a means to refresh code modules.
Since I found little discussion about this issue, here's a tip that circumvents this bug until it is fixed on the API level. It can be used by restartless addons to actually wipe out and then reload any substantial jsm content, or by chrome addons for live jsm refreshes. In order to do this, note that non-exposed jsm content is not sealed and can be easily deleted as well as reloaded with subscript loader. The two small routines implementing this should be defined inside jsm and exposed via a simple maintenance interface. Since exported objects are not effectively mutable, they should only be used in this scenario for providing javascript getters for the clients to access internal, updatable/deletable, 'true' objects. There are minor limitations and inconveniences to this approach, but if you really need the jsm cleanup and refresh functionality now, it should deliver, for all practical reasons.
See working commented example in attachment.
Closed: 13 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.