Skip to content

Commit 3290445

Browse files
committed
Merge branch 'master' of github.com:facebookincubator/create-react-app into add-stylelint
2 parents c8c51fb + 913689f commit 3290445

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3871
-2064
lines changed

CHANGELOG-0.x.md

+1,374
Large diffs are not rendered by default.

CHANGELOG.md

+427-1,164
Large diffs are not rendered by default.

README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ my-app/
6565
public/
6666
favicon.ico
6767
index.html
68+
manifest.json
6869
src/
6970
App.css
7071
App.js
7172
App.test.js
7273
index.css
7374
index.js
7475
logo.svg
76+
registerServiceWorker.js
7577
```
7678

7779
No configuration or complicated folder structures, just the files you need to build your app.<br>
@@ -100,7 +102,9 @@ Builds the app for production to the `build` folder.<br>
100102
It correctly bundles React in production mode and optimizes the build for the best performance.
101103

102104
The build is minified and the filenames include the hashes.<br>
103-
Your app is ready to be deployed!
105+
By default, it also [includes a service worker](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app) so that your app loads from local cache on future visits.
106+
107+
Your app is ready to be deployed.
104108

105109
## User Guide
106110

@@ -116,6 +120,7 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast
116120
- [Changing the Page `<title>`](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#changing-the-page-title)
117121
- [Installing a Dependency](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#installing-a-dependency)
118122
- [Importing a Component](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#importing-a-component)
123+
- [Code Splitting](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting)
119124
- [Adding a Stylesheet](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-stylesheet)
120125
- [Post-Processing CSS](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#post-processing-css)
121126
- [Adding a CSS Preprocessor (Sass, Less etc.)](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-css-preprocessor-sass-less-etc)
@@ -132,7 +137,6 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast
132137
- [Generating Dynamic `<meta>` Tags on the Server](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#generating-dynamic-meta-tags-on-the-server)
133138
- [Pre-Rendering into Static HTML Files](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#pre-rendering-into-static-html-files)
134139
- [Running Tests](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#running-tests)
135-
- [Developing Components in Isolation](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#developing-components-in-isolation)
136140
- [Making a Progressive Web App](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app)
137141
- [Deployment](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment)
138142
- [Advanced Configuration](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#advanced-configuration)
@@ -162,6 +166,7 @@ Please refer to the [User Guide](https://github.com/facebookincubator/create-rea
162166
* Import CSS and image files directly from JavaScript.
163167
* Autoprefixed CSS, so you don’t need `-webkit` or other prefixes.
164168
* A `build` script to bundle JS, CSS, and images for production, with sourcemaps.
169+
* An offline-first [service worker](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers) and a [web app manifest](https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/), meeting all the [Progressive Web App](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app) criteria.
165170

166171
**The feature set is intentionally limited**. It doesn’t support advanced features such as server rendering or CSS modules. The tool is also **non-configurable** because it is hard to provide a cohesive experience and easy updates across a set of tools when the user can tweak anything.
167172

@@ -241,7 +246,6 @@ Notable alternatives also include:
241246
* [aik](https://github.com/d4rkr00t/aik)
242247
* [react-app](https://github.com/kriasoft/react-app)
243248
* [dev-toolkit](https://github.com/stoikerty/dev-toolkit)
244-
* [tarec](https://github.com/geowarin/tarec)
245249
* [sku](https://github.com/seek-oss/sku)
246250

247251
You can also use module bundlers like [webpack](http://webpack.github.io) and [Browserify](http://browserify.org/) directly.<br>

packages/create-react-app/createReactApp.js

+53-17
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,34 @@ function createApp(name, verbose, version, template) {
160160
const originalDirectory = process.cwd();
161161
process.chdir(root);
162162

163-
run(root, appName, version, verbose, originalDirectory, template);
163+
if (!semver.satisfies(process.version, '>=6.0.0')) {
164+
console.log(
165+
chalk.yellow(
166+
`You are using Node ${process.version} so the project will be boostrapped with an old unsupported version of tools.\n\n` +
167+
`Please update to Node 6 or higher for a better, fully supported experience.\n`
168+
)
169+
);
170+
// Fall back to latest supported react-scripts on Node 4
171+
version = '[email protected]';
172+
}
173+
174+
const useYarn = shouldUseYarn();
175+
if (!useYarn) {
176+
const npmInfo = checkNpmVersion();
177+
if (!npmInfo.hasMinNpm) {
178+
if (npmInfo.npmVersion) {
179+
console.log(
180+
chalk.yellow(
181+
`You are using npm ${npmInfo.npmVersion} so the project will be boostrapped with an old unsupported version of tools.\n\n` +
182+
`Please update to npm 3 or higher for a better, fully supported experience.\n`
183+
)
184+
);
185+
}
186+
// Fall back to latest supported react-scripts for npm 3
187+
version = '[email protected]';
188+
}
189+
}
190+
run(root, appName, version, verbose, originalDirectory, template, useYarn);
164191
}
165192

166193
function shouldUseYarn() {
@@ -190,7 +217,6 @@ function install(useYarn, dependencies, verbose, isOnline) {
190217
console.log();
191218
}
192219
} else {
193-
checkNpmVersion();
194220
command = 'npm';
195221
args = ['install', '--save', '--save-exact'].concat(dependencies);
196222
}
@@ -212,13 +238,19 @@ function install(useYarn, dependencies, verbose, isOnline) {
212238
});
213239
}
214240

215-
function run(root, appName, version, verbose, originalDirectory, template) {
241+
function run(
242+
root,
243+
appName,
244+
version,
245+
verbose,
246+
originalDirectory,
247+
template,
248+
useYarn
249+
) {
216250
const packageToInstall = getInstallPackage(version);
217251
const allDependencies = ['react', 'react-dom', packageToInstall];
218252

219253
console.log('Installing packages. This might take a couple minutes.');
220-
221-
const useYarn = shouldUseYarn();
222254
getPackageName(packageToInstall)
223255
.then(packageName => checkIfOnline(useYarn).then(isOnline => ({
224256
isOnline: isOnline,
@@ -253,6 +285,15 @@ function run(root, appName, version, verbose, originalDirectory, template) {
253285
);
254286
const init = require(scriptsPath);
255287
init(root, appName, verbose, originalDirectory, template);
288+
289+
if (version === '[email protected]') {
290+
console.log(
291+
chalk.yellow(
292+
`\nNote: the project was boostrapped with an old unsupported version of tools.\n` +
293+
`Please update to Node >=6 and npm >=3 to get supported tools in new projects.\n`
294+
)
295+
);
296+
}
256297
})
257298
.catch(reason => {
258299
console.log();
@@ -399,22 +440,17 @@ function getPackageName(installPackage) {
399440

400441
function checkNpmVersion() {
401442
let hasMinNpm = false;
443+
let npmVersion = null;
402444
try {
403-
const npmVersion = execSync('npm --version').toString();
445+
npmVersion = execSync('npm --version').toString().trim();
404446
hasMinNpm = semver.gte(npmVersion, '3.0.0');
405447
} catch (err) {
406-
return;
407-
}
408-
409-
if (!hasMinNpm) {
410-
console.error(
411-
chalk.red(
412-
'Create React App requires npm 3 or higher. \n' +
413-
'Please update your version of npm.'
414-
)
415-
);
416-
process.exit(1);
448+
// ignore
417449
}
450+
return {
451+
hasMinNpm: hasMinNpm,
452+
npmVersion: npmVersion,
453+
};
418454
}
419455

420456
function checkNodeVersion(packageName) {

packages/create-react-app/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ var currentNodeVersion = process.versions.node;
4444
var semver = currentNodeVersion.split('.');
4545
var major = semver[0];
4646

47-
if (major < 6) {
47+
if (major < 4) {
4848
console.error(
4949
chalk.red(
5050
'You are running Node ' +
5151
currentNodeVersion +
5252
'.\n' +
53-
'Create React App requires Node 6 or higher. \n' +
53+
'Create React App requires Node 4 or higher. \n' +
5454
'Please update your version of Node.'
5555
)
5656
);

packages/create-react-app/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "create-react-app",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"keywords": [
55
"react"
66
],
77
"description": "Create React apps with no build configuration.",
88
"repository": "facebookincubator/create-react-app",
99
"license": "BSD-3-Clause",
1010
"engines": {
11-
"node": ">=6"
11+
"node": ">=4"
1212
},
1313
"bugs": {
1414
"url": "https://github.com/facebookincubator/create-react-app/issues"

packages/eslint-config-react-app/index.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,14 @@ module.exports = {
195195
ignoreRestSiblings: true,
196196
},
197197
],
198-
'no-use-before-define': ['warn', 'nofunc'],
198+
'no-use-before-define': [
199+
'warn',
200+
{
201+
functions: false,
202+
classes: false,
203+
variables: false,
204+
},
205+
],
199206
'no-useless-computed-key': 'warn',
200207
'no-useless-concat': 'warn',
201208
'no-useless-constructor': 'warn',
@@ -210,7 +217,6 @@ module.exports = {
210217
],
211218
'no-with': 'warn',
212219
'no-whitespace-before-property': 'warn',
213-
'operator-assignment': ['warn', 'always'],
214220
radix: 'warn',
215221
'require-yield': 'warn',
216222
'rest-spread-spacing': ['warn', 'never'],
@@ -225,12 +231,12 @@ module.exports = {
225231
// {
226232
// object: 'require',
227233
// property: 'ensure',
228-
// message: 'Please use import() instead. More info: https://webpack.js.org/guides/code-splitting-import/#dynamic-import',
234+
// message: 'Please use import() instead. More info: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting',
229235
// },
230236
{
231237
object: 'System',
232238
property: 'import',
233-
message: 'Please use import() instead. More info: https://webpack.js.org/guides/code-splitting-import/#dynamic-import',
239+
message: 'Please use import() instead. More info: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting',
234240
},
235241
],
236242

@@ -283,7 +289,8 @@ module.exports = {
283289

284290
// https://github.com/gajus/eslint-plugin-flowtype
285291
'flowtype/define-flow-type': 'warn',
286-
'flowtype/require-valid-file-annotation': 'warn',
292+
// TODO: Reenable once https://github.com/gajus/eslint-plugin-flowtype/issues/165 is fixed
293+
//'flowtype/require-valid-file-annotation': 'warn',
287294
'flowtype/use-flow-type': 'warn',
288295
},
289296
};

packages/eslint-config-react-app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-config-react-app",
3-
"version": "1.0.0",
3+
"version": "1.0.3",
44
"description": "ESLint configuration used by Create React App",
55
"repository": "facebookincubator/create-react-app",
66
"license": "BSD-3-Clause",

packages/react-dev-utils/README.md

+49-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var publicUrl = '/my-custom-url';
3434
module.exports = {
3535
output: {
3636
// ...
37-
publicPath: publicUrl + '/'
37+
publicPath: publicUrl + '/'
3838
},
3939
// ...
4040
plugins: [
@@ -68,10 +68,14 @@ var ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
6868

6969
module.exports = {
7070
// ...
71-
plugins: [
72-
new ModuleScopePlugin(paths.appSrc),
71+
resolve: {
7372
// ...
74-
],
73+
plugins: [
74+
new ModuleScopePlugin(paths.appSrc),
75+
// ...
76+
],
77+
// ...
78+
},
7579
// ...
7680
}
7781
```
@@ -132,7 +136,7 @@ console.log('Just cleared the screen!');
132136

