diff --git a/packager/react-packager/src/DependencyResolver/haste/polyfills/console.js b/packager/react-packager/src/DependencyResolver/haste/polyfills/console.js index 91fb970f885521..03dc60e24c360c 100644 --- a/packager/react-packager/src/DependencyResolver/haste/polyfills/console.js +++ b/packager/react-packager/src/DependencyResolver/haste/polyfills/console.js @@ -26,8 +26,11 @@ error: 4 }; + function setupConsole(global) { + var originalConsole = global.console; + if (!global.nativeLoggingHook) { return; } @@ -135,6 +138,18 @@ table: consoleTablePolyfill }; + // If available, also call the original `console` method since that is sometimes useful + // Ex. On OS X, this will let you see rich output to the Safari REPL console + if (originalConsole) { + Object.keys(global.console).forEach((methodName) => { + var nativeMethod = global.console[methodName]; + global.console[methodName] = function () { + originalConsole[methodName].apply(originalConsole, arguments); + nativeMethod.apply(global.console, arguments); + }; + }); + } + } if (typeof module !== 'undefined') {