npbenjohnson / systemjs-reloader

Live module reloading for SystemJs
MIT License
0 stars 0 forks source link

systemjs-reloader

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.

Install

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

Usage

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');
});

Notes

Modules

Reloader / default

Module in charge of reloading modules and their ancestors on change.

StateStore

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