133137
#### `eslintFormatter(results: Object): string`
134138

135-
This is our custom ESLint formatter that integrates well with Create React App console output.
139+
This is our custom ESLint formatter that integrates well with Create React App console output.<br>
136140
You can use the default one instead if you prefer so.
137141

138142
```js
@@ -232,6 +236,14 @@ var getProcessForPort = require('react-dev-utils/getProcessForPort');
232236
getProcessForPort(3000);
233237
```
234238

239+
#### `launchEditor(fileName: string, lineNumber: number): void`
240+
241+
On macOS, tries to find a known running editor process and opens the file in it. It can also be explicitly configured by `REACT_EDITOR`, `VISUAL`, or `EDITOR` environment variables. For example, you can put `REACT_EDITOR=atom` in your `.env.local` file, and Create React App will respect that.
242+
243+
#### `noopServiceWorkerMiddleware(): ExpressMiddleware`
244+
245+
Returns Express middleware that serves a `/service-worker.js` that resets any previously set service worker configuration. Useful for development.
246+
235247
#### `openBrowser(url: string): boolean`
236248

237249
Attempts to open the browser with a given URL.<br>
@@ -248,7 +260,38 @@ if (openBrowser('http://localhost:3000')) {
248260
}
249261
```
250262

251-
#### `webpackHotDevClient.js`
263+
#### `printHostingInstructions(appPackage: Object, publicUrl: string, publicPath: string, buildFolder: string, useYarn: boolean): void`
264+
265+
Prints hosting instructions after the project is built.
266+
267+
Pass your parsed `package.json` object as `appPackage`, your the URL where you plan to host the app as `publicUrl`, `output.publicPath` from your Webpack configuration as `publicPath`, the `buildFolder` name, and whether to `useYarn` in instructions.
268+
269+
```js
270+
const appPackage = require(paths.appPackageJson);
271+
const publicUrl = paths.publicUrl;
272+
const publicPath = config.output.publicPath;
273+
printHostingInstructions(appPackage, publicUrl, publicPath, 'build', true);
274+
```
275+
276+
#### `WebpackDevServerUtils`
277+
278+
##### `choosePort(host: string, defaultPort: number): Promise<number | null>`
279+
280+
Returns a Promise resolving to either `defaultPort` or next available port if the user confirms it is okay to do. If the port is taken and the user has refused to use another port, or if the terminal is not interactive and can’t present user with the choice, resolves to `null`.
281+
282+
##### `createCompiler(webpack: Function, config: Object, appName: string, urls: Object, useYarn: boolean): WebpackCompiler`
283+
284+
Creates a Webpack compiler instance for WebpackDevServer with built-in helpful messages. Takes the `require('webpack')` entry point as the first argument. To provide the `urls` argument, use `prepareUrls()` described below.
285+
286+
##### `prepareProxy(proxySetting: string, appPublicFolder: string): Object`
287+
288+
Creates a WebpackDevServer `proxy` configuration object from the `proxy` setting in `package.json`.
289+
290+
##### `prepareUrls(protocol: string, host: string, port: number): Object`
291+
292+
Returns an object with local and remote URLs for the development server. Pass this object to `createCompiler()` described above.
293+
294+
#### `webpackHotDevClient`
252295

253296
This is an alternative client for [WebpackDevServer](https://github.com/webpack/webpack-dev-server) that shows a syntax error overlay.
254297

0 commit comments

Comments
 (0)