-
-
Notifications
You must be signed in to change notification settings - Fork 27.2k
format UglifyJs error #2650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
format UglifyJs error #2650
Changes from 1 commit
3641c5c
52bd133
0af70c2
b53f903
31fe07e
212736d
a0d089b
8f67581
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles'); | |
| const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages'); | ||
| const printHostingInstructions = require('react-dev-utils/printHostingInstructions'); | ||
| const FileSizeReporter = require('react-dev-utils/FileSizeReporter'); | ||
| const get = require('lodash/get'); | ||
|
|
||
| const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild; | ||
| const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild; | ||
|
|
@@ -93,7 +94,7 @@ measureFileSizesBeforeBuild(paths.appBuild) | |
| }, | ||
| err => { | ||
| console.log(chalk.red('Failed to compile.\n')); | ||
| console.log((err.message || err) + '\n'); | ||
| formatError(err); | ||
| process.exit(1); | ||
| } | ||
| ); | ||
|
|
@@ -141,3 +142,30 @@ function copyPublicFolder() { | |
| filter: file => file !== paths.appHtml, | ||
| }); | ||
| } | ||
|
|
||
| function formatError(err) { | ||
| const message = get(err, 'message'); | ||
|
|
||
| // Add more helpful message for UglifyJs error | ||
| if (typeof message === 'string' && message.indexOf('from UglifyJs') !== -1) { | ||
| try { | ||
| console.log( | ||
| 'UglifyJs could not parse the code from \n\n', | ||
|
||
| chalk.yellow( | ||
| err.stack.split('\n')[1].split('[')[1].split('][')[0].replace(']', '') | ||
|
||
| ), | ||
| '\n' | ||
| ); | ||
| } catch (e) { | ||
| console.log('UglifyJs could not process the code.', err); | ||
|
||
| } | ||
| console.log( | ||
| 'Please check your dependencies for any untranspiled es6 code and raise an issue with \n' + | ||
|
||
| 'the author. \n' + | ||
| '\nIf you need to use the module right now, you can try placing the source in ./src \n' + | ||
| 'and we will transpile it for you.' | ||
| ); | ||
| } else { | ||
| console.log((message || err) + '\n'); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this to
react-dev-utils. Something likeformatBuildError.