systemjs-hot-reloader-ex
Advanced tools
Comparing version 2.0.6 to 2.0.7
@@ -38,7 +38,13 @@ 'use strict'; | ||
this.enableClearResources = opts.clearResources === undefined ? true : opts.clearResources; | ||
this.logger = this.createLogger('HMR'); | ||
if (!this.loader.trace) { | ||
this.logger.info('Set "SystemJS.trace = true" to be able to auto unload not used modules'); | ||
this.logger.error('Set "SystemJS.trace = true" to enable hot reload'); | ||
} | ||
if (/^0\.20\./.test(this.loader.version)) { | ||
throw new Error('This version of SystemJS hot reloader is designed for SystemJS v0.20.x'); | ||
} | ||
} | ||
@@ -95,3 +101,3 @@ | ||
// try to find by filename path in all registered modules, slow :-( | ||
var name3 = Object.keys(this.loader._loader.modules).find(function (name) { | ||
var name3 = Object.keys(this.loader.loads).find(function (name) { | ||
return name.startsWith(name1 + '!'); | ||
@@ -308,2 +314,3 @@ }); | ||
// fix me | ||
var moduleRecord = this.loader._loader.moduleRecords[name]; | ||
@@ -404,3 +411,5 @@ | ||
this.clearModuleResources(name); | ||
if (this.enableClearResources) { | ||
this.clearModuleResources(name); | ||
} | ||
} | ||
@@ -419,5 +428,12 @@ | ||
var removeNode = function removeNode(node) { | ||
if (window.URL && node.href.startsWith('blob:')) { | ||
URL.revokeObjectURL(node.href); | ||
} | ||
node.remove(); | ||
}; | ||
// for example, plugin-sass | ||
Array.from(document.querySelectorAll('[data-url="' + address + '"]')).forEach(function (node) { | ||
return node.remove(); | ||
return removeNode(node); | ||
}); | ||
@@ -429,3 +445,3 @@ | ||
}).forEach(function (node) { | ||
return node.remove(); | ||
return removeNode(node); | ||
}); | ||
@@ -432,0 +448,0 @@ } |
{ | ||
"name": "systemjs-hot-reloader-ex", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"description": "SystemJS / JSPM hot reloader with support of CSS, SCSS, SASS, LESS, Stylus, React and JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# SystemJS Hot Reloader # | ||
**This hot reloader is compatbile with SystemJS v0.19.x only for now** | ||
Universal hot reloader for SystemJS / JSPM. | ||
@@ -144,2 +146,16 @@ | ||
By default this hot reloader will try to free resources occupued by style/link | ||
tag with css before reload, so it will drop link/style tag and expects that | ||
loader plugin will be able to reinject style/link tag with css. That could cause | ||
changing order of style/link tags after hot reload. If you would like to disable | ||
this behaviour then pass `clearResources = false`: | ||
```javascript | ||
SystemJS.config({ | ||
hotReloaderOptions: { | ||
clearResources: false | ||
} | ||
}); | ||
``` | ||
### React Hot Reloader ### | ||
@@ -161,3 +177,3 @@ | ||
```shell | ||
jspm install npm:react-hot-loader@3.0.0-beta.5 --save-dev | ||
jspm install npm:react-hot-loader@3.0.0-beta.6 --save-dev | ||
``` | ||
@@ -189,6 +205,7 @@ | ||
}, | ||
trace: true, // fix me? | ||
transpiler: "plugin-babel", | ||
babelOptions: { | ||
"presets": [ | ||
"babel-preset-react" | ||
"babel-preset-react" // fix me | ||
] | ||
@@ -195,0 +212,0 @@ }, |
@@ -26,7 +26,13 @@ import 'core-js/shim'; | ||
this.enableClearResources = opts.clearResources === undefined ? true : opts.clearResources; | ||
this.logger = this.createLogger('HMR'); | ||
if (!this.loader.trace) { | ||
this.logger.info('Set "SystemJS.trace = true" to be able to auto unload not used modules'); | ||
this.logger.error('Set "SystemJS.trace = true" to enable hot reload'); | ||
} | ||
if (/^0\.20\./.test(this.loader.version)) { | ||
throw new Error('This version of SystemJS hot reloader is designed for SystemJS v0.20.x'); | ||
} | ||
} | ||
@@ -74,3 +80,3 @@ | ||
// try to find by filename path in all registered modules, slow :-( | ||
const name3 = Object.keys(this.loader._loader.modules).find((name) => { | ||
const name3 = Object.keys(this.loader.loads).find((name) => { | ||
return name.startsWith(`${name1}!`); | ||
@@ -264,2 +270,3 @@ }); | ||
// fix me | ||
const moduleRecord = this.loader._loader.moduleRecords[name]; | ||
@@ -347,3 +354,5 @@ | ||
this.clearModuleResources(name); | ||
if (this.enableClearResources) { | ||
this.clearModuleResources(name); | ||
} | ||
} | ||
@@ -359,5 +368,12 @@ | ||
const removeNode = (node) => { | ||
if (window.URL && node.href.startsWith('blob:')) { | ||
URL.revokeObjectURL(node.href); | ||
} | ||
node.remove(); | ||
}; | ||
// for example, plugin-sass | ||
Array.from(document.querySelectorAll(`[data-url="${address}"]`)) | ||
.forEach(node => node.remove()); | ||
.forEach(node => removeNode(node)); | ||
@@ -367,3 +383,3 @@ // for example, plugin-css | ||
.filter(node => node.href === address) | ||
.forEach(node => node.remove()); | ||
.forEach(node => removeNode(node)); | ||
} | ||
@@ -370,0 +386,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
68758
863
295