-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.js
42 lines (34 loc) · 1.12 KB
/
default.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import socketIO from 'socket.io-client'
import { reimportModule } from './reload.js'
const backendUrl = '' // same URL
let socket = socketIO(backendUrl)
socket.on('connect', () => {
// console.log('hot reload connected')
socket.emit('identification', navigator.userAgent)
// socket.emit('package.json', function (pjson) {
// // console.log('stuff', pjson)
// // self.pjson = pjson // maybe needed in the future?
// // self.jspmConfigFile = pjson.jspm.configFile || 'config.js'
// })
})
socket.on('reload', () => {
console.log('whole page reload requested')
})
socket.on('change', (e) => {
var path = e.path,
norm = System.normalizeSync(path)
if(System.bundles[path]){
// console.log('BUILT BUNDLE', path)
}else if(System.has(norm)){
// console.log('UPDATE MODULE', path)
reimportModule(norm)
}else{
// console.log('NOT FOUND', path)
}
})
socket.on('disconnect', () => {
console.log('hot reload disconnected from ', backendUrl)
})
window.onerror = (err) => {
socket.emit('error', err) // emitting errors for jspm-dev-buddy
}