systemjs-hot-reloader-ex
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -27,9 +27,14 @@ 'use strict'; | ||
this.loader = opts.loader || SystemJS || System; | ||
this.logLevel = opts.loader === undefined ? 2 : opts.logLevel; | ||
this.logger = this.createLogger('HMR'); | ||
if (!this.loader) { | ||
throw new Error('Unable to instantiate SystemJS Hot Reloader without SystemJS'); | ||
} | ||
if (this.loader.hotReloaderOptions) { | ||
Object.assign(opts, this.loader.hotReloaderOptions); | ||
} | ||
this.logLevel = opts.logLevel === undefined ? 2 : opts.logLevel; | ||
this.logger = this.createLogger('HMR'); | ||
} | ||
@@ -36,0 +41,0 @@ |
{ | ||
"name": "systemjs-hot-reloader-ex", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "SystemJS / JSPM hot reloader with support of CSS, SCSS, SASS, LESS, Stylus, React and JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -63,2 +63,12 @@ # SystemJS Hot Reloader # | ||
or via `jspm.config.js`: | ||
```javascript | ||
SystemJS.config({ | ||
hotReloaderOptions: { | ||
logLevel: 3 | ||
} | ||
}); | ||
``` | ||
### JavaScript Hot Reloader ### | ||
@@ -85,2 +95,7 @@ | ||
Avoid using of loaders via `!` because in that case there is no 100% way to | ||
convert file name into module name so reloader will have to iterate over all | ||
registered modules to find correct module name. It is recommended to define | ||
loader via `meta` SystemJS config section for files based on their extension. | ||
The fastest reload is guaranteed when css filename could be 1:1 resolved to | ||
@@ -92,8 +107,6 @@ module name. It works when you have css loading workflow like below: | ||
meta: { | ||
"*.css": { | ||
"loader": "plugin-css" | ||
}, | ||
"*.scss": { | ||
"loader": "plugin-sass" | ||
} | ||
"*.css": { "loader": "plugin-css" }, | ||
"*.scss": { "loader": "plugin-sass" }, | ||
"*.sass": { "loader": "plugin-sass" }, | ||
"*.less": { "loader": "plugin-less" } | ||
}, | ||
@@ -124,2 +137,6 @@ }); | ||
If you keep state in store model object or in `mobx` and your application will be | ||
able to restore state from it, then you don't need this part, just keep you store | ||
instance in separate module. | ||
React, babel plugin, babel preset are required (obviously): | ||
@@ -143,8 +160,11 @@ | ||
* `react-hot-loader/babel` required to wrap `import()` | ||
* `react-hot-loader/lib/patch.dev.js` will patch React | ||
* `react-hot-loader/babel` babel plugin is required to wrap `import()` | ||
* `react-hot-loader/lib/patch.dev.js` is required, will patch React on the fly | ||
* `react-hot-loader/lib/AppContainer.dev.js` will restore state on reload | ||
* `__reload()` hook required to rerender application instead of module reload | ||
* `__reload()` hook required to rerender application instead of full module reload | ||
* different application entry points for development and production | ||
Please note, that **react-hot-loader/babel** should be **FIRST** plugin in list | ||
of Babel plugins. | ||
File: `jspm.config.js`: | ||
@@ -157,2 +177,5 @@ | ||
}, | ||
meta: { | ||
"*.jsx": { loader: "plugin-babel" } | ||
}, | ||
transpiler: "plugin-babel", | ||
@@ -172,3 +195,3 @@ babelOptions: { | ||
"app": { | ||
"main": "index" | ||
"main": "index.jsx" | ||
} | ||
@@ -179,3 +202,3 @@ } | ||
"app": { | ||
"main": "index.dist", | ||
"main": "index.dist.jsx", | ||
"defaultExtension": "jsx" | ||
@@ -246,3 +269,3 @@ } | ||
<body> | ||
<div id="app-root"></div> | ||
<div id="root"></div> | ||
<script src="app.js"></script> | ||
@@ -249,0 +272,0 @@ </body> |
@@ -15,9 +15,14 @@ import 'core-js/shim'; | ||
this.loader = opts.loader || SystemJS || System; | ||
this.logLevel = opts.loader === undefined ? 2 : opts.logLevel; | ||
this.logger = this.createLogger('HMR'); | ||
if (!this.loader) { | ||
throw new Error('Unable to instantiate SystemJS Hot Reloader without SystemJS'); | ||
} | ||
if (this.loader.hotReloaderOptions) { | ||
Object.assign(opts, this.loader.hotReloaderOptions); | ||
} | ||
this.logLevel = opts.logLevel === undefined ? 2 : opts.logLevel; | ||
this.logger = this.createLogger('HMR'); | ||
} | ||
@@ -24,0 +29,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55829
681
266