Skip to content

Commit 66bf7df

Browse files
authored
feat: better refresh plugin integration (#9375)
1 parent a01b1c5 commit 66bf7df

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed
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

+1-1
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

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

packages/react-scripts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"types": "./lib/react-app.d.ts",
3030
"dependencies": {
3131
"@babel/core": "7.10.5",
32-
"@pmmmwh/react-refresh-webpack-plugin": "0.4.0-beta.8",
32+
"@pmmmwh/react-refresh-webpack-plugin": "0.4.1",
3333
"@svgr/webpack": "5.4.0",
3434
"@typescript-eslint/eslint-plugin": "^3.3.0",
3535
"@typescript-eslint/parser": "^3.3.0",

0 commit comments

Comments
 (0)