Skip to content

Commit

Permalink
feat: better refresh plugin integration (facebook#9375)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmmmwh authored and justinsilvestre committed Oct 30, 2020
1 parent bb2693f commit 87b3338
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
19 changes: 19 additions & 0 deletions packages/react-dev-utils/refreshOverlayInterop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// @remove-on-eject-begin
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// @remove-on-eject-end
'use strict';

const {
dismissRuntimeErrors,
reportRuntimeError,
} = require('react-error-overlay');

module.exports = {
clearRuntimeErrors: dismissRuntimeErrors,
handleRuntimeError: reportRuntimeError,
};
2 changes: 1 addition & 1 deletion packages/react-error-overlay/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function reportBuildError(error: string) {

export function reportRuntimeError(
error: Error,
options?: RuntimeReportingOption = {}
options: RuntimeReportingOptions = {}
) {
currentRuntimeErrorOptions = options;
crashWithFrames(handleRuntimeError(options))(error);
Expand Down
8 changes: 7 additions & 1 deletion packages/react-scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ module.exports = function (webpackEnv) {
// during a production build.
// Otherwise React will be compiled in the very slow development mode.
new webpack.DefinePlugin(env.stringified),
// This is necessary to emit hot updates (currently CSS only):
// This is necessary to emit hot updates (CSS and Fast Refresh):
isEnvDevelopment && new webpack.HotModuleReplacementPlugin(),
// Experimental hot reloading for React .
// https://github.com/facebook/react/tree/master/packages/react-refresh
Expand All @@ -645,6 +645,12 @@ module.exports = function (webpackEnv) {
new ReactRefreshWebpackPlugin({
overlay: {
entry: webpackDevClientEntry,
// The expected exports are slightly different from what the overlay exports,
// so an interop is included here to enable feedback on module-level errors.
module: require.resolve('react-dev-utils/refreshOverlayInterop'),
// Since we ship a custom dev client and overlay integration,
// the bundled socket handling logic can be eliminated.
sockIntegration: false,
},
}),
// Watcher doesn't work well if you mistype casing in a path so we use
Expand Down
5 changes: 5 additions & 0 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@
"types": "./lib/react-app.d.ts",
"dependencies": {
"@babel/core": "7.10.5",
<<<<<<< HEAD
"@pmmmwh/react-refresh-webpack-plugin": "0.4.0-beta.8",
"@babel/plugin-syntax-bigint": "^7.8.3",
=======
"@babel/plugin-syntax-bigint": "^7.8.3",
"@pmmmwh/react-refresh-webpack-plugin": "0.4.1",
>>>>>>> 66bf7dfc... feat: better refresh plugin integration (#9375)
"@svgr/webpack": "5.4.0",
"@typescript-eslint/eslint-plugin": "^3.3.0",
"@typescript-eslint/parser": "^3.3.0",
Expand Down

0 comments on commit 87b3338

Please sign in to comment.