我已经编写了一个简单的es6模块,我尝试使用jspm + jspm-server(实时服务器的分支)进行热重新加载。按照文档,将任何es6文件标记为hotreloadable我设置:
export let __hotReload = true
首次加载jspm-server时,模块运行正常。但是当我做出改变时,我得到以下错误
$ node test/server.js
Serving "/Users/ashleycoleman/github/inbro" at http://127.0.0.1:8080
Client connected. JSPM watching enabled
Change detected: test/async-dom-operation.js
✅ SystemJS loaded. Initialising ChangeHandler
# Then the below error occurs when I make a change to "async-dom-operation.js"
Change to http://127.0.0.1:8080/test/async-dom-operation.js cannot be handled gracefully:
Change occurred to a file outside SystemJS loading
这是我的项目设置:
.
├── config.js
├── package.json
└── test
├── async-dom-operation.js
├── index.html
├── main.js
└── server.js
server.js:
var jspmServer = require("jspm-server");
var params = {
host: "0.0.0.0", // Set the address to bind to. Defaults to 0.0.0.0.
open: '/test/' // When false, it won't load your browser by default.
};
jspmServer.start(params);
main.js:
import {asyncDomOperation} from '/test/async-dom-operation.js';
export let __hotReload = true; // For jspm-server hot reloading
asyncDomOperation();
异步-DOM-operation.js:
export function asyncDomOperation() {
var writePara = (msg) => () => document.writeln('<p>'+msg+'</p>');
setTimeout( writePara('Start...'), 100 );
setTimeout( writePara('...middle'), 200 );
setTimeout( writePara('...end'), 300 );
}
export let __hotReload = true; // For jspm-server hot reloading
config.js:
System.config({
baseURL: "/",
defaultJSExtensions: true,
transpiler: "babel",
babelOptions: {
"optional": [
"runtime",
"optimisation.modules.system"
]
},
paths: {
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
map: { ... etc ...}
});
答案 0 :(得分:1)
这绝对不是正确的答案,但我是https://github.com/capaj/jspm-hot-reloader的作者,如果您尝试使用它,我会很高兴,如果有任何问题,请让我知道。很有可能,jspm-hot-reloader将成为JSPM 0.17.0的一部分,如果我们能够覆盖你的用例,我也会喜欢它。