From 9df67738a2719dfe6f666c57d6b2ae22f9b41646 Mon Sep 17 00:00:00 2001 From: Lou Huang Date: Mon, 24 Jun 2019 11:42:01 -0400 Subject: [PATCH 1/2] Update hmr.md Clarify that HMR is now opt-in. See https://github.com/parcel-bundler/parcel/pull/2676#issuecomment-505059049 --- src/i18n/en/docs/hmr.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/i18n/en/docs/hmr.md b/src/i18n/en/docs/hmr.md index bdb679578..6b4641981 100644 --- a/src/i18n/en/docs/hmr.md +++ b/src/i18n/en/docs/hmr.md @@ -1,6 +1,8 @@ # 🔥 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.x, the default implementation has changed to fully refresh the page when files change. You can opt-in to enable true HMR by calling `module.hot.accept()` in your app. HMR is automatically disabled when bundling in production mode. 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 bf99c07a9f86f903f9f8dbd5273c3bddfaa989b5 Mon Sep 17 00:00:00 2001 From: Lou Huang Date: Mon, 24 Jun 2019 12:39:19 -0400 Subject: [PATCH 2/2] Update hmr.md --- src/i18n/en/docs/hmr.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/i18n/en/docs/hmr.md b/src/i18n/en/docs/hmr.md index 6b4641981..6978a9ad1 100644 --- a/src/i18n/en/docs/hmr.md +++ b/src/i18n/en/docs/hmr.md @@ -2,7 +2,13 @@ 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.x, the default implementation has changed to fully refresh the page when files change. You can opt-in to enable true HMR by calling `module.hot.accept()` in your app. 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 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.