diff --git a/packages/modules-runtime-hot/package.js b/packages/modules-runtime-hot/package.js index a983a943da..9c84208e75 100644 --- a/packages/modules-runtime-hot/package.js +++ b/packages/modules-runtime-hot/package.js @@ -1,7 +1,7 @@ Package.describe({ name: "modules-runtime-hot", version: "0.13.0-rc200.1", - summary: "Patches modules-runtime to support Hot Module Reload", + summary: "Patches modules-runtime to support Hot Module Replacement", git: "https://github.com/benjamn/install", documentation: "README.md" }); diff --git a/packages/react-fast-refresh/README.md b/packages/react-fast-refresh/README.md index 1bb8c9eef4..f2aa206a79 100644 --- a/packages/react-fast-refresh/README.md +++ b/packages/react-fast-refresh/README.md @@ -1,3 +1,15 @@ # react-fast-refresh +[Source code of released version](https://github.com/meteor/meteor/tree/master/packages/react-fast-refresh) | [Source code of development version](https://github.com/meteor/meteor/tree/devel/packages/react-fast-refresh) +*** -Automatically update React components with HMR +This package updates modified React components in the running app for faster +feedback after changing a file. To be enabled, your app must: + +- Use the `hot-module-replacement` package +- Use React 16.9.0 or newer + +This package is disabled in production. It currently only supports the modern web client. + +Learn more in the [React Fast Refresh docs](https://reactnative.dev/docs/fast-refresh) + +React Fast Refresh can be disabled by setting the `DISABLE_REACT_FAST_REFRESH` environment variable before starting Meteor. diff --git a/packages/react-fast-refresh/client-runtime.js b/packages/react-fast-refresh/client-runtime.js index ff732143b4..b564ee31ae 100644 --- a/packages/react-fast-refresh/client-runtime.js +++ b/packages/react-fast-refresh/client-runtime.js @@ -1,4 +1,6 @@ -if (process.env.NODE_ENV !== 'production' && module.hot) { +const enabled = __meteor_runtime_config__.reactFastRefreshEnabled; + +if (enabled && process.env.NODE_ENV !== 'production' && module.hot) { const runtime = require('react-refresh/runtime'); let timeout = null; diff --git a/packages/react-fast-refresh/package.js b/packages/react-fast-refresh/package.js index c8f2cfb214..09b3907103 100644 --- a/packages/react-fast-refresh/package.js +++ b/packages/react-fast-refresh/package.js @@ -7,7 +7,7 @@ Package.describe({ }); Npm.depends({ - 'react-refresh': '0.8.3', + 'react-refresh': '0.9.0', semver: '7.3.4' }); diff --git a/packages/react-fast-refresh/server.js b/packages/react-fast-refresh/server.js index eaadbade22..1fde5134d8 100644 --- a/packages/react-fast-refresh/server.js +++ b/packages/react-fast-refresh/server.js @@ -15,6 +15,10 @@ if (enabled) { } } +if (typeof __meteor_runtime_config__ === 'object') { + __meteor_runtime_config__.reactFastRefreshEnabled = enabled; +} + const babelPlugin = enabled ? require('react-refresh/babel') : null; diff --git a/tools/runners/run-app.js b/tools/runners/run-app.js index 5d66ec0be9..a702f12279 100644 --- a/tools/runners/run-app.js +++ b/tools/runners/run-app.js @@ -226,7 +226,9 @@ _.extend(AppProcess.prototype, { env.METEOR_PRINT_ON_LISTEN = 'true'; - env.METEOR_HMR_SECRET = self.hmrSecret; + if (self.hmrSecret) { + env.METEOR_HMR_SECRET = self.hmrSecret; + } return env; },