WARNING: This project isn't really adapted yet, so StateStore is going to be replaced with a plugin system for major version 1. Plugins written against StateStore will have to be adjusted to use events after the change, and the unload reload behavior will be implemented as a Plugin Issue Here
Live module reloading for SystemJs. Inspired by systemjs-hot-reloader, compatible with chokidar-socket-emitter event format.
Reloads modules, and plugin-loaded resources, in response to socket.io file change events.
systemjs-reloader.zip is available in github releases and it contains a static bundle that should work if not using a transpiler, otherwise:
jspm install sjsReload = github:npbenjohnson/systemjs-reloader
System.import('sjsReload').then(function (SjsReload) {
// this could be hardcoded to a url instead
var socketUrl = window.location.href.match(/([^\/]*\/\/[^/:?]*)/)[1] + ':9111';
// listen for changes
new SjsReload.default(System, socketUrl, 500);
// load your app
return System.import('./main.js');
});
System.import(file, normalizedParentName)
in order for the reloader to correctly reload their ancestors.map: { "html": "path/to/textloader.js" }
in SystemJs, the same as you would require for trailing "!" notation.Module in charge of reloading modules and their ancestors on change.
"relative/file.js"
or { path: "relative/file.js" }
__unload
should be stored in memory and passed to __reload
calls.Default implementation of StateStore, only useful as a starting point for custom statestores. Implements calling __unload()
method on a module when it is unloaded, and __reload([value returned from unload])
when it is reloaded
__unload
hooks and pass it to __reload
hooks as the first argument, using an object in memory as storage.__unload()
on module being unloaded.__reload([value returned from unload])
on module being reloaded.