From 8034772090082b0f66ab2e1ae181d0f9e0c43f34 Mon Sep 17 00:00:00 2001 From: Jasper De Moor Date: Sun, 6 Oct 2019 11:48:23 +0200 Subject: [PATCH 1/2] Update hmr.md --- src/i18n/en/docs/hmr.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/i18n/en/docs/hmr.md b/src/i18n/en/docs/hmr.md index bdb679578..6978a9ad1 100644 --- a/src/i18n/en/docs/hmr.md +++ b/src/i18n/en/docs/hmr.md @@ -1,6 +1,14 @@ # 🔥 Hot Module Replacement -Hot Module Replacement (HMR) improves the development experience by automatically updating modules in the browser at runtime without needing a whole page refresh. This means that application state can be retained as you change small things. Parcel's HMR implementation supports both JavaScript and CSS assets out of the box. HMR is automatically disabled when bundling in production mode. +Hot Module Replacement (HMR) improves the development experience by automatically updating modules in the browser at runtime without needing a whole page refresh. This means that application state can be retained as you change small things. Parcel's HMR implementation supports both JavaScript and CSS assets. + +As of version 1.12.0, the default implementation has changed to fully refresh the page when files change. You can opt-in to enable true HMR by adding the following in your app. This will only work in development; HMR is automatically disabled when bundling in production mode. + +```javascript +if (module.hot) { + module.hot.accept() +} +``` As you save files, Parcel rebuilds what changed and sends an update to any running clients containing the new code. The new code then replaces the old version, and is re-evaluated along with all parents. You can hook into this process using the `module.hot` API, which can notify your code when a module is about to be disposed, or when a new version comes in. Projects like [react-hot-loader](https://github.com/gaearon/react-hot-loader) can help with this process, and work out of the box with Parcel. From ca37fb2d93116f9d2933a5b5e255ab5ca38a6f2c Mon Sep 17 00:00:00 2001 From: Jasper De Moor Date: Sun, 6 Oct 2019 11:51:54 +0200 Subject: [PATCH 2/2] Update src/i18n/en/docs/hmr.md Co-Authored-By: Niklas Mischkulnig --- src/i18n/en/docs/hmr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/en/docs/hmr.md b/src/i18n/en/docs/hmr.md index 6978a9ad1..9890803f2 100644 --- a/src/i18n/en/docs/hmr.md +++ b/src/i18n/en/docs/hmr.md @@ -2,7 +2,7 @@ Hot Module Replacement (HMR) improves the development experience by automatically updating modules in the browser at runtime without needing a whole page refresh. This means that application state can be retained as you change small things. Parcel's HMR implementation supports both JavaScript and CSS assets. -As of version 1.12.0, the default implementation has changed to fully refresh the page when files change. You can opt-in to enable true HMR by adding the following in your app. This will only work in development; HMR is automatically disabled when bundling in production mode. +As of version 1.12.0, the default implementation has changed to fully refresh the page when files change. You can opt-in to enable true HMR by adding the following in your app. This will only apply in development; HMR is automatically disabled when bundling in production mode. ```javascript if (module.hot) {