From 4b9fbba0d40c1dd1bd2268accf80bf21acbfdb40 Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Tue, 29 Aug 2017 14:54:38 -0400 Subject: [PATCH 1/2] Make error overlay file configurable --- packages/react-dev-utils/webpackHotDevClient.js | 1 + packages/react-error-overlay/src/index.js | 3 ++- packages/react-error-overlay/src/listenToRuntimeErrors.js | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index b6effe718e5..96a15063231 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -33,6 +33,7 @@ ErrorOverlay.startReportingRuntimeErrors({ module.hot.decline(); } }, + filename: 'static/js/bundle.js', }); if (module.hot && typeof module.hot.dispose === 'function') { diff --git a/packages/react-error-overlay/src/index.js b/packages/react-error-overlay/src/index.js index ff4f1c71404..f4bc50244ac 100644 --- a/packages/react-error-overlay/src/index.js +++ b/packages/react-error-overlay/src/index.js @@ -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) { diff --git a/packages/react-error-overlay/src/listenToRuntimeErrors.js b/packages/react-error-overlay/src/listenToRuntimeErrors.js index 45c43fa5d40..3145ad93228 100644 --- a/packages/react-error-overlay/src/listenToRuntimeErrors.js +++ b/packages/react-error-overlay/src/listenToRuntimeErrors.js @@ -39,7 +39,10 @@ export type ErrorRecord = {| stackFrames: StackFrame[], |}; -export function listenToRuntimeErrors(crash: ErrorRecord => void) { +export function listenToRuntimeErrors( + crash: ErrorRecord => void, + filename: string +) { 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 ); From 1fa45b307f5e63b0bf500148d7c6294ecdfbe71f Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Tue, 29 Aug 2017 18:33:14 -0400 Subject: [PATCH 2/2] Add fallback filename --- packages/react-error-overlay/src/index.js | 2 +- packages/react-error-overlay/src/listenToRuntimeErrors.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-error-overlay/src/index.js b/packages/react-error-overlay/src/index.js index f4bc50244ac..168baa7ef64 100644 --- a/packages/react-error-overlay/src/index.js +++ b/packages/react-error-overlay/src/index.js @@ -21,7 +21,7 @@ import type { ErrorRecord } from './listenToRuntimeErrors'; type RuntimeReportingOptions = {| onError: () => void, launchEditorEndpoint: string, - filename: string, + filename?: string, |}; let iframe: null | HTMLIFrameElement = null; diff --git a/packages/react-error-overlay/src/listenToRuntimeErrors.js b/packages/react-error-overlay/src/listenToRuntimeErrors.js index 3145ad93228..341200afa8b 100644 --- a/packages/react-error-overlay/src/listenToRuntimeErrors.js +++ b/packages/react-error-overlay/src/listenToRuntimeErrors.js @@ -41,7 +41,7 @@ export type ErrorRecord = {| export function listenToRuntimeErrors( crash: ErrorRecord => void, - filename: string + filename: string = '/static/js/bundle.js' ) { function crashWithFrames(error: Error, unhandledRejection = false) { getStackFrames(error, unhandledRejection, CONTEXT_SIZE)