Skip to content

Commit fbe0366

Browse files
jaredpalmerkasperpeulen
authored andcommitted
Make error overlay filename configurable (facebook#3028)
* Make error overlay file configurable * Add fallback filename
1 parent 7693702 commit fbe0366

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

packages/react-dev-utils/webpackHotDevClient.js

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ ErrorOverlay.startReportingRuntimeErrors({
3333
module.hot.decline();
3434
}
3535
},
36+
filename: 'static/js/bundle.js',
3637
});
3738

3839
if (module.hot && typeof module.hot.dispose === 'function') {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type { ErrorRecord } from './listenToRuntimeErrors';
2121
type RuntimeReportingOptions = {|
2222
onError: () => void,
2323
launchEditorEndpoint: string,
24+
filename?: string,
2425
|};
2526

2627
let iframe: null | HTMLIFrameElement = null;
@@ -55,7 +56,7 @@ export function startReportingRuntimeErrors(options: RuntimeReportingOptions) {
5556
} finally {
5657
handleRuntimeError(errorRecord);
5758
}
58-
});
59+
}, options.filename);
5960
}
6061

6162
function handleRuntimeError(errorRecord) {

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ export type ErrorRecord = {|
3939
stackFrames: StackFrame[],
4040
|};
4141

42-
export function listenToRuntimeErrors(crash: ErrorRecord => void) {
42+
export function listenToRuntimeErrors(
43+
crash: ErrorRecord => void,
44+
filename: string = '/static/js/bundle.js'
45+
) {
4346
function crashWithFrames(error: Error, unhandledRejection = false) {
4447
getStackFrames(error, unhandledRejection, CONTEXT_SIZE)
4548
.then(stackFrames => {
@@ -68,7 +71,7 @@ export function listenToRuntimeErrors(crash: ErrorRecord => void) {
6871
{
6972
message: data.message,
7073
stack: data.stack,
71-
__unmap_source: '/static/js/bundle.js',
74+
__unmap_source: filename,
7275
},
7376
false
7477
);

0 commit comments

Comments
 (0)