| var SockJS = require('sockjs-client'); | ||
| var stripAnsi = require('strip-ansi'); | ||
| var url = require('url'); | ||
| var ErrorOverlay = require('react-error-overlay'); | ||
| var chalk = require('chalk'); | ||
| const friendlySyntaxErrorLabel = 'Syntax error:'; | ||
| function isLikelyASyntaxError(message) { | ||
| return message.indexOf(friendlySyntaxErrorLabel) !== -1; | ||
| } | ||
| function formatMessage(message, isError) { | ||
| let lines = message.split('\n'); | ||
| lines = lines.filter(line => !/Module [A-z ]+\(from/.test(line)); | ||
| lines = lines.map(line => { | ||
| const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec( | ||
| line | ||
| ); | ||
| if (!parsingError) { | ||
| return line; | ||
| } | ||
| const [, errorLine, errorColumn, errorMessage] = parsingError; | ||
| return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`; | ||
| }); | ||
| message = lines.join('\n'); | ||
| message = message.replace( | ||
| /SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, | ||
| `${friendlySyntaxErrorLabel} $3 ($1:$2)\n` | ||
| ); | ||
| message = message.replace(/Line (\d+):\d+:/g, 'Line $1:'); | ||
| message = message.replace( | ||
| /^.*export '(.+?)' was not found in '(.+?)'.*$/gm, | ||
| `Attempted import error: '$1' is not exported from '$2'.` | ||
| ); | ||
| message = message.replace( | ||
| /^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, | ||
| `Attempted import error: '$2' does not contain a default export (imported as '$1').` | ||
| ); | ||
| message = message.replace( | ||
| /^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, | ||
| `Attempted import error: '$1' is not exported from '$3' (imported as '$2').` | ||
| ); | ||
| lines = message.split('\n'); | ||
| if (lines.length > 2 && lines[1].trim() === '') { | ||
| lines.splice(1, 1); | ||
| } | ||
| lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, '$1'); | ||
| if (lines[1] && lines[1].indexOf('Module not found: ') === 0) { | ||
| lines = [ | ||
| lines[0], | ||
| lines[1] | ||
| .replace('Error: ', '') | ||
| .replace('Module not found: Cannot find file:', 'Cannot find file:'), | ||
| ]; | ||
| } | ||
| if (lines[1] && lines[1].match(/Cannot find module.+node-sass/)) { | ||
| lines[1] = 'To import Sass files, you first need to install node-sass.\n'; | ||
| lines[1] += | ||
| 'Run `npm install node-sass` or `yarn add node-sass` inside your workspace.'; | ||
| } | ||
| lines[0] = chalk.inverse(lines[0]); | ||
| message = lines.join('\n'); | ||
| message = message.replace( | ||
| /^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, | ||
| '' | ||
| ); | ||
| message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, ''); // at <anonymous> | ||
| lines = message.split('\n'); | ||
| lines = lines.filter( | ||
| (line, index, arr) => | ||
| index === 0 || line.trim() !== '' || line.trim() !== arr[index - 1].trim() | ||
| ); | ||
| message = lines.join('\n'); | ||
| return message.trim(); | ||
| } | ||
| function formatWebpackMessages(json) { | ||
| const formattedErrors = json.errors.map(function(message) { | ||
| return formatMessage(message, true); | ||
| }); | ||
| const formattedWarnings = json.warnings.map(function(message) { | ||
| return formatMessage(message, false); | ||
| }); | ||
| const result = { errors: formattedErrors, warnings: formattedWarnings }; | ||
| if (result.errors.some(isLikelyASyntaxError)) { | ||
| // If there are any syntax errors, show just them. | ||
| result.errors = result.errors.filter(isLikelyASyntaxError); | ||
| } | ||
| return result; | ||
| } | ||
| var launchEditorEndpoint = '/__open-stack-frame-in-editor'; | ||
| ErrorOverlay.setEditorHandler(function editorHandler(errorLocation) { | ||
| // Keep this sync with errorOverlayMiddleware.js | ||
| fetch( | ||
| launchEditorEndpoint + | ||
| '?fileName=' + | ||
| window.encodeURIComponent(errorLocation.fileName) + | ||
| '&lineNumber=' + | ||
| window.encodeURIComponent(errorLocation.lineNumber || 1) + | ||
| '&colNumber=' + | ||
| window.encodeURIComponent(errorLocation.colNumber || 1) | ||
| ); | ||
| }); | ||
| var hadRuntimeError = false; | ||
| ErrorOverlay.startReportingRuntimeErrors({ | ||
| onError: function() { | ||
| hadRuntimeError = true; | ||
| }, | ||
| filename: '/static/js/bundle.js', | ||
| }); | ||
| if (module.hot && typeof module.hot.dispose === 'function') { | ||
| module.hot.dispose(function() { | ||
| ErrorOverlay.stopReportingRuntimeErrors(); | ||
| }); | ||
| } | ||
| var connection = new SockJS( | ||
| url.format({ | ||
| protocol: window.location.protocol, | ||
| hostname: window.location.hostname, | ||
| port: window.location.port, | ||
| pathname: '/sockjs-node', | ||
| }) | ||
| ); | ||
| connection.onclose = function() { | ||
| if (typeof console !== 'undefined' && typeof console.info === 'function') { | ||
| console.info( | ||
| 'The development server has disconnected.\nRefresh the page if necessary.' | ||
| ); | ||
| } | ||
| }; | ||
| var isFirstCompilation = true; | ||
| var mostRecentCompilationHash = null; | ||
| var hasCompileErrors = false; | ||
| function clearOutdatedErrors() { | ||
| if (typeof console !== 'undefined' && typeof console.clear === 'function') { | ||
| if (hasCompileErrors) { | ||
| console.clear(); | ||
| } | ||
| } | ||
| } | ||
| function handleSuccess() { | ||
| clearOutdatedErrors(); | ||
| var isHotUpdate = !isFirstCompilation; | ||
| isFirstCompilation = false; | ||
| hasCompileErrors = false; | ||
| if (isHotUpdate) { | ||
| tryApplyUpdates(function onHotUpdateSuccess() { | ||
| ErrorOverlay.dismissBuildError(); | ||
| }); | ||
| } | ||
| } | ||
| function handleWarnings(warnings) { | ||
| clearOutdatedErrors(); | ||
| var isHotUpdate = !isFirstCompilation; | ||
| isFirstCompilation = false; | ||
| hasCompileErrors = false; | ||
| function printWarnings() { | ||
| var formatted = formatWebpackMessages({ | ||
| warnings: warnings, | ||
| errors: [], | ||
| }); | ||
| if (typeof console !== 'undefined' && typeof console.warn === 'function') { | ||
| for (var i = 0; i < formatted.warnings.length; i++) { | ||
| if (i === 5) { | ||
| console.warn( | ||
| 'There were more warnings in other files.\n' + | ||
| 'You can find a complete log in the terminal.' | ||
| ); | ||
| break; | ||
| } | ||
| console.warn(stripAnsi(formatted.warnings[i])); | ||
| } | ||
| } | ||
| } | ||
| if (isHotUpdate) { | ||
| tryApplyUpdates(function onSuccessfulHotUpdate() { | ||
| printWarnings(); | ||
| ErrorOverlay.dismissBuildError(); | ||
| }); | ||
| } else { | ||
| printWarnings(); | ||
| } | ||
| } | ||
| function handleErrors(errors) { | ||
| clearOutdatedErrors(); | ||
| isFirstCompilation = false; | ||
| hasCompileErrors = true; | ||
| var formatted = formatWebpackMessages({ | ||
| errors: errors, | ||
| warnings: [], | ||
| }); | ||
| ErrorOverlay.reportBuildError(formatted.errors[0]); | ||
| if (typeof console !== 'undefined' && typeof console.error === 'function') { | ||
| for (var i = 0; i < formatted.errors.length; i++) { | ||
| console.error(stripAnsi(formatted.errors[i])); | ||
| } | ||
| } | ||
| } | ||
| function handleAvailableHash(hash) { | ||
| mostRecentCompilationHash = hash; | ||
| } | ||
| connection.onmessage = function(e) { | ||
| var message = JSON.parse(e.data); | ||
| switch (message.type) { | ||
| case 'hash': | ||
| handleAvailableHash(message.data); | ||
| break; | ||
| case 'still-ok': | ||
| case 'ok': | ||
| handleSuccess(); | ||
| break; | ||
| case 'content-changed': | ||
| window.location.reload(); | ||
| break; | ||
| case 'warnings': | ||
| handleWarnings(message.data); | ||
| break; | ||
| case 'errors': | ||
| handleErrors(message.data); | ||
| break; | ||
| default: | ||
| // Do nothing. | ||
| } | ||
| }; | ||
| function isUpdateAvailable() { | ||
| return mostRecentCompilationHash !== __webpack_hash__; | ||
| } | ||
| // Webpack disallows updates in other states. | ||
| function canApplyUpdates() { | ||
| return module.hot.status() === 'idle'; | ||
| } | ||
| function tryApplyUpdates(onHotUpdateSuccess) { | ||
| if (!module.hot) { | ||
| window.location.reload(); | ||
| return; | ||
| } | ||
| if (!isUpdateAvailable() || !canApplyUpdates()) { | ||
| return; | ||
| } | ||
| function handleApplyUpdates(err, updatedModules) { | ||
| if (err || !updatedModules || hadRuntimeError) { | ||
| window.location.reload(); | ||
| return; | ||
| } | ||
| if (typeof onHotUpdateSuccess === 'function') { | ||
| onHotUpdateSuccess(); | ||
| } | ||
| if (isUpdateAvailable()) { | ||
| tryApplyUpdates(); | ||
| } | ||
| } | ||
| var result = module.hot.check(/* autoApply */ true, handleApplyUpdates); | ||
| if (result && result.then) { | ||
| result.then( | ||
| function(updatedModules) { | ||
| handleApplyUpdates(null, updatedModules); | ||
| }, | ||
| function(err) { | ||
| handleApplyUpdates(err, null); | ||
| } | ||
| ); | ||
| } | ||
| } |
+6
-3
| { | ||
| "name": "c3-pack", | ||
| "version": "0.4.4", | ||
| "version": "0.4.6-beta.0", | ||
| "description": "ccc pc pack", | ||
@@ -23,3 +23,3 @@ "bin": { | ||
| "babel-loader": "^8.0.0", | ||
| "c3-version": "^0.0.1", | ||
| "c3-version": "^0.1.0", | ||
| "chalk": "^2.4.1", | ||
@@ -41,4 +41,7 @@ "clean-webpack-plugin": "^0.1.19", | ||
| "postcss-loader": "^3.0.0", | ||
| "react-error-overlay": "^5.0.4", | ||
| "read-pkg": "^4.0.1", | ||
| "size-plugin": "^1.0.1", | ||
| "sockjs-client": "^1.3.0", | ||
| "strip-ansi": "^5.0.0", | ||
| "style-loader": "^0.23.0", | ||
@@ -52,3 +55,3 @@ "url-loader": "^1.1.1", | ||
| "readme": "ERROR: No README data found!", | ||
| "_id": "c3-pack@0.4.4-alpha.1" | ||
| "_id": "c3-pack@0.4.5" | ||
| } |
@@ -23,4 +23,5 @@ /* eslint-disable */ | ||
| entry: [ | ||
| `webpack-dev-server/client?${config.url}`, | ||
| 'webpack/hot/dev-server', | ||
| // `webpack-dev-server/client?${config.url}`, | ||
| // 'webpack/hot/dev-server', | ||
| require.resolve('./webpackHotDevClient'), | ||
| path.resolve(DEV_PATH, 'index.js'), | ||
@@ -27,0 +28,0 @@ ], |
Network access
Supply chain riskThis module accesses the network.
27471
41.89%11
10%878
42.3%31
10.71%2
100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
Updated