mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-01-12 22:46:30 +08:00
Make error overlay filename configurable (#3028)
* Make error overlay file configurable * Add fallback filename
This commit is contained in:
committed by
Dan Abramov
parent
6644054fc3
commit
8a72a314bc
@@ -33,6 +33,7 @@ ErrorOverlay.startReportingRuntimeErrors({
|
||||
module.hot.decline();
|
||||
}
|
||||
},
|
||||
filename: 'static/js/bundle.js',
|
||||
});
|
||||
|
||||
if (module.hot && typeof module.hot.dispose === 'function') {
|
||||
|
||||
3
packages/react-error-overlay/src/index.js
vendored
3
packages/react-error-overlay/src/index.js
vendored
@@ -21,6 +21,7 @@ import type { ErrorRecord } from './listenToRuntimeErrors';
|
||||
type RuntimeReportingOptions = {|
|
||||
onError: () => void,
|
||||
launchEditorEndpoint: string,
|
||||
filename?: string,
|
||||
|};
|
||||
|
||||
let iframe: null | HTMLIFrameElement = null;
|
||||
@@ -55,7 +56,7 @@ export function startReportingRuntimeErrors(options: RuntimeReportingOptions) {
|
||||
} finally {
|
||||
handleRuntimeError(errorRecord);
|
||||
}
|
||||
});
|
||||
}, options.filename);
|
||||
}
|
||||
|
||||
function handleRuntimeError(errorRecord) {
|
||||
|
||||
@@ -39,7 +39,10 @@ export type ErrorRecord = {|
|
||||
stackFrames: StackFrame[],
|
||||
|};
|
||||
|
||||
export function listenToRuntimeErrors(crash: ErrorRecord => void) {
|
||||
export function listenToRuntimeErrors(
|
||||
crash: ErrorRecord => void,
|
||||
filename: string = '/static/js/bundle.js'
|
||||
) {
|
||||
function crashWithFrames(error: Error, unhandledRejection = false) {
|
||||
getStackFrames(error, unhandledRejection, CONTEXT_SIZE)
|
||||
.then(stackFrames => {
|
||||
@@ -68,7 +71,7 @@ export function listenToRuntimeErrors(crash: ErrorRecord => void) {
|
||||
{
|
||||
message: data.message,
|
||||
stack: data.stack,
|
||||
__unmap_source: '/static/js/bundle.js',
|
||||
__unmap_source: filename,
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user