You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 16, 2020. It is now read-only.
Copy file name to clipboardexpand all lines: examples/hot-reload/README.md
+15-1
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Hot module replacement with browserify/watchifyor webpack
1
+
# Hot module replacement with browserify/watchify, webpack or amok
2
2
3
3
Using hot reloading while developing can improve your workflow.
4
4
No more clicking through your application to a particular state each time you change the rendering code!
@@ -16,13 +16,22 @@ To install and run:
16
16
// for webpack
17
17
npm run hot-webpack
18
18
19
+
// for amok
20
+
npm run hot-amok
21
+
22
+
### browserify and webpack
19
23
Edit [package.json][] if you want to run on a different port.
20
24
If you're running inside a container or VM, add `--host 0.0.0.0` (webpack) so you can access the dev server from your host machine.
21
25
22
26
Try clicking to increment the counter, then edit [render.js][]!
23
27
Your changes should instantly appear on the page without refreshing or upsetting the counter's value.
24
28
Note that if you edit [browser.js][], your page will refresh and your state will be reset (only using webpack).
25
29
30
+
### amok
31
+
Amok starts its own web server to provide hot reloading and also starts the browser. Live editing is not limited to the render function. It uses a V8 feature instead of eval and is limited to Chrome or Chromium browsers. Change the counter increment in `browser.js` for example.
32
+
33
+
Edit [package.json][] to switch the web browser to use (Chrome or Chromium).
34
+
26
35
[package.json]: ./package.json
27
36
[render.js]: ./render.js
28
37
[browser.js]: ./browser.js
@@ -38,6 +47,11 @@ We have to be careful to not reseat any references - so we pass a function that
38
47
### browserify/watchify
39
48
The main difference to webpack is that browserify does not come with a dev-server which is why we use [http-server][] to host our example. Other than that it works quite similar. Under the hood [browserify-hmr][] imitates webpack's hot module replacement.
40
49
50
+
### amok
51
+
[Amok][] uses watchify to fire a `patch` event on the window object when a file is changed. Similarly to the webpack/browserify, we must change the state so Mercury re-renders automatically. Without this action, the changes in the code would only be seen after we clicked the button in the example. (The button click would change the state and trigger a re-render as well.)
0 commit comments