diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index dc3c02df8ab..ca97a668bab 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -81,8 +81,8 @@
1. `node -v`:
2. `npm -v`:
-4. `yarn --version` (if you use Yarn):
-3. `npm ls react-scripts` (if you haven’t ejected):
+3. `yarn --version` (if you use Yarn):
+4. `npm ls react-scripts` (if you haven’t ejected):
Then, specify:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e2c349eb22..b8230403216 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,114 @@
+## 1.0.11 (2017-08-09)
+
+#### :bug: Bug Fix
+* `create-react-app`
+ * [#2884](https://github.com/facebookincubator/create-react-app/pull/2884) Improve offline heuristic for proxied environments. ([@bsyk](https://github.com/bsyk))
+
+ When a Yarn proxy is set, we will check its connectivity if we cannot reach Yarn's registry. This is often the case when DNS lookups must be made through the proxy.
+
+ * [#2853](https://github.com/facebookincubator/create-react-app/pull/2853) Allow use of scoped packages with a pinned version. ([@wileybenet](https://github.com/wileybenet))
+* `react-dev-utils`
+ * [#2796](https://github.com/facebookincubator/create-react-app/pull/2796) Properly escape HTML tags in error overlay. ([@ccloli](https://github.com/ccloli))
+
+ Elements printed in their entirety would sometimes render as HTML. This should no longer happen and should properly render as text.
+
+* `react-dev-utils`, `react-scripts`
+ * [#2834](https://github.com/facebookincubator/create-react-app/pull/2834) Make `formatWebpackMessages` return all messages ([@onigoetz](https://github.com/onigoetz))
+* `react-scripts`
+ * [#2806](https://github.com/facebookincubator/create-react-app/pull/2806) Fix SockJS version compatibility. ([@christianbundy](https://github.com/christianbundy))
+ * [#2738](https://github.com/facebookincubator/create-react-app/pull/2738) Fix Jest `node` file resolution. ([@mostafah](https://github.com/mostafah))
+
+#### :nail_care: Enhancement
+* `react-scripts`
+ * [#2818](https://github.com/facebookincubator/create-react-app/pull/2818) Allow sourcemaps to be disabled. ([@viankakrisna](https://github.com/viankakrisna))
+
+ As applications grow more complex, it is possible webpack may run out of memory while generating source maps. They may now be disabled by setting `GENERATE_SOURCEMAP=false`.
+
+ * [#2913](https://github.com/facebookincubator/create-react-app/pull/2913) Allow flags to be passed to node when running `react-scripts`. ([@koistya](https://github.com/koistya))
+ * [#2574](https://github.com/facebookincubator/create-react-app/pull/2574) Upgrade to `webpack@3`. ([@themre](https://github.com/themre))
+ * [#2747](https://github.com/facebookincubator/create-react-app/pull/2747) Simplify webpack configuration using `Rule.oneOf`. ([@Furizaa](https://github.com/Furizaa))
+* `react-dev-utils`, `react-scripts`
+ * [#2468](https://github.com/facebookincubator/create-react-app/pull/2468) Allow importing `package.json`. ([@iamdoron](https://github.com/iamdoron))
+ * [#2650](https://github.com/facebookincubator/create-react-app/pull/2650) Make UglifyJS error friendlier. ([@viankakrisna](https://github.com/viankakrisna))
+* `create-react-app`
+ * [#2785](https://github.com/facebookincubator/create-react-app/pull/2785) Change error wording and list conflicting files when initializing app. ([@OwenFlood](https://github.com/OwenFlood))
+* `react-dev-utils`
+ * [#2761](https://github.com/facebookincubator/create-react-app/pull/2761) Don't prompt to install serve if already installed. ([@OwenFlood](https://github.com/OwenFlood))
+ * [#2754](https://github.com/facebookincubator/create-react-app/pull/2754) Auto-detect JetBrains IDEs. ([@danrr](https://github.com/danrr))
+ * [#2740](https://github.com/facebookincubator/create-react-app/pull/2740) Support PyCharm in `launchEditor`. ([@danrr](https://github.com/danrr))
+ * [#2723](https://github.com/facebookincubator/create-react-app/pull/2723) Reorder vim arguments in `launchEditor` so `--remote` works. ([@trygveaa](https://github.com/trygveaa))
+* `eslint-config-react-app`, `react-scripts`
+ * [#2735](https://github.com/facebookincubator/create-react-app/pull/2735) Upgrade to `eslint@4`. ([@trungdq88](https://github.com/trungdq88))
+* `eslint-config-react-app`
+ * [#2701](https://github.com/facebookincubator/create-react-app/pull/2701) Set `allowTaggedTemplates` to true (eslint). ([@denkristoffer](https://github.com/denkristoffer))
+
+#### :memo: Documentation
+* Other
+ * [#2728](https://github.com/facebookincubator/create-react-app/pull/2728) Add Electrode to alternatives. ([@animesh10](https://github.com/animesh10))
+ * [#2788](https://github.com/facebookincubator/create-react-app/pull/2788) Update link for motion. ([@viankakrisna](https://github.com/viankakrisna))
+ * [#2697](https://github.com/facebookincubator/create-react-app/pull/2697) Fix env list ordering. ([@alexeyraspopov](https://github.com/alexeyraspopov))
+* `react-dev-utils`
+ * [#2798](https://github.com/facebookincubator/create-react-app/pull/2798) Update note about `webpackHotDevClient` support. ([@ForbesLindesay](https://github.com/ForbesLindesay))
+* `react-scripts`
+ * [#2822](https://github.com/facebookincubator/create-react-app/pull/2822) Add explicit "Opting Out of Caching" header. ([@gaearon](https://github.com/gaearon))
+ * [#2725](https://github.com/facebookincubator/create-react-app/pull/2725) Fixed typo. ([@zeel](https://github.com/zeel))
+ * [#2668](https://github.com/facebookincubator/create-react-app/pull/2668) Document `basename` feature in `react-router`. ([@viankakrisna](https://github.com/viankakrisna))
+ * [#2719](https://github.com/facebookincubator/create-react-app/pull/2719) Remove Windows note for `source-map-explorer`. ([@hodanny](https://github.com/hodanny))
+* `babel-preset-react-app`
+ * [#2732](https://github.com/facebookincubator/create-react-app/pull/2732) Update link to issue blocking JSX hoisting. ([@ForbesLindesay](https://github.com/ForbesLindesay))
+
+#### :house: Internal
+* `create-react-app`, `eslint-config-react-app`, `react-dev-utils`, `react-error-overlay`, `react-scripts`
+ * [#2923](https://github.com/facebookincubator/create-react-app/pull/2923) Update deps. ([@Timer](https://github.com/Timer))
+* `eslint-config-react-app`
+ * [#2718](https://github.com/facebookincubator/create-react-app/pull/2718) Re-enable flowtype warning. ([@oskarkook](https://github.com/oskarkook))
+* Other
+ * [#2700](https://github.com/facebookincubator/create-react-app/pull/2700) Unstage `yarn.lock` pre-commit. ([@jdcrensh](https://github.com/jdcrensh))
+* `react-scripts`
+ * [#2873](https://github.com/facebookincubator/create-react-app/pull/2873) Use template strings. ([@monkindey](https://github.com/monkindey))
+
+#### Committers: 26
+- 864907600cc ([ccloli](https://github.com/ccloli))
+- Ade Viankakrisna Fadlil ([viankakrisna](https://github.com/viankakrisna))
+- Alexey Raspopov ([alexeyraspopov](https://github.com/alexeyraspopov))
+- Andreas Hoffmann ([Furizaa](https://github.com/Furizaa))
+- Animesh Dutta ([animesh10](https://github.com/animesh10))
+- Ben Sykes ([bsyk](https://github.com/bsyk))
+- Christian Bundy ([christianbundy](https://github.com/christianbundy))
+- Dan Abramov ([gaearon](https://github.com/gaearon))
+- Dan Ristea ([danrr](https://github.com/danrr))
+- Danny Ho ([hodanny](https://github.com/hodanny))
+- Forbes Lindesay ([ForbesLindesay](https://github.com/ForbesLindesay))
+- Joe Haddad ([Timer](https://github.com/Timer))
+- Jon Crenshaw ([jdcrensh](https://github.com/jdcrensh))
+- Kiho · Cham ([monkindey](https://github.com/monkindey))
+- Konstantin Tarkus ([koistya](https://github.com/koistya))
+- Kristoffer ([denkristoffer](https://github.com/denkristoffer))
+- Mostafa Hajizadeh ([mostafah](https://github.com/mostafah))
+- Oskar Köök ([oskarkook](https://github.com/oskarkook))
+- Owen Flood ([OwenFlood](https://github.com/OwenFlood))
+- Stéphane Goetz ([onigoetz](https://github.com/onigoetz))
+- Trygve Aaberge ([trygveaa](https://github.com/trygveaa))
+- Wiley Bennett ([wileybenet](https://github.com/wileybenet))
+- [iamdoron](https://github.com/iamdoron)
+- [themre](https://github.com/themre)
+- zeel ([zeel](https://github.com/zeel))
+- Đinh Quang Trung ([trungdq88](https://github.com/trungdq88))
+
+### Migrating from 1.0.10 to 1.0.11
+
+Inside any created project that has not been ejected, run:
+
+```
+npm install --save --save-exact react-scripts@1.0.11
+```
+
+or
+
+```
+yarn add --exact react-scripts@1.0.11
+```
+
## 1.0.10 (June 29, 2017)
#### :bug: Bug Fix
@@ -110,7 +221,7 @@ yarn add --exact react-scripts@1.0.9
* [#2600](https://github.com/facebookincubator/create-react-app/pull/2600) Add empty mock for `dgram` Node module. ([@micopiira](https://github.com/micopiira))
* [#2458](https://github.com/facebookincubator/create-react-app/pull/2458) Add names to module factories in development. ([@Zaccc123](https://github.com/Zaccc123))
* [#2551](https://github.com/facebookincubator/create-react-app/pull/2551) In new projects, unregister service worker and force reload if `service-worker.js` is not found. ([@ro-savage](https://github.com/ro-savage))
-
+
* `babel-preset-react-app`, `react-dev-utils`, `react-scripts`
* [#2658](https://github.com/facebookincubator/create-react-app/pull/2658) Bump dependencies. ([@gaearon](https://github.com/gaearon))
@@ -119,7 +230,7 @@ yarn add --exact react-scripts@1.0.9
* [#2657](https://github.com/facebookincubator/create-react-app/pull/2657) Put `react-scripts` in `dependencies`, not `devDependencies`. ([@gaearon](https://github.com/gaearon))
* [#2635](https://github.com/facebookincubator/create-react-app/pull/2635) Silence unhelpful npm warnings. ([@gaearon](https://github.com/gaearon))
-
+
* `react-dev-utils`
* [#2637](https://github.com/facebookincubator/create-react-app/pull/2637) Auto-detect Brackets editor from error overlay. ([@petetnt](https://github.com/petetnt))
@@ -176,7 +287,7 @@ yarn add --exact react-scripts@1.0.9
* [#2397](https://github.com/facebookincubator/create-react-app/pull/2397) Fix command in e2e-kitchensink.sh cleanup. ([@ro-savage](https://github.com/ro-savage))
* [#2388](https://github.com/facebookincubator/create-react-app/pull/2388) Fix wrong path expansion in end-to-end test. ([@gaearon](https://github.com/gaearon))
* [#2387](https://github.com/facebookincubator/create-react-app/pull/2387) Catch "No tests found" during CI. ([@EnoahNetzach](https://github.com/EnoahNetzach))
-
+
* `react-scripts`
* [#2408](https://github.com/facebookincubator/create-react-app/pull/2408) E2E testing enhancements. ([@EnoahNetzach](https://github.com/EnoahNetzach))
@@ -573,7 +684,7 @@ yarn add --dev --exact react-scripts@1.0.1
We’ve been working on this release for the past few months, and there are many big impovements, from migrating to webpack 2 to a brand new runtime error overlay and built-in support for Progressive Web Apps.
-So instead of just enumerating them here, we decided to write a blog post about all the new features.
+So instead of just enumerating them here, we decided to write a blog post about all the new features.
Check it out: **[What’s New in Create React App](https://facebook.github.io/react/blog/2017/05/18/whats-new-in-create-react-app.html)**.
Have you read it? Now let's see how to update your app to the latest version.
diff --git a/README.md b/README.md
index 05435cd6148..1146edbdc4f 100644
--- a/README.md
+++ b/README.md
@@ -248,11 +248,12 @@ Some of the more popular and actively maintained ones are:
* [NYTimes/kyt](https://github.com/NYTimes/kyt)
* [zeit/next.js](https://github.com/zeit/next.js)
* [gatsbyjs/gatsby](https://github.com/gatsbyjs/gatsby)
+* [electrode-io/electrode](https://github.com/electrode-io/electrode)
Notable alternatives also include:
* [enclave](https://github.com/eanplatter/enclave)
-* [motion](https://github.com/motion/motion)
+* [motion](https://github.com/steelbrain/pundle/tree/master/packages/motion)
* [quik](https://github.com/satya164/quik)
* [sagui](https://github.com/saguijs/sagui)
* [roc](https://github.com/rocjs/roc)
diff --git a/lerna.json b/lerna.json
index 7ca916a8569..1673f8a3187 100644
--- a/lerna.json
+++ b/lerna.json
@@ -1,5 +1,5 @@
{
- "lerna": "2.0.0-rc.5",
+ "lerna": "2.0.0",
"version": "independent",
"changelog": {
"repo": "facebookincubator/create-react-app",
diff --git a/package.json b/package.json
index b9abb1ce865..c3dd6404b5e 100644
--- a/package.json
+++ b/package.json
@@ -14,10 +14,10 @@
"precommit": "lint-staged"
},
"devDependencies": {
- "eslint": "3.19.0",
+ "eslint": "^4.4.1",
"husky": "^0.13.2",
- "lerna": "2.0.0-rc.5",
- "lerna-changelog": "^0.2.3",
+ "lerna": "^2.0.0",
+ "lerna-changelog": "^0.6.0",
"lint-staged": "^3.3.1",
"prettier": "^1.5.2"
},
@@ -25,6 +25,9 @@
"*.js": [
"prettier --trailing-comma es5 --single-quote --write",
"git add"
+ ],
+ "yarn.lock": [
+ "git rm --cached"
]
}
}
diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js
index c8f20dde61d..f6102dc0529 100644
--- a/packages/babel-preset-react-app/index.js
+++ b/packages/babel-preset-react-app/index.js
@@ -129,10 +129,7 @@ if (env === 'test') {
if (env === 'production') {
// Optimization: hoist JSX that never changes out of render()
- // Disabled because of issues:
- // * https://github.com/facebookincubator/create-react-app/issues/525
- // * https://phabricator.babeljs.io/search/query/pCNlnC2xzwzx/
- // * https://github.com/babel/babel/issues/4516
+ // Disabled because of issues: https://github.com/facebookincubator/create-react-app/issues/553
// TODO: Enable again when these issues are resolved.
// plugins.push.apply(plugins, [
// require.resolve('babel-plugin-transform-react-constant-elements')
diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json
index d10188fda02..dce6742985f 100644
--- a/packages/babel-preset-react-app/package.json
+++ b/packages/babel-preset-react-app/package.json
@@ -1,6 +1,6 @@
{
"name": "babel-preset-react-app",
- "version": "3.0.1",
+ "version": "3.0.2",
"description": "Babel preset used by Create React App",
"repository": "facebookincubator/create-react-app",
"license": "BSD-3-Clause",
diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js
index 4509b49788d..4a1b7901dc4 100755
--- a/packages/create-react-app/createReactApp.js
+++ b/packages/create-react-app/createReactApp.js
@@ -47,6 +47,7 @@ const semver = require('semver');
const dns = require('dns');
const tmp = require('tmp');
const unpack = require('tar-pack').unpack;
+const url = require('url');
const hyperquest = require('hyperquest');
const packageJson = require('./package.json');
@@ -143,11 +144,7 @@ function createApp(name, verbose, version, template) {
checkAppName(appName);
fs.ensureDirSync(name);
- if (!isSafeToCreateProjectIn(root)) {
- console.log(
- `The directory ${chalk.green(name)} contains files that could conflict.`
- );
- console.log('Try using a new directory name.');
+ if (!isSafeToCreateProjectIn(root, name)) {
process.exit(1);
}
@@ -444,8 +441,8 @@ function getPackageName(installPackage) {
// Pull package name out of git urls e.g:
// git+https://github.com/mycompany/react-scripts.git
// git+ssh://github.com/mycompany/react-scripts.git#v1.2.3
- return Promise.resolve(installPackage.match(/([^\/]+)\.git(#.*)?$/)[1]);
- } else if (installPackage.indexOf('@') > 0) {
+ return Promise.resolve(installPackage.match(/([^/]+)\.git(#.*)?$/)[1]);
+ } else if (installPackage.match(/.+@/)) {
// Do not match @scope/ when stripping off @version or @tag
return Promise.resolve(
installPackage.charAt(0) + installPackage.substr(1).split('@')[0]
@@ -571,7 +568,7 @@ function setCaretRangeForRuntimeDeps(packageName) {
// If project only contains files generated by GH, it’s safe.
// We also special case IJ-based products .idea because it integrates with CRA:
// https://github.com/facebookincubator/create-react-app/pull/368#issuecomment-243446094
-function isSafeToCreateProjectIn(root) {
+function isSafeToCreateProjectIn(root, name) {
const validFiles = [
'.DS_Store',
'Thumbs.db',
@@ -585,7 +582,28 @@ function isSafeToCreateProjectIn(root) {
'.hgignore',
'.hgcheck',
];
- return fs.readdirSync(root).every(file => validFiles.indexOf(file) >= 0);
+ console.log();
+
+ const conflicts = fs
+ .readdirSync(root)
+ .filter(file => !validFiles.includes(file));
+ if (conflicts.length < 1) {
+ return true;
+ }
+
+ console.log(
+ `The directory ${chalk.green(name)} contains files that could conflict:`
+ );
+ console.log();
+ for (const file of conflicts) {
+ console.log(` ${file}`);
+ }
+ console.log();
+ console.log(
+ 'Either try using a new directory name, or remove the files listed above.'
+ );
+
+ return false;
}
function checkIfOnline(useYarn) {
@@ -597,7 +615,15 @@ function checkIfOnline(useYarn) {
return new Promise(resolve => {
dns.lookup('registry.yarnpkg.com', err => {
- resolve(err === null);
+ if (err != null && process.env.https_proxy) {
+ // If a proxy is defined, we likely can't resolve external hostnames.
+ // Try to resolve the proxy name as an indication of a connection.
+ dns.lookup(url.parse(process.env.https_proxy).hostname, proxyErr => {
+ resolve(proxyErr == null);
+ });
+ } else {
+ resolve(err == null);
+ }
});
});
}
diff --git a/packages/create-react-app/package.json b/packages/create-react-app/package.json
index 28502ca077a..42ee3497ea5 100644
--- a/packages/create-react-app/package.json
+++ b/packages/create-react-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-react-app",
- "version": "1.3.3",
+ "version": "1.4.0",
"keywords": [
"react"
],
diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js
index 7298a8c3b3d..4e94e650c38 100644
--- a/packages/eslint-config-react-app/index.js
+++ b/packages/eslint-config-react-app/index.js
@@ -185,6 +185,7 @@ module.exports = {
{
allowShortCircuit: true,
allowTernary: true,
+ allowTaggedTemplates: true,
},
],
'no-unused-labels': 'warn',
@@ -290,8 +291,7 @@ module.exports = {
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/define-flow-type': 'warn',
- // TODO: Reenable once https://github.com/gajus/eslint-plugin-flowtype/issues/165 is fixed
- //'flowtype/require-valid-file-annotation': 'warn',
+ 'flowtype/require-valid-file-annotation': 'warn',
'flowtype/use-flow-type': 'warn',
},
};
diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json
index cd36a70e5cb..375c9f54b87 100644
--- a/packages/eslint-config-react-app/package.json
+++ b/packages/eslint-config-react-app/package.json
@@ -1,6 +1,6 @@
{
"name": "eslint-config-react-app",
- "version": "1.0.5",
+ "version": "2.0.0",
"description": "ESLint configuration used by Create React App",
"repository": "facebookincubator/create-react-app",
"license": "BSD-3-Clause",
@@ -12,10 +12,10 @@
],
"peerDependencies": {
"babel-eslint": "^7.2.3",
- "eslint": "^3.19.0",
- "eslint-plugin-flowtype": "^2.33.0",
- "eslint-plugin-import": "^2.2.0",
- "eslint-plugin-jsx-a11y": "^5.0.3",
- "eslint-plugin-react": "^7.0.1"
+ "eslint": "^4.1.1",
+ "eslint-plugin-flowtype": "^2.34.1",
+ "eslint-plugin-import": "^2.6.0",
+ "eslint-plugin-jsx-a11y": "^5.1.1",
+ "eslint-plugin-react": "^7.1.0"
}
}
diff --git a/packages/react-dev-utils/ModuleScopePlugin.js b/packages/react-dev-utils/ModuleScopePlugin.js
index f630a0279f5..3a10904d36b 100644
--- a/packages/react-dev-utils/ModuleScopePlugin.js
+++ b/packages/react-dev-utils/ModuleScopePlugin.js
@@ -13,8 +13,9 @@ const chalk = require('chalk');
const path = require('path');
class ModuleScopePlugin {
- constructor(appSrc) {
+ constructor(appSrc, allowedFiles = []) {
this.appSrc = appSrc;
+ this.allowedFiles = new Set(allowedFiles);
}
apply(resolver) {
@@ -40,15 +41,16 @@ class ModuleScopePlugin {
if (relative.startsWith('../') || relative.startsWith('..\\')) {
return callback();
}
- // Find path from src to the requested file
- const requestRelative = path.relative(
- appSrc,
- path.resolve(
- path.dirname(request.context.issuer),
- request.__innerRequest_request
- )
+ const requestFullPath = path.resolve(
+ path.dirname(request.context.issuer),
+ request.__innerRequest_request
);
+ if (this.allowedFiles.has(requestFullPath)) {
+ return callback();
+ }
+ // Find path from src to the requested file
// Error if in a parent directory of src/
+ const requestRelative = path.relative(appSrc, requestFullPath);
if (
requestRelative.startsWith('../') ||
requestRelative.startsWith('..\\')
diff --git a/packages/react-dev-utils/README.md b/packages/react-dev-utils/README.md
index 166e1bfaea3..e23f0a294aa 100644
--- a/packages/react-dev-utils/README.md
+++ b/packages/react-dev-utils/README.md
@@ -57,7 +57,7 @@ module.exports = {
```
-#### `new ModuleScopePlugin(appSrc: string)`
+#### `new ModuleScopePlugin(appSrc: string, allowedFiles?: string[])`
This Webpack plugin ensures that relative imports from app's source directory don't reach outside of it.
@@ -71,7 +71,7 @@ module.exports = {
resolve: {
// ...
plugins: [
- new ModuleScopePlugin(paths.appSrc),
+ new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
// ...
],
// ...
@@ -220,6 +220,20 @@ compiler.plugin('done', function(stats) {
});
```
+#### `printBuildError(error: Object): void`
+
+Prettify some known build errors.
+Pass an Error object to log a prettified error message in the console.
+
+```
+ const printBuildError = require('react-dev-utils/printBuildError')
+ try {
+ build()
+ } catch(e) {
+ printBuildError(e) // logs prettified message
+ }
+```
+
#### `getProcessForPort(port: number): string`
Finds the currently running process on `port`.
@@ -295,7 +309,7 @@ Returns an object with local and remote URLs for the development server. Pass th
This is an alternative client for [WebpackDevServer](https://github.com/webpack/webpack-dev-server) that shows a syntax error overlay.
-It currently supports only Webpack 1.x.
+It currently supports only Webpack 3.x.
```js
// Webpack development config
diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js
index 8a66b15ec0c..1cd060592f9 100644
--- a/packages/react-dev-utils/WebpackDevServerUtils.js
+++ b/packages/react-dev-utils/WebpackDevServerUtils.js
@@ -164,6 +164,11 @@ function createCompiler(webpack, config, appName, urls, useYarn) {
// If errors exist, only show errors.
if (messages.errors.length) {
+ // Only keep the first error. Others are often indicative
+ // of the same problem, but confuse the reader with noise.
+ if (messages.errors.length > 1) {
+ messages.errors.length = 1;
+ }
console.log(chalk.red('Failed to compile.\n'));
console.log(messages.errors.join('\n\n'));
return;
diff --git a/packages/react-dev-utils/ansiHTML.js b/packages/react-dev-utils/ansiHTML.js
index 9f53cea67a3..90bf70374ee 100644
--- a/packages/react-dev-utils/ansiHTML.js
+++ b/packages/react-dev-utils/ansiHTML.js
@@ -10,6 +10,8 @@
'use strict';
var Anser = require('anser');
+var Entities = require('html-entities').AllHtmlEntities;
+var entities = new Entities();
// Color scheme inspired by https://chriskempson.github.io/base16/css/base16-github.css
// var base00 = 'ffffff'; // Default Background
@@ -61,7 +63,7 @@ var anserMap = {
};
function ansiHTML(txt) {
- var arr = new Anser().ansiToJson(txt, {
+ var arr = new Anser().ansiToJson(entities.encode(txt), {
use_classes: true,
});
diff --git a/packages/react-dev-utils/formatWebpackMessages.js b/packages/react-dev-utils/formatWebpackMessages.js
index 5dfd099c65c..1f22a0059a5 100644
--- a/packages/react-dev-utils/formatWebpackMessages.js
+++ b/packages/react-dev-utils/formatWebpackMessages.js
@@ -97,7 +97,7 @@ function formatMessage(message, isError) {
// from user code generated by WebPack. For more information see
// https://github.com/facebookincubator/create-react-app/pull/1050
message = message.replace(
- /^\s*at\s((?!webpack:).)*:\d+:\d+[\s\)]*(\n|$)/gm,
+ /^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
''
); // at ... ...:x:y
@@ -121,11 +121,6 @@ function formatWebpackMessages(json) {
// preceding a much more useful Babel syntax error.
result.errors = result.errors.filter(isLikelyASyntaxError);
}
- // Only keep the first error. Others are often indicative
- // of the same problem, but confuse the reader with noise.
- if (result.errors.length > 1) {
- result.errors.length = 1;
- }
return result;
}
diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js
index bcf0a506069..e1ea29c8869 100644
--- a/packages/react-dev-utils/launchEditor.js
+++ b/packages/react-dev-utils/launchEditor.js
@@ -38,6 +38,22 @@ const COMMON_EDITORS_OSX = {
'/Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2':
'/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl',
'/Applications/Visual Studio Code.app/Contents/MacOS/Electron': 'code',
+ '/Applications/AppCode.app/Contents/MacOS/appcode':
+ '/Applications/AppCode.app/Contents/MacOS/appcode',
+ '/Applications/CLion.app/Contents/MacOS/clion':
+ '/Applications/CLion.app/Contents/MacOS/clion',
+ '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea':
+ '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea',
+ '/Applications/PhpStorm.app/Contents/MacOS/phpstorm':
+ '/Applications/PhpStorm.app/Contents/MacOS/phpstorm',
+ '/Applications/PyCharm.app/Contents/MacOS/pycharm':
+ '/Applications/PyCharm.app/Contents/MacOS/pycharm',
+ '/Applications/PyCharm CE.app/Contents/MacOS/pycharm':
+ '/Applications/PyCharm CE.app/Contents/MacOS/pycharm',
+ '/Applications/RubyMine.app/Contents/MacOS/rubymine':
+ '/Applications/RubyMine.app/Contents/MacOS/rubymine',
+ '/Applications/WebStorm.app/Contents/MacOS/webstorm':
+ '/Applications/WebStorm.app/Contents/MacOS/webstorm',
};
const COMMON_EDITORS_WIN = [
@@ -46,6 +62,18 @@ const COMMON_EDITORS_WIN = [
'atom.exe',
'sublime_text.exe',
'notepad++.exe',
+ 'clion.exe',
+ 'clion64.exe',
+ 'idea.exe',
+ 'idea64.exe',
+ 'phpstorm.exe',
+ 'phpstorm64.exe',
+ 'pycharm.exe',
+ 'pycharm64.exe',
+ 'rubymine.exe',
+ 'rubymine64.exe',
+ 'webstorm.exe',
+ 'webstorm64.exe',
];
function addWorkspaceToArgumentsIfExists(args, workspace) {
@@ -58,9 +86,6 @@ function addWorkspaceToArgumentsIfExists(args, workspace) {
function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) {
const editorBasename = path.basename(editor).replace(/\.(exe|cmd|bat)$/i, '');
switch (editorBasename) {
- case 'vim':
- case 'mvim':
- return [fileName, '+' + lineNumber];
case 'atom':
case 'Atom':
case 'Atom Beta':
@@ -68,12 +93,12 @@ function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) {
case 'sublime':
case 'sublime_text':
case 'wstorm':
- case 'appcode':
case 'charm':
- case 'idea':
return [fileName + ':' + lineNumber];
case 'notepad++':
return ['-n' + lineNumber, fileName];
+ case 'vim':
+ case 'mvim':
case 'joe':
case 'emacs':
case 'emacsclient':
@@ -88,10 +113,19 @@ function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) {
['-g', fileName + ':' + lineNumber],
workspace
);
- case 'webstorm':
- case 'webstorm64':
+ case 'appcode':
+ case 'clion':
+ case 'clion64':
+ case 'idea':
+ case 'idea64':
case 'phpstorm':
case 'phpstorm64':
+ case 'pycharm':
+ case 'pycharm64':
+ case 'rubymine':
+ case 'rubymine64':
+ case 'webstorm':
+ case 'webstorm64':
return addWorkspaceToArgumentsIfExists(
['--line', lineNumber, fileName],
workspace
diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json
index b4539788d26..0e4e135f89f 100644
--- a/packages/react-dev-utils/package.json
+++ b/packages/react-dev-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "react-dev-utils",
- "version": "3.0.2",
+ "version": "3.1.0",
"description": "Webpack utilities used by Create React App",
"repository": "facebookincubator/create-react-app",
"license": "BSD-3-Clause",
@@ -18,13 +18,14 @@
"crossSpawn.js",
"eslintFormatter.js",
"FileSizeReporter.js",
+ "printBuildError.js",
"formatWebpackMessages.js",
"getProcessForPort.js",
"inquirer.js",
"InterpolateHtmlPlugin.js",
"launchEditor.js",
- "noopServiceWorkerMiddleware.js",
"ModuleScopePlugin.js",
+ "noopServiceWorkerMiddleware.js",
"openBrowser.js",
"openChrome.applescript",
"printHostingInstructions.js",
@@ -37,13 +38,14 @@
"anser": "1.4.1",
"babel-code-frame": "6.22.0",
"chalk": "1.1.3",
- "cross-spawn": "4.0.2",
+ "cross-spawn": "5.1.0",
"detect-port-alt": "1.1.3",
"escape-string-regexp": "1.0.5",
- "filesize": "3.3.0",
+ "filesize": "3.5.10",
+ "global-modules": "1.0.0",
"gzip-size": "3.0.0",
"html-entities": "1.2.1",
- "inquirer": "3.1.1",
+ "inquirer": "3.2.1",
"is-root": "1.0.0",
"opn": "5.1.0",
"recursive-readdir": "2.2.1",
diff --git a/packages/react-dev-utils/printBuildError.js b/packages/react-dev-utils/printBuildError.js
new file mode 100644
index 00000000000..208c708e11a
--- /dev/null
+++ b/packages/react-dev-utils/printBuildError.js
@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2015-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+'use strict';
+
+const get = require('lodash/get');
+const chalk = require('chalk');
+
+module.exports = function printBuildError(err) {
+ const message = get(err, 'message');
+ const stack = get(err, 'stack');
+
+ // Add more helpful message for UglifyJs error
+ if (
+ stack &&
+ typeof message === 'string' &&
+ message.indexOf('from UglifyJs') !== -1
+ ) {
+ try {
+ const matched = /Unexpected token:(.+)\[(.+):(.+),(.+)\]\[.+\]/.exec(
+ stack
+ );
+ if (!matched) {
+ throw new Error(
+ "The regex pattern is not matched. Maybe UglifyJs changed it's message?"
+ );
+ }
+ const problemPath = matched[2];
+ const line = matched[3];
+ const column = matched[4];
+ console.log(
+ 'Failed to minify the code from this file: \n\n',
+ chalk.yellow(`${problemPath} line ${line}:${column}`),
+ '\n'
+ );
+ } catch (ignored) {
+ console.log('Failed to minify the code.', err);
+ }
+ console.log('Read more here: http://bit.ly/2tRViJ9');
+ } else {
+ console.log((message || err) + '\n');
+ }
+ console.log();
+};
diff --git a/packages/react-dev-utils/printHostingInstructions.js b/packages/react-dev-utils/printHostingInstructions.js
index f9882d44a7c..2ef25767aa2 100644
--- a/packages/react-dev-utils/printHostingInstructions.js
+++ b/packages/react-dev-utils/printHostingInstructions.js
@@ -11,6 +11,8 @@
const chalk = require('chalk');
const url = require('url');
+const globalModules = require('global-modules');
+const fs = require('fs');
function printHostingInstructions(
appPackage,
@@ -121,10 +123,12 @@ function printHostingInstructions(
);
console.log('You may serve it with a static server:');
console.log();
- if (useYarn) {
- console.log(` ${chalk.cyan('yarn')} global add serve`);
- } else {
- console.log(` ${chalk.cyan('npm')} install -g serve`);
+ if (!fs.existsSync(`${globalModules}/serve`)) {
+ if (useYarn) {
+ console.log(` ${chalk.cyan('yarn')} global add serve`);
+ } else {
+ console.log(` ${chalk.cyan('npm')} install -g serve`);
+ }
}
console.log(` ${chalk.cyan('serve')} -s ${buildFolder}`);
console.log();
diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js
index 78002b28efb..f2f206a5cd2 100644
--- a/packages/react-dev-utils/webpackHotDevClient.js
+++ b/packages/react-dev-utils/webpackHotDevClient.js
@@ -22,9 +22,7 @@ var SockJS = require('sockjs-client');
var stripAnsi = require('strip-ansi');
var url = require('url');
var formatWebpackMessages = require('./formatWebpackMessages');
-var Entities = require('html-entities').AllHtmlEntities;
var ansiHTML = require('./ansiHTML');
-var entities = new Entities();
function createOverlayIframe(onIframeLoad) {
var iframe = document.createElement('iframe');
@@ -138,7 +136,7 @@ function showErrorOverlay(message) {
'margin-bottom: 0.5em; overflow-x: auto; white-space: pre-wrap; ' +
'border-radius: 0.25rem; background-color: rgba(206, 17, 38, 0.05)">' +
'' +
- ansiHTML(entities.encode(message)) +
+ ansiHTML(message) +
'
' +
'