Skip to content

Commit 87b3338

Browse files
pmmmwhjustinsilvestre
authored andcommitted
feat: better refresh plugin integration (facebook#9375)
1 parent bb2693f commit 87b3338

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// @remove-on-eject-begin
2+
/**
3+
* Copyright (c) 2015-present, Facebook, Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
// @remove-on-eject-end
9+
'use strict';
10+
11+
const {
12+
dismissRuntimeErrors,
13+
reportRuntimeError,
14+
} = require('react-error-overlay');
15+
16+
module.exports = {
17+
clearRuntimeErrors: dismissRuntimeErrors,
18+
handleRuntimeError: reportRuntimeError,
19+
};

packages/react-error-overlay/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function reportBuildError(error: string) {
5151

5252
export function reportRuntimeError(
5353
error: Error,
54-
options?: RuntimeReportingOption = {}
54+
options: RuntimeReportingOptions = {}
5555
) {
5656
currentRuntimeErrorOptions = options;
5757
crashWithFrames(handleRuntimeError(options))(error);

packages/react-scripts/config/webpack.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ module.exports = function (webpackEnv) {
636636
// during a production build.
637637
// Otherwise React will be compiled in the very slow development mode.
638638
new webpack.DefinePlugin(env.stringified),
639-
// This is necessary to emit hot updates (currently CSS only):
639+
// This is necessary to emit hot updates (CSS and Fast Refresh):
640640
isEnvDevelopment && new webpack.HotModuleReplacementPlugin(),
641641
// Experimental hot reloading for React .
642642
// https://github.com/facebook/react/tree/master/packages/react-refresh
@@ -645,6 +645,12 @@ module.exports = function (webpackEnv) {
645645
new ReactRefreshWebpackPlugin({
646646
overlay: {
647647
entry: webpackDevClientEntry,
648+
// The expected exports are slightly different from what the overlay exports,
649+
// so an interop is included here to enable feedback on module-level errors.
650+
module: require.resolve('react-dev-utils/refreshOverlayInterop'),
651+
// Since we ship a custom dev client and overlay integration,
652+
// the bundled socket handling logic can be eliminated.
653+
sockIntegration: false,
648654
},
649655
}),
650656
// Watcher doesn't work well if you mistype casing in a path so we use

packages/react-scripts/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@
2929
"types": "./lib/react-app.d.ts",
3030
"dependencies": {
3131
"@babel/core": "7.10.5",
32+
<<<<<<< HEAD
3233
"@pmmmwh/react-refresh-webpack-plugin": "0.4.0-beta.8",
3334
"@babel/plugin-syntax-bigint": "^7.8.3",
35+
=======
36+
"@babel/plugin-syntax-bigint": "^7.8.3",
37+
"@pmmmwh/react-refresh-webpack-plugin": "0.4.1",
38+
>>>>>>> 66bf7dfc... feat: better refresh plugin integration (#9375)
3439
"@svgr/webpack": "5.4.0",
3540
"@typescript-eslint/eslint-plugin": "^3.3.0",
3641
"@typescript-eslint/parser": "^3.3.0",

0 commit comments

Comments
 (0)