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
Added several suggested corrections to typos. Also, I'm not sure what the intended meaning in this sentence (line 33) is: In general the module developer writes handlers that are called when a dependency of this module is updated.
Copy file name to clipboardExpand all lines: content/concepts/hot-module-replacement.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,33 +24,33 @@ In addition to the normal assets the compiler need to emit the "Update" to allow
24
24
25
25
The manifest contains the new compilation hash and a list of all update chunks (2.).
26
26
27
-
The update chunks contains code for all updated modules in this chunk (or a flag if a module was removed).
27
+
The update chunks contain code for all updated modules in this chunk (or a flag if a module was removed).
28
28
29
-
The compiler addtionally makes sure that module and chunk ids as consistent between these builds. It uses a "records" json file to store them between builds (on it store them in memory).
29
+
The compiler addtionally makes sure that module and chunk ids are consistent between these builds. It uses a "records" json file to store them between builds (or it stores them in memory).
30
30
31
31
### From The Module View
32
32
33
33
HMR is an opt-in feature, so it only affects modules that contains HMR code. The documentation describes the API that is available in modules. In general the module developer writes handlers that are called when a dependency of this module is updated. The developer can also write a handler that is called when this module is updated.
34
34
35
-
In most cases it's not mandatory to write HMR code in every module. If a module has no HMR handlers the update bubbles up. This means a single handler can handle a update to a complete module tree. If a single module in this tree is updated, the complete module tree is reloaded (only reloaded not transferred).
35
+
In most cases it's not mandatory to write HMR code in every module. If a module has no HMR handlers the update bubbles up. This means a single handler can handle an update to a complete module tree. If a single module in this tree is updated, the complete module tree is reloaded (only reloaded not transferred).
36
36
37
37
### From The HMR Runtime View (Technical)
38
38
39
-
For the module system runtime is additional code emitted to track module `parents` and `children`.
39
+
For the module system runtime additional code is emitted to track module `parents` and `children`.
40
40
41
41
On the management side the runtime supports two methods: `check` and `apply`.
42
42
43
43
A `check` does a HTTP request to the update manifest. When this request fails, there is no update available. Elsewise the list of updated chunks is compared to the list of currently loaded chunks. For each loaded chunk the corresponding update chunk is downloaded. All module updates as stored in the runtime as update. The runtime switches into the `ready` state, meaning an update has been downloaded and is ready to be applied.
44
44
45
45
For each new chunk request in the ready state the update chunk is also downloaded.
46
46
47
-
The `apply` method flags all updated modules as invalid. For each invalid module there need to be a update handler in the module or update handlers in every parent. Else the invalid buddles up and mark all parents as invalid too. This process continues until no more "bubble up" occurs. If it bubbles up from an entry point the process fails.
47
+
The `apply` method flags all updated modules as invalid. For each invalid module there need to be a update handler in the module or update handlers in every parent. Else the invalid buddles up and marks all parents as invalid too. This process continues until no more "bubble up" occurs. If it bubbles up from an entry point the process fails.
48
48
49
49
Now all invalid modules are disposed (dispose handler) and unloaded. Then the current hash is updated and all "accept" handlers are called. The runtime switches back to the `idle` state and everything continues as normal.
50
50
51
51
## What can I do with it?
52
52
53
-
You can use it in development as LiveReload replacement. webpack-dev-server supports a hot mode which tries to update with HMR before trying to reload the whole page. See how to implement [HMR with React](/guides/hmr-react) for example.
53
+
You can use it in development as a LiveReload replacement. webpack-dev-server supports a hot mode which tries to update with HMR before trying to reload the whole page. See how to implement [HMR with React](/guides/hmr-react) for example.
54
54
55
55
Some loaders already generate modules that are hot-updateable. i.e. the `style-loader` can exchange the stylesheet. You don't need to do anything special.
0 commit comments