Skip to content

Commit 212736d

Browse files
committed
rename to printBuildError and add link to the docs
1 parent 31fe07e commit 212736d

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

packages/react-dev-utils/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,17 @@ compiler.plugin('done', function(stats) {
220220
});
221221
```
222222

223-
#### `formatBuildError(error: Object): String`
223+
#### `printBuildError(error: Object): String`
224224

225225
Prettify some known build errors.
226226
Pass an Error object to log a prettified error message in the console
227227

228228
```
229-
const formatBuildError = require('react-dev-utils/formatBuildError')
229+
const printBuildError = require('react-dev-utils/printBuildError')
230230
try {
231231
build()
232-
} catch(e){
233-
formatBuildError(e) // logs prettified message
232+
} catch(e) {
233+
printBuildError(e) // logs prettified message
234234
}
235235
```
236236

packages/react-dev-utils/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"crossSpawn.js",
1919
"eslintFormatter.js",
2020
"FileSizeReporter.js",
21-
"formatBuildError.js",
21+
"printBuildError.js",
2222
"formatWebpackMessages.js",
2323
"getProcessForPort.js",
2424
"inquirer.js",

packages/react-dev-utils/formatBuildError.js renamed to packages/react-dev-utils/printBuildError.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
const get = require('lodash/get');
1313
const chalk = require('chalk');
1414

15-
module.exports = function formatBuildError(err) {
15+
module.exports = function printBuildError(err) {
1616
const message = get(err, 'message');
1717
const stack = get(err, 'stack');
1818

@@ -43,10 +43,8 @@ module.exports = function formatBuildError(err) {
4343
console.log('Failed to minify the code.', err);
4444
}
4545
console.log(
46-
'Please check your dependencies for any untranspiled es6 code and raise an issue with \n' +
47-
'the author. \n' +
48-
'\nIf you need to use the module right now, you can try placing the source in ./src \n' +
49-
'and we will transpile it for you.'
46+
'Read more here: \n',
47+
'https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify'
5048
);
5149
} else {
5250
console.log((message || err) + '\n');

packages/react-scripts/scripts/build.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
3434
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
3535
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
3636
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
37-
const formatBuildError = require('react-dev-utils/formatBuildError');
37+
const printBuildError = require('react-dev-utils/printBuildError');
3838

39-
const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild;
39+
const measureFileSizesBeforeBuild =
40+
FileSizeReporter.measureFileSizesBeforeBuild;
4041
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
4142
const useYarn = fs.existsSync(paths.yarnLockFile);
4243

@@ -94,7 +95,7 @@ measureFileSizesBeforeBuild(paths.appBuild)
9495
},
9596
err => {
9697
console.log(chalk.red('Failed to compile.\n'));
97-
formatBuildError(err);
98+
printBuildError(err);
9899
process.exit(1);
99100
}
100101
);

packages/react-scripts/template/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ You can find the most recent version of this guide [here](https://github.com/fac
8787
- [`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra)
8888
- [`npm run build` exits too early](#npm-run-build-exits-too-early)
8989
- [`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku)
90+
- [`npm run build` fails to minify](#npm-run-build-fails-to-minify)
9091
- [Moment.js locales are missing](#momentjs-locales-are-missing)
9192
- [Something Missing?](#something-missing)
9293

@@ -1998,6 +1999,16 @@ moment.locale('fr');
19981999

19992000
This will only work for locales that have been explicitly imported before.
20002001

2002+
### `npm run build` fails to minify
2003+
2004+
Some dependencies may be shipping their source which our minify can't process.
2005+
Because running Babel on `node_modules` is slow, we cannot compile it to es5
2006+
before minifying it. Possible solutions are:
2007+
1. Raise an issue with the library author to ship compiled es5.
2008+
2. If it's small and compatible with out babel preset, you can place the
2009+
source in ./src.
2010+
3. Fork the project repo and publish an es5 version of it.
2011+
20012012
## Something Missing?
20022013

20032014
If you have ideas for more “How To” recipes that should be on this page, [let us know](https://github.com/facebookincubator/create-react-app/issues) or [contribute some!](https://github.com/facebookincubator/create-react-app/edit/master/packages/react-scripts/template/README.md)

0 commit comments

Comments
 (0)