You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
23 KiB

4 years ago
{"ast":null,"code":"/**\n * Copyright (c) 2015-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict'; // This alternative WebpackDevServer combines the functionality of:\n// https://github.com/webpack/webpack-dev-server/blob/webpack-1/client/index.js\n// https://github.com/webpack/webpack/blob/webpack-1/hot/dev-server.js\n// It only supports their simplest configuration (hot updates on same server).\n// It makes some opinionated choices on top, like adding a syntax error overlay\n// that looks similar to our console output. The error overlay is inspired by:\n// https://github.com/glenjamin/webpack-hot-middleware\n\nvar stripAnsi = require('strip-ansi');\n\nvar url = require('url');\n\nvar launchEditorEndpoint = require('./launchEditorEndpoint');\n\nvar formatWebpackMessages = require('./formatWebpackMessages');\n\nvar ErrorOverlay = require('react-error-overlay');\n\nErrorOverlay.setEditorHandler(function editorHandler(errorLocation) {\n // Keep this sync with errorOverlayMiddleware.js\n fetch(launchEditorEndpoint + '?fileName=' + window.encodeURIComponent(errorLocation.fileName) + '&lineNumber=' + window.encodeURIComponent(errorLocation.lineNumber || 1) + '&colNumber=' + window.encodeURIComponent(errorLocation.colNumber || 1));\n}); // We need to keep track of if there has been a runtime error.\n// Essentially, we cannot guarantee application state was not corrupted by the\n// runtime error. To prevent confusing behavior, we forcibly reload the entire\n// application. This is handled below when we are notified of a compile (code\n// change).\n// See https://github.com/facebook/create-react-app/issues/3096\n\nvar hadRuntimeError = false;\nErrorOverlay.startReportingRuntimeErrors({\n onError: function () {\n hadRuntimeError = true;\n },\n filename: '/static/js/bundle.js'\n});\n\nif (module.hot && typeof module.hot.dispose === 'function') {\n module.hot.dispose(function () {\n // TODO: why do we need this?\n ErrorOverlay.stopReportingRuntimeErrors();\n });\n} // Connect to WebpackDevServer via a socket.\n\n\nvar connection = new WebSocket(url.format({\n protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',\n hostname: process.env.WDS_SOCKET_HOST || window.location.hostname,\n port: process.env.WDS_SOCKET_PORT || window.location.port,\n // Hardcoded in WebpackDevServer\n pathname: process.env.WDS_SOCKET_PATH || '/sockjs-node',\n slashes: true\n})); // Unlike WebpackDevServer client, we won't try to reconnect\n// to avoid spamming the console. Disconnect usually happens\n// when developer stops the server.\n\nconnection.onclose = function () {\n if (typeof console !== 'undefined' && typeof console.info === 'function') {\n console.info('The development server has disconnected.\\nRefresh the page if necessary.');\n }\n}; // Remember some state related to hot module replacement.\n\n\nvar isFirstCompilation = true;\nvar mostRecentCompilationHash = null;\nvar hasCompileErrors = false;\n\nfunction clearOutdatedErrors() {\n // Clean up outdated compile errors, if any.\n if (typeof console !== 'undefined' && typeof console.clear === 'function') {\n if (hasCompileErrors) {\n console.clear();\n }\n }\n} // Successful compilation.\n\n\nfunction handleSuccess() {\n clearOutdatedErrors();\n var isHotUpdate = !isFirstCompilation;\n isFirstCompilation = false;\n hasCompileErrors = false; // Attempt to apply hot updates or reload.\n\n if (isHotUpdate) {\n tryApplyUpdates(function onHotUpdateSuccess() {\n // Only dismiss it when we're sure it's a hot update.\n // Otherwise it would flicker right before the reload.\n tryDismissErrorOverlay();\n });\n }\n} // Compilation with warnings (e.g. ESLint).\n\n\nfunction handleWarnings(warnings) {\n clearOutdatedErrors();\n var isHotUpdate = !isFirstCompilation;\n isFirstCompilation = false;\n hasCompileErrors = false;\n\n function printWarnings() {\n // Print warnings to the console.\n var for