Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
96 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*~ | ||
.DS_Store | ||
/node_modules | ||
node_modules | ||
npm-debug.log | ||
/example/bundle.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
/node_modules | ||
npm-debug.log | ||
/test | ||
/example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Browserify-HMR</title> | ||
<script src="/bundle.js"></script> | ||
</head> | ||
<body> | ||
<div id="main"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,20 @@ | ||
global.runCount = (global.runCount||0) + 1; | ||
|
||
console.log('index start'); | ||
require('./a'); | ||
console.log('index end'); | ||
require('./label'); | ||
|
||
if (module.hot) { | ||
module.hot.accept('./a', function() { | ||
console.log('index accepted new a'); | ||
console.log('exports of a', require('./a')); | ||
}); | ||
|
||
if (global.runCount === 1) { | ||
setInterval(function() { | ||
module.hot.check(function(err, outdatedModules) { | ||
console.log('check callback', err, outdatedModules); | ||
if (outdatedModules) { | ||
module.hot.apply(function(err, outdatedModules) { | ||
console.log('apply callback', err, outdatedModules); | ||
}); | ||
} | ||
}); | ||
}, 1000); | ||
} | ||
var doCheck = function() { | ||
module.hot.check(function(err, outdated) { | ||
if (err) { | ||
console.error('Check error', err); | ||
} | ||
if (outdated) { | ||
module.hot.apply(function(err, updated) { | ||
console.log('Replaced modules', updated); | ||
setTimeout(doCheck, 2000); | ||
}); | ||
} else { | ||
setTimeout(doCheck, 2000); | ||
} | ||
}); | ||
}; | ||
doCheck(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var $ = require('jquery'); | ||
|
||
$(window).ready(function() { | ||
$("#main").text('this text can update'); | ||
}); | ||
|
||
if (module.hot) { | ||
module.hot.accept(); | ||
module.hot.dispose(function() { | ||
// cleanup code here | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "example", | ||
"private": true, | ||
"version": "0.1.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "./scripts/run", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^11.0.1", | ||
"browserify-hmr": "^0.1.0", | ||
"http-server": "^0.8.0", | ||
"watchify": "^3.3.1" | ||
}, | ||
"dependencies": { | ||
"jquery": "^2.1.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
./node_modules/.bin/watchify -vp [ browserify-hmr -u /bundle.js ] index.js -o bundle.js & | ||
./node_modules/.bin/http-server & | ||
wait |