From 1c2ab8c797db1aed0f0d988acc48f8a9bd454373 Mon Sep 17 00:00:00 2001 From: Luke Barbuto Date: Wed, 30 Nov 2016 12:46:08 -0800 Subject: [PATCH 0001/1739] Rename scripts package and update urls for Zeal --- packages/react-scripts/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 58bb4ab1d06..51eb27f771e 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,14 +1,14 @@ { - "name": "react-scripts", - "version": "0.7.0", + "name": "@zeal/react-scripts", + "version": "0.1.0", "description": "Configuration and scripts for Create React App.", - "repository": "facebookincubator/create-react-app", + "repository": "codingzeal/create-react-app", "license": "BSD-3-Clause", "engines": { "node": ">=4" }, "bugs": { - "url": "https://github.com/facebookincubator/create-react-app/issues" + "url": "https://github.com/codingzeal/create-react-app/issues" }, "files": [ ".babelrc", From 6727d4a830d3c59b7d47b64c0b6fc726c53273f8 Mon Sep 17 00:00:00 2001 From: Luke Barbuto Date: Wed, 30 Nov 2016 12:46:24 -0800 Subject: [PATCH 0002/1739] Fix reloading when served from a custom backend Before these changes, when the bundle was served from a custom web server, requests for updates were being sent to the port seen on window rather than what the webpack dev server was running on. --- .../config/webpack.config.dev.js | 24 ++++++++++++++----- packages/react-scripts/scripts/start.js | 12 ++++++++-- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index d875c63e8d9..0031188fac2 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -22,7 +22,14 @@ var paths = require('./paths'); // Webpack uses `publicPath` to determine where the app is being served from. // In development, we always serve from the root. This makes config easier. -var publicPath = '/'; +// ZEAL: Setting publicPath in the start script and passing it in. Since we are +// mounting this app on various backends, the dev server port will be different +// from the port on window location. Because of this, we need the full public +// path, not just the relative path. Elements of the full path can be dynamic, +// but are all known in the start script, making it the best place to define the +// public path. +// var publicPath = '/'; + // `publicUrl` is just like `publicPath`, but we will provide it to our app // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript. // Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz. @@ -33,7 +40,9 @@ var env = getClientEnvironment(publicUrl); // This is the development configuration. // It is focused on developer experience and fast rebuilds. // The production configuration is different and lives in a separate file. -module.exports = { +// ZEAL: Converted to a function to allow injecting the publicPath. +module.exports = function(publicPath) { + return { // This makes the bundle appear split into separate modules in the devtools. // We don't use source maps here because they can be confusing: // https://github.com/facebookincubator/create-react-app/issues/343#issuecomment-237241875 @@ -51,9 +60,12 @@ module.exports = { // Note: instead of the default WebpackDevServer client, we use a custom one // to bring better experience for Create React App users. You can replace // the line below with these two lines if you prefer the stock client: - // require.resolve('webpack-dev-server/client') + '?/', - // require.resolve('webpack/hot/dev-server'), - require.resolve('react-dev-utils/webpackHotDevClient'), + // ZEAL: Opted to use the default client because the custom one gets the + // port off window location, which will be different from the dev server + // when the app is served from a different back end. + require.resolve('webpack-dev-server/client') + '?' + publicPath, + require.resolve('webpack/hot/dev-server'), + // require.resolve('react-dev-utils/webpackHotDevClient'), // We ship a few polyfills by default: require.resolve('./polyfills'), // Finally, this is your app's code: @@ -221,4 +233,4 @@ module.exports = { net: 'empty', tls: 'empty' } -}; +}}; diff --git a/packages/react-scripts/scripts/start.js b/packages/react-scripts/scripts/start.js index 8723c281637..3ce30216078 100644 --- a/packages/react-scripts/scripts/start.js +++ b/packages/react-scripts/scripts/start.js @@ -57,7 +57,9 @@ if (isSmokeTest) { function setupCompiler(host, port, protocol) { // "Compiler" is a low-level interface to Webpack. // It lets us listen to some events and provide our own custom messages. - compiler = webpack(config, handleCompile); + // ZEAL: Injecting the publicPath into the config since it needs to be fully + // qualified now. More notes in the config regarding publicPath. + compiler = webpack(config(publicPath(host, port, protocol)), handleCompile); // "invalid" event fires when you have changed a file, and Webpack is // recompiling a bundle. WebpackDevServer takes care to pause serving the @@ -221,7 +223,9 @@ function runDevServer(host, port, protocol) { hot: true, // It is important to tell WebpackDevServer to use the same "root" path // as we specified in the config. In development, we always serve from /. - publicPath: config.output.publicPath, + // ZEAL: The public path is now being injected into the config with this + // function, so no need to reach into the config to get it anymore. + publicPath: publicPath(host, port, protocol), // WebpackDevServer is noisy by default so we emit custom message instead // by listening to the compiler events with `compiler.plugin` calls above. quiet: true, @@ -251,6 +255,10 @@ function runDevServer(host, port, protocol) { }); } +function publicPath(host, port, protocol) { + return protocol + '://' + host + ':' + port + '/' +} + function run(port) { var protocol = process.env.HTTPS === 'true' ? "https" : "http"; var host = process.env.HOST || 'localhost'; From a065ef110fbba05ed0d4175489b76760294fe0de Mon Sep 17 00:00:00 2001 From: Byron Matto Date: Wed, 30 Nov 2016 12:46:46 -0800 Subject: [PATCH 0003/1739] Add support for css modules --- packages/react-scripts/config/webpack.config.dev.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 0031188fac2..d20d42587a1 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -147,9 +147,10 @@ module.exports = function(publicPath) { // "style" loader turns CSS into JS modules that inject ~λλcλcλcreate-react-appmy-appCreatinganewReactappin~/my-app.Installingpackages.Thismighttakeacoupleofminutes.Installingreact,react-dom,andreact-scripts...yarnaddv1.2.1infoNolockfilefound.[1/4]🔍Resolvingpackages...[2/4]🚚Fetchingpackages...[3/4]🔗Linkingdependencies...[4/4]📃Buildingfreshpackages...Donein13.46s.Success!Createdmy-appat~/my-appInsidethatdirectory,youcanrunseveralcommands:yarnstartStartsthedevelopmentserver.yarnbuildBundlestheappintostaticfilesforproduction.yarntestStartsthetestrunner.yarnejectRemovesthistoolandcopiesbuilddependencies,configurationfilesandscriptsintotheappdirectory.Ifyoudothis,youcan’tgoback!Wesuggestthatyoubeginbytyping:cdmy-appHappyhacking!~14sλcdmy-app/λcdmy-app/~/my-appλyarnstartλyarnstartyarnrunv1.2.1Compiledsuccessfully!Youcannowviewmy-appinthebrowser.Local:http://localhost:3000/OnYourNetwork:http://192.168.178.58:3000/Notethatthedevelopmentbuildisnotoptimized.Tocreateaproductionbuild,useyarnbuild.λcrλcreate-react-appmy-appλcreate-react-appmy-appλcreate-react-appmy-appλcreate-react-appmy-appλcreate-react-appmy-appλcreate-react-appmy-appλcreate-react-appmy-appλcdλcdλcdmy-app/λcdmy-app/λcdmy-app/λyλyλyarnstartλyarnstartλyarnstartλyarnstartλyarnstartλyarnstartλyarnstartλyarnstartλyarnstart$react-scriptsstartStartingthedevelopmentserver...Compiling... \ No newline at end of file From 5a0b1ef56d2074d608c86ccd3f9091f0881dd0b4 Mon Sep 17 00:00:00 2001 From: Danny Calleri Date: Tue, 9 Jan 2018 16:25:59 +0100 Subject: [PATCH 0464/1739] Better documentation for setupTests.js when ejecting (#3656) * Better documentation for setupTests.js when ejecting When running `npm run eject` before creating `src/setupTests.js`, the resulting `package.json` file, won't contain any entry for it - and this is correct in my opinion, since otherwise Jest will crash - but it's useful to have it documented and avoid pointless waste of time. * Added additional note about src/setupTests.js Added another note about src/setupTests.js and `npm run eject` in Testing Components section * Update README.md * Update README.md --- packages/react-scripts/template/README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 377b2fbe099..5cb8d4e23b8 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1334,7 +1334,7 @@ import Adapter from 'enzyme-adapter-react-16'; configure({ adapter: new Adapter() }); ``` -(Note that **if you already ejected** before creating `src/setupTests.js`, this won’t work unless you set [this Jest option](https://facebook.github.io/jest/docs/en/configuration.html#setuptestframeworkscriptfile-string) to point to `src/setupTests.js`.) +>Note: Keep in mind that if you decide to "eject" before creating `src/setupTests.js`, the resulting `package.json` file won't contain any reference to it. [Read here](#initializing-test-environment) to learn how to add this after ejecting. Now you can write a smoke test with it: @@ -1425,7 +1425,14 @@ const localStorageMock = { global.localStorage = localStorageMock ``` -Note that **if you already ejected** before creating `src/setupTests.js`, this won’t work unless you set [this Jest option](https://facebook.github.io/jest/docs/en/configuration.html#setuptestframeworkscriptfile-string) to point to `src/setupTests.js`. +>Note: Keep in mind that if you decide to "eject" before creating `src/setupTests.js`, the resulting `package.json` file won't contain any reference to it, so you should manually create the property `setupTestFrameworkScriptFile` in the configuration for Jest, something like the following: + +>```js +>"jest": { +> // ... +> "setupTestFrameworkScriptFile": "/src/setupTests.js" +> } +> ``` ### Focusing and Excluding Tests From 85bf3a937be8d4fb1444daa069688cdb015d042b Mon Sep 17 00:00:00 2001 From: shrynx Date: Wed, 10 Jan 2018 00:46:46 +0900 Subject: [PATCH 0465/1739] added code-insiders to the editor list (#3652) --- packages/react-dev-utils/launchEditor.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index aee22b248ca..955f250d9c5 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -64,6 +64,7 @@ const COMMON_EDITORS_LINUX = { atom: 'atom', Brackets: 'brackets', code: 'code', + 'code-insiders': 'code-insiders', emacs: 'emacs', 'idea.sh': 'idea', 'phpstorm.sh': 'phpstorm', @@ -77,6 +78,7 @@ const COMMON_EDITORS_LINUX = { const COMMON_EDITORS_WIN = [ 'Brackets.exe', 'Code.exe', + 'Code - Insiders.exe', 'atom.exe', 'sublime_text.exe', 'notepad++.exe', @@ -127,6 +129,8 @@ function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { return ['--line', lineNumber, fileName]; case 'code': case 'Code': + case 'code-insiders': + case 'Code - Insiders': return addWorkspaceToArgumentsIfExists( ['-g', fileName + ':' + lineNumber], workspace From 10b05c7662ba3b9c5191b6dc1a9c36fd236d01e3 Mon Sep 17 00:00:00 2001 From: Tharaka Wijebandara Date: Tue, 9 Jan 2018 21:17:22 +0530 Subject: [PATCH 0466/1739] Open editor to exact column from build error overlay (#3465) * Open editor to exact column from build error overlay * Update launch editor validations --- .../react-dev-utils/errorOverlayMiddleware.js | 4 ++- packages/react-dev-utils/launchEditor.js | 35 +++++++++++++++---- .../react-dev-utils/webpackHotDevClient.js | 4 ++- .../src/utils/parseCompileError.js | 6 +++- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/packages/react-dev-utils/errorOverlayMiddleware.js b/packages/react-dev-utils/errorOverlayMiddleware.js index b756b0ef647..873b1994732 100644 --- a/packages/react-dev-utils/errorOverlayMiddleware.js +++ b/packages/react-dev-utils/errorOverlayMiddleware.js @@ -12,7 +12,9 @@ const launchEditorEndpoint = require('./launchEditorEndpoint'); module.exports = function createLaunchEditorMiddleware() { return function launchEditorMiddleware(req, res, next) { if (req.url.startsWith(launchEditorEndpoint)) { - launchEditor(req.query.fileName, req.query.lineNumber); + const lineNumber = parseInt(req.query.lineNumber, 10) || 1; + const colNumber = parseInt(req.query.colNumber, 10) || 1; + launchEditor(req.query.fileName, lineNumber, colNumber); res.end(); } else { next(); diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index 955f250d9c5..cf190b08619 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -103,7 +103,13 @@ function addWorkspaceToArgumentsIfExists(args, workspace) { return args; } -function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { +function getArgumentsForLineNumber( + editor, + fileName, + lineNumber, + colNumber, + workspace +) { const editorBasename = path.basename(editor).replace(/\.(exe|cmd|bat)$/i, ''); switch (editorBasename) { case 'atom': @@ -112,17 +118,19 @@ function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { case 'subl': case 'sublime': case 'sublime_text': + return [fileName + ':' + lineNumber + ':' + colNumber]; case 'wstorm': case 'charm': return [fileName + ':' + lineNumber]; case 'notepad++': - return ['-n' + lineNumber, fileName]; + return ['-n' + lineNumber, '-c' + colNumber, fileName]; case 'vim': case 'mvim': case 'joe': + return ['+' + lineNumber, fileName]; case 'emacs': case 'emacsclient': - return ['+' + lineNumber, fileName]; + return ['+' + lineNumber + ':' + colNumber, fileName]; case 'rmate': case 'mate': case 'mine': @@ -132,7 +140,7 @@ function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { case 'code-insiders': case 'Code - Insiders': return addWorkspaceToArgumentsIfExists( - ['-g', fileName + ':' + lineNumber], + ['-g', fileName + ':' + lineNumber + ':' + colNumber], workspace ); case 'appcode': @@ -255,17 +263,24 @@ function printInstructions(fileName, errorMessage) { } let _childProcess = null; -function launchEditor(fileName, lineNumber) { +function launchEditor(fileName, lineNumber, colNumber) { if (!fs.existsSync(fileName)) { return; } // Sanitize lineNumber to prevent malicious use on win32 // via: https://github.com/nodejs/node/blob/c3bb4b1aa5e907d489619fb43d233c3336bfc03d/lib/child_process.js#L333 - if (lineNumber && isNaN(lineNumber)) { + // and it should be a positive integer + if (!(Number.isInteger(lineNumber) && lineNumber > 0)) { return; } + // colNumber is optional, but should be a positive integer too + // default is 1 + if (!(Number.isInteger(colNumber) && colNumber > 0)) { + colNumber = 1; + } + let [editor, ...args] = guessEditor(); if (!editor) { @@ -294,7 +309,13 @@ function launchEditor(fileName, lineNumber) { let workspace = null; if (lineNumber) { args = args.concat( - getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) + getArgumentsForLineNumber( + editor, + fileName, + lineNumber, + colNumber, + workspace + ) ); } else { args.push(fileName); diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index 296e380467d..cbbc80029ae 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -30,7 +30,9 @@ ErrorOverlay.setEditorHandler(function editorHandler(errorLocation) { '?fileName=' + window.encodeURIComponent(errorLocation.fileName) + '&lineNumber=' + - window.encodeURIComponent(errorLocation.lineNumber || 1) + window.encodeURIComponent(errorLocation.lineNumber || 1) + + '&colNumber=' + + window.encodeURIComponent(errorLocation.colNumber || 1) ); }); diff --git a/packages/react-error-overlay/src/utils/parseCompileError.js b/packages/react-error-overlay/src/utils/parseCompileError.js index 2c9b6e60ebb..e87c45622c1 100644 --- a/packages/react-error-overlay/src/utils/parseCompileError.js +++ b/packages/react-error-overlay/src/utils/parseCompileError.js @@ -4,6 +4,7 @@ import Anser from 'anser'; export type ErrorLocation = {| fileName: string, lineNumber: number, + colNumber?: number, |}; const filePathRegex = /^\.(\/[^/\n ]+)+\.[^/\n ]+$/; @@ -25,6 +26,7 @@ function parseCompileError(message: string): ?ErrorLocation { const lines: Array = message.split('\n'); let fileName: string = ''; let lineNumber: number = 0; + let colNumber: number = 0; for (let i = 0; i < lines.length; i++) { const line: string = Anser.ansiToText(lines[i]).trim(); @@ -41,6 +43,8 @@ function parseCompileError(message: string): ?ErrorLocation { const match: ?Array = line.match(lineNumberRegexes[k]); if (match) { lineNumber = parseInt(match[1], 10); + // colNumber starts with 0 and hence add 1 + colNumber = parseInt(match[2], 10) + 1 || 1; break; } k++; @@ -51,7 +55,7 @@ function parseCompileError(message: string): ?ErrorLocation { } } - return fileName && lineNumber ? { fileName, lineNumber } : null; + return fileName && lineNumber ? { fileName, lineNumber, colNumber } : null; } export default parseCompileError; From 0d716713c47ec1b954f144b742c9584b9bc3f9b2 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 9 Jan 2018 07:49:17 -0800 Subject: [PATCH 0467/1739] Allowing "file:" --scripts-version values (#3629) * Allowing for local "file:" prefixed scripts packages * Fixing test failure --- packages/create-react-app/createReactApp.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index e7dbbb35842..f8330a48d5f 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -268,7 +268,7 @@ function run( template, useYarn ) { - const packageToInstall = getInstallPackage(version); + const packageToInstall = getInstallPackage(version, originalDirectory); const allDependencies = ['react', 'react-dom', packageToInstall]; console.log('Installing packages. This might take a couple of minutes.'); @@ -365,11 +365,16 @@ function run( }); } -function getInstallPackage(version) { +function getInstallPackage(version, originalDirectory) { let packageToInstall = 'react-scripts'; const validSemver = semver.valid(version); if (validSemver) { packageToInstall += `@${validSemver}`; + } else if (version && version.match(/^file:/)) { + packageToInstall = `file:${path.resolve( + originalDirectory, + version.match(/^file:(.*)?$/)[1] + )}`; } else if (version) { // for tar.gz or alternative paths packageToInstall = version; @@ -459,6 +464,10 @@ function getPackageName(installPackage) { return Promise.resolve( installPackage.charAt(0) + installPackage.substr(1).split('@')[0] ); + } else if (installPackage.match(/^file:/)) { + const installPackagePath = installPackage.match(/^file:(.*)?$/)[1]; + const installPackageJson = require(path.join(installPackagePath, 'package.json')); + return Promise.resolve(installPackageJson.name); } return Promise.resolve(installPackage); } From 5d154cbcee3eaa8e1b0b5b1ed4d31fff57b8245d Mon Sep 17 00:00:00 2001 From: Andy Kenward Date: Tue, 9 Jan 2018 15:49:48 +0000 Subject: [PATCH 0468/1739] Travis CI use trusty instead precise (#3661) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It appears trusty has Yarn ^v1.0.0 now. So (#3054) shouldn’t be an issue changing to trusty. As Travis CI [precise support](https://blog.travis-ci.com/2017-08-31-trusty-as-default-status) will be dropped in March 2018 . --- .travis.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0ca362c23c3..e2afbfa97f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,5 @@ --- -# Use Ubuntu Precise instead of new default Trusty which cause build fail -# with pre installed yarn v0.17.8 -# https://github.com/facebookincubator/create-react-app/issues/3054 -# TODO: remove after Trusty environment is updated with a lastet version of yarn -dist: precise +dist: trusty language: node_js node_js: - 6 From 373687feaf9a5961fe87951e4ed28beed414322b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tao=20G=C3=B3mez=20Gil?= Date: Tue, 9 Jan 2018 16:50:20 +0100 Subject: [PATCH 0469/1739] Add Powershell commands to README.md (#3515) --- packages/react-scripts/template/README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 5cb8d4e23b8..772db475495 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -932,6 +932,12 @@ set "REACT_APP_SECRET_CODE=abcdef" && npm start (Note: Quotes around the variable assignment are required to avoid a trailing whitespace.) +#### Windows (Powershell) + +```Powershell +($env:REACT_APP_SECRET_CODE = "abcdef") -and (npm start) +``` + #### Linux, macOS (Bash) ```bash @@ -1179,6 +1185,12 @@ To do this, set the `HTTPS` environment variable to `true`, then start the dev s set HTTPS=true&&npm start ``` +#### Windows (Powershell) + +```Powershell +($env:HTTPS = $true) -and (npm start) +``` + (Note: the lack of whitespace is intentional.) #### Linux, macOS (Bash) @@ -1527,6 +1539,16 @@ set CI=true&&npm run build (Note: the lack of whitespace is intentional.) +##### Windows (Powershell) + +```Powershell +($env:CI = $true) -and (npm test) +``` + +```Powershell +($env:CI = $true) -and (npm run build) +``` + ##### Linux, macOS (Bash) ```bash From ab507e62f8dd57ca1e810b3c8cc1bc321081fffe Mon Sep 17 00:00:00 2001 From: David Boyne Date: Tue, 9 Jan 2018 15:59:26 +0000 Subject: [PATCH 0470/1739] Updated babel-preset-react-app README.md (#3463) Added some more documentation to install the babel-preset-react-app making it more clear on how to get started with this preset outside of create-react-app. --- packages/babel-preset-react-app/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/babel-preset-react-app/README.md b/packages/babel-preset-react-app/README.md index 4dc9fb9b168..5653831ac7e 100644 --- a/packages/babel-preset-react-app/README.md +++ b/packages/babel-preset-react-app/README.md @@ -16,6 +16,12 @@ If you want to use this Babel preset in a project not built with Create React Ap First, [install Babel](https://babeljs.io/docs/setup/). +Then install babel-preset-react-app. + +```sh +npm install babel-preset-react-app --save-dev +``` + Then create a file named `.babelrc` with following contents in the root folder of your project: ```js From b507a9aec1455d7ead63e6842db0354ba98469c2 Mon Sep 17 00:00:00 2001 From: Trevor Brindle Date: Tue, 9 Jan 2018 11:02:15 -0500 Subject: [PATCH 0471/1739] =?UTF-8?q?add=20envinfo=20package,=20=E2=80=94i?= =?UTF-8?q?nfo=20flag=20(#3408)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add envinfo package, —info flag * update envinfo to use new duplicates option --- packages/create-react-app/createReactApp.js | 10 ++++++++++ packages/create-react-app/package.json | 1 + 2 files changed, 11 insertions(+) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index f8330a48d5f..062c9f2f6fc 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -47,6 +47,7 @@ const tmp = require('tmp'); const unpack = require('tar-pack').unpack; const url = require('url'); const hyperquest = require('hyperquest'); +const envinfo = require('envinfo'); const packageJson = require('./package.json'); @@ -60,6 +61,7 @@ const program = new commander.Command(packageJson.name) projectName = name; }) .option('--verbose', 'print additional logs') + .option('--info', 'print environment debug info') .option( '--scripts-version ', 'use a non-standard version of react-scripts' @@ -100,6 +102,14 @@ const program = new commander.Command(packageJson.name) .parse(process.argv); if (typeof projectName === 'undefined') { + if (program.info) { + envinfo.print({ + packages: ['react', 'react-dom', 'react-scripts'], + noNativeIDE: true, + duplicates: true, + }); + process.exit(0); + } console.error('Please specify the project directory:'); console.log( ` ${chalk.cyan(program.name())} ${chalk.green('')}` diff --git a/packages/create-react-app/package.json b/packages/create-react-app/package.json index 569985f5c07..1b3b60aac80 100644 --- a/packages/create-react-app/package.json +++ b/packages/create-react-app/package.json @@ -24,6 +24,7 @@ "chalk": "^1.1.1", "commander": "^2.9.0", "cross-spawn": "^4.0.0", + "envinfo": "^3.8.0", "fs-extra": "^1.0.0", "hyperquest": "^2.1.2", "semver": "^5.0.3", From dccc752cac5b7067e46df820316d8f32e2cf1010 Mon Sep 17 00:00:00 2001 From: Moos Date: Tue, 9 Jan 2018 08:05:36 -0800 Subject: [PATCH 0472/1739] =?UTF-8?q?fix=20#2223=20-=20[feature]=20Impleme?= =?UTF-8?q?nt=20dotenv-expand=20to=20accept=20variable=20expa=E2=80=A6=20(?= =?UTF-8?q?#3387)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix #2223 - [feature] Implement dotenv-expand to accept variable expansion in dot env files * add to README TOC * fix readme * Update README.md --- packages/react-scripts/config/env.js | 11 ++++++---- .../react-scripts/fixtures/kitchensink/.env | 4 ++++ .../kitchensink/integration/env.test.js | 17 +++++++++++++++ .../fixtures/kitchensink/src/App.js | 5 +++++ .../src/features/env/ExpandEnvVariables.js | 21 +++++++++++++++++++ .../features/env/ExpandEnvVariables.test.js | 17 +++++++++++++++ packages/react-scripts/package.json | 1 + packages/react-scripts/template/README.md | 19 +++++++++++++++++ 8 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 packages/react-scripts/fixtures/kitchensink/src/features/env/ExpandEnvVariables.js create mode 100644 packages/react-scripts/fixtures/kitchensink/src/features/env/ExpandEnvVariables.test.js diff --git a/packages/react-scripts/config/env.js b/packages/react-scripts/config/env.js index fa42747f6a8..ceda79604e7 100644 --- a/packages/react-scripts/config/env.js +++ b/packages/react-scripts/config/env.js @@ -35,13 +35,16 @@ var dotenvFiles = [ // Load environment variables from .env* files. Suppress warnings using silent // if this file is missing. dotenv will never modify any environment variables -// that have already been set. +// that have already been set. Variable expansion is supported in .env files. // https://github.com/motdotla/dotenv +// https://github.com/motdotla/dotenv-expand dotenvFiles.forEach(dotenvFile => { if (fs.existsSync(dotenvFile)) { - require('dotenv').config({ - path: dotenvFile, - }); + require('dotenv-expand')( + require('dotenv').config({ + path: dotenvFile, + }) + ); } }); diff --git a/packages/react-scripts/fixtures/kitchensink/.env b/packages/react-scripts/fixtures/kitchensink/.env index 3e2f7b14a73..9f7acc60233 100644 --- a/packages/react-scripts/fixtures/kitchensink/.env +++ b/packages/react-scripts/fixtures/kitchensink/.env @@ -1,3 +1,7 @@ REACT_APP_X = x-from-original-env REACT_APP_ORIGINAL_1 = from-original-env-1 REACT_APP_ORIGINAL_2 = from-original-env-2 +REACT_APP_BASIC = basic +REACT_APP_BASIC_EXPAND = ${REACT_APP_BASIC} +REACT_APP_BASIC_EXPAND_SIMPLE = $REACT_APP_BASIC +REACT_APP_EXPAND_EXISTING = $REACT_APP_SHELL_ENV_MESSAGE diff --git a/packages/react-scripts/fixtures/kitchensink/integration/env.test.js b/packages/react-scripts/fixtures/kitchensink/integration/env.test.js index 5138bc513b3..43badcbde8e 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/env.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/env.test.js @@ -67,5 +67,22 @@ describe('Integration', () => { doc.getElementById('feature-shell-env-variables').textContent ).to.equal('fromtheshell.'); }); + + it('expand .env variables', async () => { + const doc = await initDOM('expand-env-variables'); + + expect(doc.getElementById('feature-expand-env-1').textContent).to.equal( + 'basic' + ); + expect(doc.getElementById('feature-expand-env-2').textContent).to.equal( + 'basic' + ); + expect(doc.getElementById('feature-expand-env-3').textContent).to.equal( + 'basic' + ); + expect( + doc.getElementById('feature-expand-env-existing').textContent + ).to.equal('fromtheshell'); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/App.js b/packages/react-scripts/fixtures/kitchensink/src/App.js index 5fe13accf25..0a1663192ee 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/App.js +++ b/packages/react-scripts/fixtures/kitchensink/src/App.js @@ -179,6 +179,11 @@ class App extends Component { this.setFeature(f.default) ); break; + case 'expand-env-variables': + import('./features/env/ExpandEnvVariables').then(f => + this.setFeature(f.default) + ); + break; default: throw new Error(`Missing feature "${feature}"`); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/ExpandEnvVariables.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/ExpandEnvVariables.js new file mode 100644 index 00000000000..58fc00e3a5c --- /dev/null +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/ExpandEnvVariables.js @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import React from 'react'; + +export default () => ( + + {process.env.REACT_APP_BASIC} + {process.env.REACT_APP_BASIC_EXPAND} + + {process.env.REACT_APP_BASIC_EXPAND_SIMPLE} + + + {process.env.REACT_APP_EXPAND_EXISTING} + + +); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/ExpandEnvVariables.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/ExpandEnvVariables.test.js new file mode 100644 index 00000000000..4e4200abee8 --- /dev/null +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/ExpandEnvVariables.test.js @@ -0,0 +1,17 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import React from 'react'; +import ReactDOM from 'react-dom'; +import ExpandEnvVariables from './ExpandEnvVariables'; + +describe('expand .env variables', () => { + it('renders without crashing', () => { + const div = document.createElement('div'); + ReactDOM.render(, div); + }); +}); diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index dcac53cf49f..f6bff1deaa6 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -32,6 +32,7 @@ "chalk": "1.1.3", "css-loader": "0.28.7", "dotenv": "4.0.0", + "dotenv-expand": "4.0.1", "eslint": "4.10.0", "eslint-config-react-app": "^2.0.1", "eslint-loader": "1.9.0", diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 772db475495..17b85756b4f 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -978,6 +978,25 @@ Please refer to the [dotenv documentation](https://github.com/motdotla/dotenv) f >Note: If you are defining environment variables for development, your CI and/or hosting platform will most likely need these defined as well. Consult their documentation how to do this. For example, see the documentation for [Travis CI](https://docs.travis-ci.com/user/environment-variables/) or [Heroku](https://devcenter.heroku.com/articles/config-vars). +#### Expanding Environment Variables In `.env` + +>Note: this feature is available with `react-scripts@1.0.18` and higher. + +Expand variables already on your machine for use in your .env file (using [dotenv-expand](https://github.com/motdotla/dotenv-expand)). See [#2223](https://github.com/facebookincubator/create-react-app/issues/2223). + +For example, to get the environment variable `npm_package_version`: +``` +REACT_APP_VERSION=$npm_package_version +# also works: +# REACT_APP_VERSION=${npm_package_version} +``` +Or expand variables local to the current `.env` file: +``` +DOMAIN=www.example.com +REACT_APP_FOO=$DOMAIN/foo +REACT_APP_BAR=$DOMAIN/bar +``` + ## Can I Use Decorators? Many popular libraries use [decorators](https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841) in their documentation.
From 887fd10ed842d9a4a6e61b6483e0b5b21bcb4725 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Wed, 10 Jan 2018 02:07:21 +1000 Subject: [PATCH 0473/1739] Print full directory name from lsof (#3440) awk splits lines based on spaces, which causes directory names with spaces to end up in other fields. Using a for loop allows us to print from the 9th field onwards instead of just the 9th field. --- packages/react-dev-utils/getProcessForPort.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dev-utils/getProcessForPort.js b/packages/react-dev-utils/getProcessForPort.js index 932f3e5bf4d..f9eda7752b4 100644 --- a/packages/react-dev-utils/getProcessForPort.js +++ b/packages/react-dev-utils/getProcessForPort.js @@ -58,7 +58,7 @@ function getProcessCommand(processId, processDirectory) { function getDirectoryOfProcessById(processId) { return execSync( - 'lsof -p ' + processId + ' | awk \'$4=="cwd" {print $9}\'', + 'lsof -p ' + processId + ' | awk \'$4=="cwd" {for (i=9; i<=NF; i++) printf "%s ", $i}\'', execOptions ).trim(); } From 3a0b836be376575b5227a0237e8b2334a9f9ab24 Mon Sep 17 00:00:00 2001 From: Maksym Dogadailo Date: Tue, 9 Jan 2018 18:30:25 +0100 Subject: [PATCH 0474/1739] added getProxy (#3320) * added getProxy getProxy checks proxy settings from process.env.https_proxy or Yarn (NPM) config (.npmrc) * changed yarn for npm to get https-proxy default value for https-proxy is null, not undefined like in yarn --- packages/create-react-app/createReactApp.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 062c9f2f6fc..420dde1b194 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -639,6 +639,21 @@ function isSafeToCreateProjectIn(root, name) { return false; } +function getProxy() { + if (process.env.https_proxy) { + return process.env.https_proxy; + } else { + try { + // Trying to read https-proxy from .npmrc + let httpsProxy = execSync('npm config get https-proxy') + .toString() + .trim(); + return httpsProxy !== 'null' ? httpsProxy : undefined; + } catch (e) { + return; + } + } +} function checkThatNpmCanReadCwd() { const cwd = process.cwd(); let childOutput = null; @@ -709,10 +724,11 @@ function checkIfOnline(useYarn) { return new Promise(resolve => { dns.lookup('registry.yarnpkg.com', err => { - if (err != null && process.env.https_proxy) { + let proxy; + if (err != null && (proxy = getProxy())) { // 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 => { + dns.lookup(url.parse(proxy).hostname, proxyErr => { resolve(proxyErr == null); }); } else { From 11f09a16aaad3498f94d67667cb78445cac57205 Mon Sep 17 00:00:00 2001 From: Sascha Dens Date: Tue, 9 Jan 2018 18:34:46 +0100 Subject: [PATCH 0475/1739] Extend --scripts-version to include .tar.gz format (#3725) * Extend --scripts-version to include .tar.gz format * Removal of debug console.log --- packages/create-react-app/createReactApp.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 420dde1b194..f91608f34dc 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -85,6 +85,11 @@ const program = new commander.Command(packageJson.name) 'https://mysite.com/my-react-scripts-0.8.2.tgz' )}` ); + console.log( + ` - a .tar.gz archive: ${chalk.green( + 'https://mysite.com/my-react-scripts-0.8.2.tar.gz' + )}` + ); console.log( ` It is not needed unless you specifically want to use a fork.` ); @@ -432,7 +437,7 @@ function extractStream(stream, dest) { // Extract package name from tarball url or path. function getPackageName(installPackage) { - if (installPackage.indexOf('.tgz') > -1) { + if (installPackage.match(/^.+\.(tgz|tar\.gz)$/)) { return getTemporaryDirectory() .then(obj => { let stream; @@ -455,7 +460,7 @@ function getPackageName(installPackage) { `Could not extract the package name from the archive: ${err.message}` ); const assumedProjectName = installPackage.match( - /^.+\/(.+?)(?:-\d+.+)?\.tgz$/ + /^.+\/(.+?)(?:-\d+.+)?\.(tgz|tar\.gz)$/ )[1]; console.log( `Based on the filename, assuming it is "${chalk.cyan( From b20b96a97131345e3cc1dee82a0e1fb6703259c3 Mon Sep 17 00:00:00 2001 From: Ian Schmitz Date: Tue, 9 Jan 2018 09:38:33 -0800 Subject: [PATCH 0476/1739] Port cra.sh development task to javascript (#2309) * Port cra.sh development task to javascript * Port cra.sh development task to javascript Use absolute path when generating .tgz path --- package.json | 2 +- tasks/cra.js | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++ tasks/cra.sh | 84 --------------------------------------- 3 files changed, 110 insertions(+), 85 deletions(-) create mode 100644 tasks/cra.js delete mode 100755 tasks/cra.sh diff --git a/package.json b/package.json index e912ba893b3..9cf2f50f14f 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "scripts": { "build": "node packages/react-scripts/scripts/build.js", "changelog": "lerna-changelog", - "create-react-app": "tasks/cra.sh", + "create-react-app": "node tasks/cra.js", "e2e": "tasks/e2e-simple.sh", "e2e:docker": "tasks/local-test.sh", "postinstall": "node bootstrap.js && cd packages/react-error-overlay/ && npm run build:prod", diff --git a/tasks/cra.js b/tasks/cra.js new file mode 100644 index 00000000000..ec15d702ac5 --- /dev/null +++ b/tasks/cra.js @@ -0,0 +1,109 @@ +#!/usr/bin/env node +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const cp = require('child_process'); + +const cleanup = () => { + console.log('Cleaning up.'); + // Uncomment when snapshot testing is enabled by default: + // rm ./template/src/__snapshots__/App.test.js.snap +}; + +const handleExit = () => { + cleanup(); + console.log('Exiting without error.'); + process.exit(); +}; + +const handleError = e => { + console.error('ERROR! An error was encountered while executing\n', e); + cleanup(); + console.log('Exiting with error.'); + process.exit(1); +}; + +process.on('SIGINT', handleExit); +process.on('uncaughtException', handleError); + +// ****************************************************************************** +// Pack react- scripts so we can verify they work. +// ****************************************************************************** + +const rootDir = path.join(__dirname, '..'); +const reactScriptsDir = path.join(rootDir, 'packages', 'react-scripts'); +const packageJsonPath = path.join(reactScriptsDir, 'package.json'); +const packageJsonOrigPath = path.join(reactScriptsDir, 'package.json.orig'); + +// Install all our packages +const lernaPath = path.join(rootDir, 'node_modules', '.bin', 'lerna'); +cp.execSync(`${lernaPath} bootstrap`, { + cwd: rootDir, + stdio: 'inherit', +}); + +// Save package.json because we're going to touch it +fs.writeFileSync(packageJsonOrigPath, fs.readFileSync(packageJsonPath)); + +// Replace own dependencies (those in the`packages` dir) with the local paths +// of those packages +const replaceOwnDepsPath = path.join(__dirname, 'replace-own-deps.js'); +cp.execSync(`node ${replaceOwnDepsPath}`, { stdio: 'inherit' }); + +// Finally, pack react-scripts +// Don't redirect stdio as we want to capture the output that will be returned +// from execSync(). In this case it will be the .tgz filename. +const scriptsFileName = cp + .execSync(`npm pack`, { cwd: reactScriptsDir }) + .toString() + .trim(); +const scriptsPath = path.join( + rootDir, + 'packages', + 'react-scripts', + scriptsFileName +); + +// Restore package.json +fs.unlinkSync(packageJsonPath); +fs.writeFileSync(packageJsonPath, fs.readFileSync(packageJsonOrigPath)); +fs.unlinkSync(packageJsonOrigPath); + +// ****************************************************************************** +// Now that we have packed them, call the global CLI. +// ****************************************************************************** + +// If Yarn is installed, clean its cache because it may have cached react-scripts +try { + cp.execSync('yarn cache clean'); +} catch (e) { + // We can safely ignore this as the user doesn't have yarn installed +} + +const args = process.argv.slice(2); + +// Now run the CRA command +const craScriptPath = path.join( + rootDir, + 'packages', + 'create-react-app', + 'index.js' +); +cp.execSync( + `node ${craScriptPath} --scripts-version="${scriptsPath}" ${args.join(' ')}`, + { + cwd: rootDir, + stdio: 'inherit', + } +); + +// Cleanup +handleExit(); diff --git a/tasks/cra.sh b/tasks/cra.sh deleted file mode 100755 index 7929cdbf5af..00000000000 --- a/tasks/cra.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# Copyright (c) 2015-present, Facebook, Inc. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -# ****************************************************************************** -# This creates an app with the global CLI and `react-scripts` from the source. -# It is useful for testing the end-to-end flow locally. -# ****************************************************************************** - -# Start in tasks/ even if run from root directory -cd "$(dirname "$0")" - -function cleanup { - echo 'Cleaning up.' - # Uncomment when snapshot testing is enabled by default: - # rm ./template/src/__snapshots__/App.test.js.snap -} - -# Error messages are redirected to stderr -function handle_error { - echo "$(basename $0): ERROR! An error was encountered executing line $1." 1>&2; - cleanup - echo 'Exiting with error.' 1>&2; - exit 1 -} - -function handle_exit { - cleanup - echo 'Exiting without error.' 1>&2; - exit -} - -# Exit the script with a helpful error message when any error is encountered -trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR - -# Cleanup before exit on any termination signal -trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP - -# Echo every command being executed -set -x - -# Go to root -cd .. -root_path=$PWD - -# ****************************************************************************** -# Pack react-scripts so we can verify they work. -# ****************************************************************************** - -# Install all our packages -"$root_path"/node_modules/.bin/lerna bootstrap - -cd packages/react-scripts - -# Save package.json because we're going to touch it -cp package.json package.json.orig - -# Replace own dependencies (those in the `packages` dir) with the local paths -# of those packages. -node "$root_path"/tasks/replace-own-deps.js - -# Finally, pack react-scripts -scripts_path="$root_path"/packages/react-scripts/`npm pack` - -# Restore package.json -rm package.json -mv package.json.orig package.json - - -# ****************************************************************************** -# Now that we have packed them, call the global CLI. -# ****************************************************************************** - -# If Yarn is installed, clean its cache because it may have cached react-scripts -yarn cache clean || true - -# Go back to the root directory and run the command from here -cd "$root_path" -node packages/create-react-app/index.js --scripts-version="$scripts_path" "$@" - -# Cleanup -cleanup From c162920e7fdcfda73e3d6129c89287cd247120b2 Mon Sep 17 00:00:00 2001 From: Dubes Date: Tue, 9 Jan 2018 23:08:54 +0530 Subject: [PATCH 0477/1739] Documentation to help windows contributors (#2841) * Added documentation for contributors using windows 10 Hopefully encourages devs on Windows machine to contribute * corrected the wordings a little --- CONTRIBUTING.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 86b392f2f44..8957c0c3de6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -96,6 +96,21 @@ and then run `npm start` or `npm run build`. More detailed information are in the dedicated [README](/packages/react-scripts/fixtures/kitchensink/README.md). +## Tips for contributors using Windows + +The scripts in tasks folder and other scripts in `package.json` will not work in Windows out of the box. However, using [Bash on windows](https://msdn.microsoft.com/en-us/commandline/wsl/about) makes it easier to use those scripts without any workarounds. The steps to do so are detailed below: + +### Install Bash on Ubuntu on Windows + +A good step by step guide can be found [here](https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/) + +### Install Node.js and npm +Even if you have node and npm installed on your windows, it would not be accessible from the bash shell. You would have to install it again. Installing via [`nvm`](https://github.com/creationix/nvm#install-script) is recommended. + +### Line endings + +By default git would use `CRLF` line endings which would cause the scripts to fail. You can change it for this repo only by setting `autocrlf` to false by running `git config core.autocrlf false`. You can also enable it for all your repos by using the `--global` flag if you wish to do so. + ## Cutting a Release 1. Tag all merged pull requests that go into the release with the relevant milestone. Each merged PR should also be labeled with one of the [labels](https://github.com/facebookincubator/create-react-app/labels) named `tag: ...` to indicate what kind of change it is. From 72b6eb8c3c65e6ed0f2413708069287311a386c2 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 9 Jan 2018 09:41:10 -0800 Subject: [PATCH 0478/1739] Cleaning up printHostingInstructions a bit (#3036) * Replacing literal 'build' with `buildFolder` variable * Cleaning up the printHostingInstructions a bit * Fixing undefined variable --- .../printHostingInstructions.js | 159 ++++++++---------- 1 file changed, 73 insertions(+), 86 deletions(-) diff --git a/packages/react-dev-utils/printHostingInstructions.js b/packages/react-dev-utils/printHostingInstructions.js index 4a080dba2c9..2371d6d60ed 100644 --- a/packages/react-dev-utils/printHostingInstructions.js +++ b/packages/react-dev-utils/printHostingInstructions.js @@ -19,60 +19,32 @@ function printHostingInstructions( buildFolder, useYarn ) { - const publicPathname = url.parse(publicPath).pathname; - if (publicUrl && publicUrl.indexOf('.github.io/') !== -1) { + if (publicUrl && publicUrl.includes('.github.io/')) { // "homepage": "http://user.github.io/project" - console.log( - `The project was built assuming it is hosted at ${chalk.green( - publicPathname - )}.` - ); - console.log( - `You can control this with the ${chalk.green( - 'homepage' - )} field in your ${chalk.cyan('package.json')}.` - ); - console.log(); - console.log(`The ${chalk.cyan('build')} folder is ready to be deployed.`); - console.log(`To publish it at ${chalk.green(publicUrl)}, run:`); - // If script deploy has been added to package.json, skip the instructions - if (typeof appPackage.scripts.deploy === 'undefined') { - console.log(); - if (useYarn) { - console.log(` ${chalk.cyan('yarn')} add --dev gh-pages`); - } else { - console.log(` ${chalk.cyan('npm')} install --save-dev gh-pages`); - } - console.log(); - console.log( - `Add the following script in your ${chalk.cyan('package.json')}.` - ); - console.log(); - console.log(` ${chalk.dim('// ...')}`); - console.log(` ${chalk.yellow('"scripts"')}: {`); - console.log(` ${chalk.dim('// ...')}`); - console.log( - ` ${chalk.yellow('"predeploy"')}: ${chalk.yellow( - '"npm run build",' - )}` - ); - console.log( - ` ${chalk.yellow('"deploy"')}: ${chalk.yellow( - '"gh-pages -d build"' - )}` - ); - console.log(' }'); - console.log(); - console.log('Then run:'); - } - console.log(); - console.log(` ${chalk.cyan(useYarn ? 'yarn' : 'npm')} run deploy`); - console.log(); + const publicPathname = url.parse(publicPath).pathname; + const hasDeployScript = typeof appPackage.scripts.deploy !== 'undefined'; + printBaseMessage(buildFolder, publicPathname); + + printDeployInstructions(publicUrl, hasDeployScript, useYarn); + } else if (publicPath !== '/') { // "homepage": "http://mywebsite.com/project" + printBaseMessage(buildFolder, publicPath); + + } else { + // "homepage": "http://mywebsite.com" + // or no homepage + printBaseMessage(buildFolder, publicUrl); + + printStaticServerInstructions(buildFolder, useYarn); + } + console.log(); +} + +function printBaseMessage(buildFolder, hostingLocation) { console.log( `The project was built assuming it is hosted at ${chalk.green( - publicPath + hostingLocation || 'the server root' )}.` ); console.log( @@ -80,57 +52,72 @@ function printHostingInstructions( 'homepage' )} field in your ${chalk.cyan('package.json')}.` ); - console.log(); - console.log(`The ${chalk.cyan('build')} folder is ready to be deployed.`); - console.log(); - } else { - if (publicUrl) { - // "homepage": "http://mywebsite.com" - console.log( - `The project was built assuming it is hosted at ${chalk.green( - publicUrl - )}.` - ); - console.log( - `You can control this with the ${chalk.green( - 'homepage' - )} field in your ${chalk.cyan('package.json')}.` - ); - console.log(); - } else { - // no homepage - console.log( - 'The project was built assuming it is hosted at the server root.' - ); - console.log( - `To override this, specify the ${chalk.green( - 'homepage' - )} in your ${chalk.cyan('package.json')}.` - ); + + if (!hostingLocation) { console.log('For example, add this to build it for GitHub Pages:'); console.log(); + console.log( ` ${chalk.green('"homepage"')} ${chalk.cyan(':')} ${chalk.green( '"http://myname.github.io/myapp"' )}${chalk.cyan(',')}` ); - console.log(); } + console.log(); + console.log( `The ${chalk.cyan(buildFolder)} folder is ready to be deployed.` ); - console.log('You may serve it with a static server:'); - console.log(); - if (!fs.existsSync(`${globalModules}/serve`)) { - if (useYarn) { - console.log(` ${chalk.cyan('yarn')} global add serve`); - } else { - console.log(` ${chalk.cyan('npm')} install -g serve`); - } +} + +function printDeployInstructions(publicUrl, hasDeployScript, useYarn) { + console.log(`To publish it at ${chalk.green(publicUrl)}, run:`); + console.log(); + + // If script deploy has been added to package.json, skip the instructions + if (!hasDeployScript) { + if (useYarn) { + console.log(` ${chalk.cyan('yarn')} add --dev gh-pages`); + } else { + console.log(` ${chalk.cyan('npm')} install --save-dev gh-pages`); } - console.log(` ${chalk.cyan('serve')} -s ${buildFolder}`); console.log(); + + console.log(`Add the following script in your ${chalk.cyan( + 'package.json' + )}.`); + console.log(); + + console.log(` ${chalk.dim('// ...')}`); + console.log(` ${chalk.yellow('"scripts"')}: {`); + console.log(` ${chalk.dim('// ...')}`); + console.log(` ${chalk.yellow('"predeploy"')}: ${chalk.yellow( + '"npm run build",' + )}`); + console.log(` ${chalk.yellow('"deploy"')}: ${chalk.yellow( + '"gh-pages -d build"' + )}`); + console.log(' }'); + console.log(); + + console.log('Then run:'); + console.log(); + } + console.log(` ${chalk.cyan(useYarn ? 'yarn' : 'npm')} run deploy`); +} + +function printStaticServerInstructions(buildFolder, useYarn) { + console.log('You may serve it with a static server:'); + console.log(); + + 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}`); } module.exports = printHostingInstructions; From 91d968f916ee2b9c07444eb32619f76a62ffb852 Mon Sep 17 00:00:00 2001 From: Eli Perelman Date: Tue, 9 Jan 2018 17:48:44 -0600 Subject: [PATCH 0479/1739] Update README.md to note Neutrino's support of react components (#3729) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a093833823a..d6945417abf 100644 --- a/README.md +++ b/README.md @@ -190,7 +190,7 @@ Here’s a few common cases where you might want to try something else: * If you need to **integrate React code with a server-side template framework** like Rails or Django, or if you’re **not building a single-page app**, consider using [nwb](https://github.com/insin/nwb) or [Neutrino](https://neutrino.js.org/) which are more flexible. -* If you need to **publish a React component**, [nwb](https://github.com/insin/nwb) can [also do this](https://github.com/insin/nwb#react-components-and-libraries). +* If you need to **publish a React component**, [nwb](https://github.com/insin/nwb) can [also do this](https://github.com/insin/nwb#react-components-and-libraries), as well as [Neutrino's react-components preset](https://neutrino.js.org/packages/react-components/). * If you want to do **server rendering** with React and Node.js, check out [Next.js](https://github.com/zeit/next.js/) or [Razzle](https://github.com/jaredpalmer/razzle). Create React App is agnostic of the backend, and just produces static HTML/JS/CSS bundles. From 0ec41350db21a2e87d6d8288ecacca45227f368a Mon Sep 17 00:00:00 2001 From: Siddharth Doshi Date: Wed, 10 Jan 2018 17:30:03 +0530 Subject: [PATCH 0480/1739] Use proxy for all request methods other than GET (#3726) * Use proxy for all request methods other than GET * Add comment --- packages/react-dev-utils/WebpackDevServerUtils.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index f19582e1227..4add9f9c1bc 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -317,15 +317,19 @@ function prepareProxy(proxy, appPublicFolder) { // For single page apps, we generally want to fallback to /index.html. // However we also want to respect `proxy` for API calls. // So if `proxy` is specified as a string, we need to decide which fallback to use. - // We use a heuristic: if request `accept`s text/html, we pick /index.html. + // We use a heuristic: We want to proxy all the requests that are not meant + // for static assets and as all the requests for static assets will be using + // `GET` method, we can proxy all non-`GET` requests. + // For `GET` requests, if request `accept`s text/html, we pick /index.html. // Modern browsers include text/html into `accept` header when navigating. // However API calls like `fetch()` won’t generally accept text/html. // If this heuristic doesn’t work well for you, use a custom `proxy` object. context: function(pathname, req) { return ( - mayProxy(pathname) && - req.headers.accept && - req.headers.accept.indexOf('text/html') === -1 + req.method !== 'GET' || + (mayProxy(pathname) && + req.headers.accept && + req.headers.accept.indexOf('text/html') === -1) ); }, onProxyReq: proxyReq => { From d49744f04cffa969f1b69e90503eab0d12b8a0e7 Mon Sep 17 00:00:00 2001 From: Vladimir Tolstikov Date: Wed, 10 Jan 2018 17:02:45 +0400 Subject: [PATCH 0481/1739] docs: add info about HTTP caching headers into Firebase section (#3659) --- packages/react-scripts/template/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 17b85756b4f..e5c0cf6bf77 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -2086,6 +2086,18 @@ Then run the `firebase init` command from your project’s root. You need to cho ✔ Firebase initialization complete! ``` +IMPORTANT: you need to set proper HTTP caching headers for `service-worker.js` file in `firebase.json` file or you will not be able to see changes after first deployment ([issue #2440](https://github.com/facebookincubator/create-react-app/issues/2440)). It should be added inside `"hosting"` key like next: + +``` +{ + "hosting": { + ... + "headers": [ + {"source": "/service-worker.js", "headers": [{"key": "Cache-Control", "value": "no-cache"}]} + ] + ... +``` + Now, after you create a production build with `npm run build`, you can deploy it by running `firebase deploy`. ```sh From 70b3a4db89f0f912824a8ba707305e4944da417a Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Wed, 10 Jan 2018 16:24:27 +0000 Subject: [PATCH 0482/1739] Lint against files with old license (#3361) * Lint against files with old license * Update e2e-simple.sh * Update e2e-simple.sh * oh no --- tasks/e2e-simple.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 9e51b00805d..34203407716 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -88,6 +88,19 @@ set -x cd .. root_path=$PWD +# Make sure we don't introduce accidental references to PATENTS. +EXPECTED='packages/react-error-overlay/fixtures/bundle.mjs +packages/react-error-overlay/fixtures/bundle.mjs.map +packages/react-error-overlay/fixtures/bundle_u.mjs +packages/react-error-overlay/fixtures/bundle_u.mjs.map +tasks/e2e-simple.sh' +ACTUAL=$(git grep -l PATENTS) +if [ "$EXPECTED" != "$ACTUAL" ]; then + echo "PATENTS crept into some new files?" + diff -u <(echo "$EXPECTED") <(echo "$ACTUAL") || true + exit 1 +fi + # Clear cache to avoid issues with incorrect packages being used if hash yarnpkg 2>/dev/null then From 7fd37d35ed61ad7764b9f3e32527617aefeea61b Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil Date: Wed, 10 Jan 2018 23:51:12 +0700 Subject: [PATCH 0483/1739] add link to deployment docs after build (#3104) * add link to deployment docs after build * Update printHostingInstructions.js --- packages/react-dev-utils/printHostingInstructions.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react-dev-utils/printHostingInstructions.js b/packages/react-dev-utils/printHostingInstructions.js index 2371d6d60ed..aa440377cce 100644 --- a/packages/react-dev-utils/printHostingInstructions.js +++ b/packages/react-dev-utils/printHostingInstructions.js @@ -68,6 +68,11 @@ function printBaseMessage(buildFolder, hostingLocation) { console.log( `The ${chalk.cyan(buildFolder)} folder is ready to be deployed.` ); + console.log() + console.log('Find out more about deployment here:'); + console.log(); + console.log(` ${chalk.yellow('http://bit.ly/2vY88Kr')}`); + console.log(); } function printDeployInstructions(publicUrl, hasDeployScript, useYarn) { From 7b881f12e398fc6bcfdf39a0a3fafde8b48bac7e Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil Date: Thu, 11 Jan 2018 00:43:32 +0700 Subject: [PATCH 0484/1739] move the link for deployment to the bottom (#3736) --- .../printHostingInstructions.js | 74 +++++++++---------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/packages/react-dev-utils/printHostingInstructions.js b/packages/react-dev-utils/printHostingInstructions.js index aa440377cce..4f761dfb0d0 100644 --- a/packages/react-dev-utils/printHostingInstructions.js +++ b/packages/react-dev-utils/printHostingInstructions.js @@ -26,11 +26,9 @@ function printHostingInstructions( printBaseMessage(buildFolder, publicPathname); printDeployInstructions(publicUrl, hasDeployScript, useYarn); - } else if (publicPath !== '/') { // "homepage": "http://mywebsite.com/project" printBaseMessage(buildFolder, publicPath); - } else { // "homepage": "http://mywebsite.com" // or no homepage @@ -39,40 +37,36 @@ function printHostingInstructions( printStaticServerInstructions(buildFolder, useYarn); } console.log(); + console.log('Find out more about deployment here:'); + console.log(); + console.log(` ${chalk.yellow('http://bit.ly/2vY88Kr')}`); + console.log(); } function printBaseMessage(buildFolder, hostingLocation) { - console.log( - `The project was built assuming it is hosted at ${chalk.green( - hostingLocation || 'the server root' - )}.` - ); - console.log( - `You can control this with the ${chalk.green( - 'homepage' - )} field in your ${chalk.cyan('package.json')}.` - ); - - if (!hostingLocation) { - console.log('For example, add this to build it for GitHub Pages:'); - console.log(); - - console.log( - ` ${chalk.green('"homepage"')} ${chalk.cyan(':')} ${chalk.green( - '"http://myname.github.io/myapp"' - )}${chalk.cyan(',')}` - ); - } + console.log( + `The project was built assuming it is hosted at ${chalk.green( + hostingLocation || 'the server root' + )}.` + ); + console.log( + `You can control this with the ${chalk.green( + 'homepage' + )} field in your ${chalk.cyan('package.json')}.` + ); + + if (!hostingLocation) { + console.log('For example, add this to build it for GitHub Pages:'); console.log(); console.log( - `The ${chalk.cyan(buildFolder)} folder is ready to be deployed.` + ` ${chalk.green('"homepage"')} ${chalk.cyan(':')} ${chalk.green( + '"http://myname.github.io/myapp"' + )}${chalk.cyan(',')}` ); - console.log() - console.log('Find out more about deployment here:'); - console.log(); - console.log(` ${chalk.yellow('http://bit.ly/2vY88Kr')}`); - console.log(); + } + console.log(); + console.log(`The ${chalk.cyan(buildFolder)} folder is ready to be deployed.`); } function printDeployInstructions(publicUrl, hasDeployScript, useYarn) { @@ -88,20 +82,24 @@ function printDeployInstructions(publicUrl, hasDeployScript, useYarn) { } console.log(); - console.log(`Add the following script in your ${chalk.cyan( - 'package.json' - )}.`); + console.log( + `Add the following script in your ${chalk.cyan('package.json')}.` + ); console.log(); console.log(` ${chalk.dim('// ...')}`); console.log(` ${chalk.yellow('"scripts"')}: {`); console.log(` ${chalk.dim('// ...')}`); - console.log(` ${chalk.yellow('"predeploy"')}: ${chalk.yellow( - '"npm run build",' - )}`); - console.log(` ${chalk.yellow('"deploy"')}: ${chalk.yellow( - '"gh-pages -d build"' - )}`); + console.log( + ` ${chalk.yellow('"predeploy"')}: ${chalk.yellow( + '"npm run build",' + )}` + ); + console.log( + ` ${chalk.yellow('"deploy"')}: ${chalk.yellow( + '"gh-pages -d build"' + )}` + ); console.log(' }'); console.log(); From a03524c594062a8accb3e1a404f03fbc68fb44b1 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Wed, 10 Jan 2018 21:55:18 +0000 Subject: [PATCH 0485/1739] Use latest npm in e2e tests (#3735) * Use latest npm in e2e tests * Keep default npm version in "simple" test * Try to fix CI by using a version that supports Yarn --- tasks/e2e-installs.sh | 17 +++++++---------- tasks/e2e-kitchensink.sh | 5 +---- tasks/e2e-simple.sh | 4 ---- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 489cadb37c9..8cd3c0ef6e3 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -93,10 +93,7 @@ fi if hash npm 2>/dev/null then - # npm 5 is too buggy right now - if [ $(npm -v | head -c 1) -eq 5 ]; then - npm i -g npm@^4.x - fi; + npm i -g npm@latest npm cache clean || npm cache verify fi @@ -137,12 +134,12 @@ npm install "$cli_path" # ****************************************************************************** cd "$temp_app_path" -create_react_app --scripts-version=0.4.0 test-app-version-number +create_react_app --scripts-version=1.0.17 test-app-version-number cd test-app-version-number # Check corresponding scripts version is installed. exists node_modules/react-scripts -grep '"version": "0.4.0"' node_modules/react-scripts/package.json +grep '"version": "1.0.17"' node_modules/react-scripts/package.json checkDependencies # ****************************************************************************** @@ -150,13 +147,13 @@ checkDependencies # ****************************************************************************** cd "$temp_app_path" -create_react_app --use-npm --scripts-version=0.4.0 test-use-npm-flag +create_react_app --use-npm --scripts-version=1.0.17 test-use-npm-flag cd test-use-npm-flag # Check corresponding scripts version is installed. exists node_modules/react-scripts [ ! -e "yarn.lock" ] && echo "yarn.lock correctly does not exist" -grep '"version": "0.4.0"' node_modules/react-scripts/package.json +grep '"version": "1.0.17"' node_modules/react-scripts/package.json checkDependencies # ****************************************************************************** @@ -164,12 +161,12 @@ checkDependencies # ****************************************************************************** cd "$temp_app_path" -create_react_app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-0.4.0.tgz test-app-tarball-url +create_react_app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-1.0.17.tgz test-app-tarball-url cd test-app-tarball-url # Check corresponding scripts version is installed. exists node_modules/react-scripts -grep '"version": "0.4.0"' node_modules/react-scripts/package.json +grep '"version": "1.0.17"' node_modules/react-scripts/package.json checkDependencies # ****************************************************************************** diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 547821b652a..26c2ed08385 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -110,10 +110,7 @@ fi if hash npm 2>/dev/null then - # npm 5 is too buggy right now - if [ $(npm -v | head -c 1) -eq 5 ]; then - npm i -g npm@^4.x - fi; + npm i -g npm@latest npm cache clean || npm cache verify fi diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 34203407716..bb8f9b123b1 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -122,10 +122,6 @@ fi if hash npm 2>/dev/null then - # npm 5 is too buggy right now - if [ $(npm -v | head -c 1) -eq 5 ]; then - npm i -g npm@^4.x - fi; npm cache clean || npm cache verify fi From dcd8ea6b5cf654eb452e019b8f90cd2d77ca3829 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Wed, 10 Jan 2018 23:30:59 +0000 Subject: [PATCH 0486/1739] Always use Yarn on CI (#3738) --- .travis.yml | 6 ------ tasks/e2e-installs.sh | 7 ------- tasks/e2e-kitchensink.sh | 14 +------------- tasks/e2e-simple.sh | 14 +------------- tasks/local-test.sh | 6 ------ 5 files changed, 2 insertions(+), 45 deletions(-) diff --git a/.travis.yml b/.travis.yml index e2afbfa97f3..e970cf01cdb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,6 @@ script: - 'if [ $TEST_SUITE = "installs" ]; then tasks/e2e-installs.sh; fi' - 'if [ $TEST_SUITE = "kitchensink" ]; then tasks/e2e-kitchensink.sh; fi' env: - global: - - USE_YARN=no matrix: - TEST_SUITE=simple - TEST_SUITE=installs @@ -25,7 +23,3 @@ matrix: include: - node_js: 0.10 env: TEST_SUITE=simple -# There's a weird Yarn/Lerna bug related to prerelease versions. -# TODO: reenable after we ship 1.0. -# - node_js: 6 -# env: USE_YARN=yes TEST_SUITE=simple diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 8cd3c0ef6e3..402ab7bc288 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -103,13 +103,6 @@ grep -v "postinstall" package.json > temp && mv temp package.json npm install mv package.json.bak package.json -if [ "$USE_YARN" = "yes" ] -then - # Install Yarn so that the test can use it to install packages. - npm install -g yarn - yarn cache clean -fi - # We removed the postinstall, so do it manually node bootstrap.js diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 26c2ed08385..ddcd4873f67 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -58,12 +58,7 @@ function install_package { # Install `dependencies` cd node_modules/$pkg/ - if [ "$USE_YARN" = "yes" ] - then - yarn install --production - else - npm install --only=production - fi + npm install --only=production # Remove our packages to ensure side-by-side versions are used (which we link) rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts} cd ../.. @@ -120,13 +115,6 @@ grep -v "postinstall" package.json > temp && mv temp package.json npm install mv package.json.bak package.json -if [ "$USE_YARN" = "yes" ] -then - # Install Yarn so that the test can use it to install packages. - npm install -g yarn - yarn cache clean -fi - # We removed the postinstall, so do it manually node bootstrap.js diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index bb8f9b123b1..15a74e13ad0 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -57,12 +57,7 @@ function install_package { # Install `dependencies` cd node_modules/$pkg/ - if [ "$USE_YARN" = "yes" ] - then - yarn install --production - else - npm install --only=production - fi + npm install --only=production # Remove our packages to ensure side-by-side versions are used (which we link) rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts} cd ../.. @@ -147,13 +142,6 @@ then [[ $err_output =~ You\ are\ running\ Node ]] && exit 0 || exit 1 fi -if [ "$USE_YARN" = "yes" ] -then - # Install Yarn so that the test can use it to install packages. - npm install -g yarn - yarn cache clean -fi - # We removed the postinstall, so do it manually here node bootstrap.js diff --git a/tasks/local-test.sh b/tasks/local-test.sh index 8ce44b64057..0416fb5d9cc 100755 --- a/tasks/local-test.sh +++ b/tasks/local-test.sh @@ -11,7 +11,6 @@ function print_help { echo " --node-version the node version to use while testing [6]" echo " --git-branch the git branch to checkout for testing [the current one]" echo " --test-suite which test suite to use ('simple', installs', 'kitchensink', 'all') ['all']" - echo " --yarn if present, use yarn as the package manager" echo " --interactive gain a bash shell after the test run" echo " --help print this message and exit" echo "" @@ -22,7 +21,6 @@ cd $(dirname $0) node_version=6 current_git_branch=`git rev-parse --abbrev-ref HEAD` git_branch=${current_git_branch} -use_yarn=no test_suite=all interactive=false @@ -36,9 +34,6 @@ while [ "$1" != "" ]; do shift git_branch=$1 ;; - "--yarn") - use_yarn=yes - ;; "--test-suite") shift test_suite=$1 @@ -107,7 +102,6 @@ CMD docker run \ --env CI=true \ --env NPM_CONFIG_QUIET=true \ - --env USE_YARN=${use_yarn} \ --tty \ --user node \ --volume ${PWD}/..:/var/create-react-app \ From d29d41b3c69d0164ba80818cb6ab8e149327ddec Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 11 Jan 2018 00:54:49 +0000 Subject: [PATCH 0487/1739] Try to use Yarn in more E2E scripts (#3739) * Try to use Yarn in more E2E scripts * Keep using npm pack * Maybe this will fix Windows? * Try this --- tasks/e2e-installs.sh | 37 +++--------------- tasks/e2e-kitchensink.sh | 55 ++++++--------------------- tasks/e2e-simple.sh | 82 ++++++++++++---------------------------- 3 files changed, 42 insertions(+), 132 deletions(-) diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 402ab7bc288..d3c3bcf830b 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -72,42 +72,17 @@ set -x cd .. root_path=$PWD -# Clear cache to avoid issues with incorrect packages being used -if hash yarnpkg 2>/dev/null -then - # AppVeyor uses an old version of yarn. - # Once updated to 0.24.3 or above, the workaround can be removed - # and replaced with `yarnpkg cache clean` - # Issues: - # https://github.com/yarnpkg/yarn/issues/2591 - # https://github.com/appveyor/ci/issues/1576 - # https://github.com/facebookincubator/create-react-app/pull/2400 - # When removing workaround, you may run into - # https://github.com/facebookincubator/create-react-app/issues/2030 - case "$(uname -s)" in - *CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;; - *) yarn=yarnpkg;; - esac - $yarn cache clean -fi - -if hash npm 2>/dev/null -then - npm i -g npm@latest - npm cache clean || npm cache verify -fi - # Prevent bootstrap, we only want top-level dependencies cp package.json package.json.bak grep -v "postinstall" package.json > temp && mv temp package.json -npm install +yarn mv package.json.bak package.json # We removed the postinstall, so do it manually node bootstrap.js cd packages/react-error-overlay/ -npm run build:prod +yarn run build:prod cd ../.. # ****************************************************************************** @@ -120,7 +95,7 @@ cli_path=$PWD/`npm pack` # Install the CLI in a temporary location cd "$temp_cli_path" -npm install "$cli_path" +yarn add "$cli_path" # ****************************************************************************** # Test --scripts-version with a version number @@ -222,20 +197,20 @@ cd test-app-nested-paths-t1 mkdir -p test-app-nested-paths-t1/aa/bb/cc/dd create_react_app test-app-nested-paths-t1/aa/bb/cc/dd cd test-app-nested-paths-t1/aa/bb/cc/dd -npm start -- --smoke-test +yarn start --smoke-test # Testing a path that does not exist cd "$temp_app_path" create_react_app test-app-nested-paths-t2/aa/bb/cc/dd cd test-app-nested-paths-t2/aa/bb/cc/dd -npm start -- --smoke-test +yarn start --smoke-test # Testing a path that is half exists cd "$temp_app_path" mkdir -p test-app-nested-paths-t3/aa create_react_app test-app-nested-paths-t3/aa/bb/cc/dd cd test-app-nested-paths-t3/aa/bb/cc/dd -npm start -- --smoke-test +yarn start --smoke-test # Cleanup cleanup diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index ddcd4873f67..085f62f5bc1 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -58,7 +58,7 @@ function install_package { # Install `dependencies` cd node_modules/$pkg/ - npm install --only=production + yarn --production # Remove our packages to ensure side-by-side versions are used (which we link) rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts} cd ../.. @@ -84,42 +84,17 @@ set -x cd .. root_path=$PWD -# Clear cache to avoid issues with incorrect packages being used -if hash yarnpkg 2>/dev/null -then - # AppVeyor uses an old version of yarn. - # Once updated to 0.24.3 or above, the workaround can be removed - # and replaced with `yarnpkg cache clean` - # Issues: - # https://github.com/yarnpkg/yarn/issues/2591 - # https://github.com/appveyor/ci/issues/1576 - # https://github.com/facebookincubator/create-react-app/pull/2400 - # When removing workaround, you may run into - # https://github.com/facebookincubator/create-react-app/issues/2030 - case "$(uname -s)" in - *CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;; - *) yarn=yarnpkg;; - esac - $yarn cache clean -fi - -if hash npm 2>/dev/null -then - npm i -g npm@latest - npm cache clean || npm cache verify -fi - # Prevent bootstrap, we only want top-level dependencies cp package.json package.json.bak grep -v "postinstall" package.json > temp && mv temp package.json -npm install +yarn mv package.json.bak package.json # We removed the postinstall, so do it manually node bootstrap.js cd packages/react-error-overlay/ -npm run build:prod +yarn build:prod cd ../.. # ****************************************************************************** @@ -153,7 +128,7 @@ mv package.json.orig package.json # Install the CLI in a temporary location cd "$temp_cli_path" -npm install "$cli_path" +yarn add "$cli_path" # Install the app in a temporary location cd $temp_app_path @@ -161,7 +136,7 @@ create_react_app --scripts-version="$scripts_path" --internal-testing-template=" # Install the test module cd "$temp_module_path" -npm install test-integrity@^2.0.1 +yarn add test-integrity@^2.0.1 # ****************************************************************************** # Now that we used create-react-app to create an app depending on react-scripts, @@ -184,7 +159,7 @@ install_package "$temp_module_path/node_modules/test-integrity" REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ - npm run build + yarn build # Check for expected output exists build/*.html @@ -195,14 +170,14 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true \ NODE_PATH=src \ NODE_ENV=test \ - npm test -- --no-cache --testPathPattern=src + yarn test --no-cache --testPathPattern=src # Test "development" environment tmp_server_log=`mktemp` PORT=3001 \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_PATH=src \ - nohup npm start &>$tmp_server_log & + nohup yarn start &>$tmp_server_log & grep -q 'You can now view' <(tail -f $tmp_server_log) E2E_URL="http://localhost:3001" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ @@ -225,14 +200,6 @@ E2E_FILE=./build/index.html \ # Eject... echo yes | npm run eject -# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn -# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove -# this in the near future. -if hash yarnpkg 2>/dev/null -then - yarn install --check-files -fi - # ...but still link to the local packages install_package "$root_path"/packages/babel-preset-react-app install_package "$root_path"/packages/eslint-config-react-app @@ -246,7 +213,7 @@ install_package "$temp_module_path/node_modules/test-integrity" REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ - npm run build + yarn build # Check for expected output exists build/*.html @@ -257,14 +224,14 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true \ NODE_PATH=src \ NODE_ENV=test \ - npm test -- --no-cache --testPathPattern=src + yarn test --no-cache --testPathPattern=src # Test "development" environment tmp_server_log=`mktemp` PORT=3002 \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_PATH=src \ - nohup npm start &>$tmp_server_log & + nohup yarn start &>$tmp_server_log & grep -q 'You can now view' <(tail -f $tmp_server_log) E2E_URL="http://localhost:3002" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 15a74e13ad0..449c5f3ba76 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -57,7 +57,7 @@ function install_package { # Install `dependencies` cd node_modules/$pkg/ - npm install --only=production + yarn --production # Remove our packages to ensure side-by-side versions are used (which we link) rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts} cd ../.. @@ -96,39 +96,15 @@ if [ "$EXPECTED" != "$ACTUAL" ]; then exit 1 fi -# Clear cache to avoid issues with incorrect packages being used -if hash yarnpkg 2>/dev/null -then - # AppVeyor uses an old version of yarn. - # Once updated to 0.24.3 or above, the workaround can be removed - # and replaced with `yarnpkg cache clean` - # Issues: - # https://github.com/yarnpkg/yarn/issues/2591 - # https://github.com/appveyor/ci/issues/1576 - # https://github.com/facebookincubator/create-react-app/pull/2400 - # When removing workaround, you may run into - # https://github.com/facebookincubator/create-react-app/issues/2030 - case "$(uname -s)" in - *CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;; - *) yarn=yarnpkg;; - esac - $yarn cache clean -fi - -if hash npm 2>/dev/null -then - npm cache clean || npm cache verify -fi - # Prevent bootstrap, we only want top-level dependencies cp package.json package.json.bak grep -v "postinstall" package.json > temp && mv temp package.json -npm install +yarn mv package.json.bak package.json # We need to install create-react-app deps to test it cd "$root_path"/packages/create-react-app -npm install +yarn cd "$root_path" # If the node version is < 6, the script should just give an error. @@ -153,11 +129,11 @@ node bootstrap.js ./node_modules/.bin/eslint --max-warnings 0 packages/react-scripts/ cd packages/react-error-overlay/ ./node_modules/.bin/eslint --max-warnings 0 src/ -npm test -npm run build:prod +yarn test +yarn build:prod cd ../.. cd packages/react-dev-utils/ -npm test +yarn test cd ../.. # ****************************************************************************** @@ -166,7 +142,7 @@ cd ../.. # ****************************************************************************** # Test local build command -npm run build +yarn build # Check for expected output exists build/*.html exists build/static/js/*.js @@ -175,12 +151,12 @@ exists build/static/media/*.svg exists build/favicon.ico # Run tests with CI flag -CI=true npm test +CI=true yarn test # Uncomment when snapshot testing is enabled by default: # exists template/src/__snapshots__/App.test.js.snap # Test local start command -npm start -- --smoke-test +yarn start --smoke-test # ****************************************************************************** # Next, pack react-scripts and create-react-app so we can verify they work. @@ -216,10 +192,10 @@ cd "$temp_cli_path" # Initialize package.json before installing the CLI because npm will not install # the CLI properly in the temporary location if it is missing. -npm init --yes +yarn init --yes # Now we can install the CLI from the local package. -npm install "$cli_path" +yarn add "$cli_path" # Install the app in a temporary location cd $temp_app_path @@ -240,24 +216,24 @@ function verify_env_url { # Test relative path build awk -v n=2 -v s=" \"homepage\": \".\"," 'NR == n {print s} {print}' package.json > tmp && mv tmp package.json - npm run build + yarn build # Disabled until this can be tested # grep -F -R --exclude=*.map "../../static/" build/ -q; test $? -eq 0 || exit 1 grep -F -R --exclude=*.map "\"./static/" build/ -q; test $? -eq 0 || exit 1 grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 - PUBLIC_URL="/anabsolute" npm run build + PUBLIC_URL="/anabsolute" yarn build grep -F -R --exclude=*.map "/anabsolute/static/" build/ -q; test $? -eq 0 || exit 1 grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 # Test absolute path build sed "2s/.*/ \"homepage\": \"\/testingpath\",/" package.json > tmp && mv tmp package.json - npm run build + yarn build grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 || exit 1 grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 - PUBLIC_URL="https://www.example.net/overridetest" npm run build + PUBLIC_URL="https://www.example.net/overridetest" yarn build grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 || exit 1 grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 || exit 1 @@ -265,11 +241,11 @@ function verify_env_url { # Test absolute url build sed "2s/.*/ \"homepage\": \"https:\/\/www.example.net\/testingpath\",/" package.json > tmp && mv tmp package.json - npm run build + yarn build grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 || exit 1 grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 - PUBLIC_URL="https://www.example.net/overridetest" npm run build + PUBLIC_URL="https://www.example.net/overridetest" yarn build grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 || exit 1 grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 || exit 1 @@ -290,7 +266,7 @@ function verify_module_scope { echo "import sampleJson from '../sample'" | cat - src/App.js > src/App.js.temp && mv src/App.js.temp src/App.js # Make sure the build fails - npm run build; test $? -eq 1 || exit 1 + yarn build; test $? -eq 1 || exit 1 # TODO: check for error message # Restore App.js @@ -302,7 +278,7 @@ function verify_module_scope { cd test-app # Test the build -npm run build +yarn build # Check for expected output exists build/*.html exists build/static/js/*.js @@ -311,12 +287,12 @@ exists build/static/media/*.svg exists build/favicon.ico # Run tests with CI flag -CI=true npm test +CI=true yarn test # Uncomment when snapshot testing is enabled by default: # exists src/__snapshots__/App.test.js.snap # Test the server -npm start -- --smoke-test +yarn start --smoke-test # Test environment handling verify_env_url @@ -331,21 +307,13 @@ verify_module_scope # Eject... echo yes | npm run eject -# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn -# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove -# this in the near future. -if hash yarnpkg 2>/dev/null -then - yarnpkg install --check-files -fi - # ...but still link to the local packages install_package "$root_path"/packages/babel-preset-react-app install_package "$root_path"/packages/eslint-config-react-app install_package "$root_path"/packages/react-dev-utils # Test the build -npm run build +yarn build # Check for expected output exists build/*.html exists build/static/js/*.js @@ -354,15 +322,15 @@ exists build/static/media/*.svg exists build/favicon.ico # Run tests, overring the watch option to disable it. -# `CI=true npm test` won't work here because `npm test` becomes just `jest`. +# `CI=true yarn test` won't work here because `yarn test` becomes just `jest`. # We should either teach Jest to respect CI env variable, or make # `scripts/test.js` survive ejection (right now it doesn't). -npm test -- --watch=no +yarn test --watch=no # Uncomment when snapshot testing is enabled by default: # exists src/__snapshots__/App.test.js.snap # Test the server -npm start -- --smoke-test +yarn start --smoke-test # Test environment handling verify_env_url From 99c14e710ffb01d1c4a1124fc3ed2172bf58afbd Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 11 Jan 2018 01:55:55 +0000 Subject: [PATCH 0488/1739] Separate old Node E2E test (#3742) * Separate old Node E2E test * Try this for old node --- .travis.yml | 3 ++- tasks/e2e-old-node.sh | 61 +++++++++++++++++++++++++++++++++++++++++++ tasks/e2e-simple.sh | 16 ------------ 3 files changed, 63 insertions(+), 17 deletions(-) create mode 100755 tasks/e2e-old-node.sh diff --git a/.travis.yml b/.travis.yml index e970cf01cdb..ef223ffd5e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ script: - 'if [ $TEST_SUITE = "simple" ]; then tasks/e2e-simple.sh; fi' - 'if [ $TEST_SUITE = "installs" ]; then tasks/e2e-installs.sh; fi' - 'if [ $TEST_SUITE = "kitchensink" ]; then tasks/e2e-kitchensink.sh; fi' + - 'if [ $TEST_SUITE = "old-node" ]; then tasks/e2e-old-node.sh; fi' env: matrix: - TEST_SUITE=simple @@ -22,4 +23,4 @@ env: matrix: include: - node_js: 0.10 - env: TEST_SUITE=simple + env: TEST_SUITE=old-node diff --git a/tasks/e2e-old-node.sh b/tasks/e2e-old-node.sh new file mode 100755 index 00000000000..8245dd24e50 --- /dev/null +++ b/tasks/e2e-old-node.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# Copyright (c) 2015-present, Facebook, Inc. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +# ****************************************************************************** +# This is an end-to-end test intended to run on CI. +# You can also run it locally but it's slow. +# ****************************************************************************** + +# Start in tasks/ even if run from root directory +cd "$(dirname "$0")" + +temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'` + +function cleanup { + echo 'Cleaning up.' + cd "$root_path" + rm -rf $temp_app_path +} + +# Error messages are redirected to stderr +function handle_error { + echo "$(basename $0): ERROR! An error was encountered executing line $1." 1>&2; + cleanup + echo 'Exiting with error.' 1>&2; + exit 1 +} + +function handle_exit { + cleanup + echo 'Exiting without error.' 1>&2; + exit +} + +# Exit the script with a helpful error message when any error is encountered +trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR + +# Cleanup before exit on any termination signal +trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP + +# Echo every command being executed +set -x + +# Go to root +cd .. +root_path=$PWD + +# We need to install create-react-app deps to test it +cd "$root_path"/packages/create-react-app +npm install +cd "$root_path" + +# If the node version is < 6, the script should just give an error. +cd $temp_app_path +err_output=`node "$root_path"/packages/create-react-app/index.js test-node-version 2>&1 > /dev/null || echo ''` +[[ $err_output =~ You\ are\ running\ Node ]] && exit 0 || exit 1 + +# Cleanup +cleanup diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 449c5f3ba76..72bc757d9e8 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -102,22 +102,6 @@ grep -v "postinstall" package.json > temp && mv temp package.json yarn mv package.json.bak package.json -# We need to install create-react-app deps to test it -cd "$root_path"/packages/create-react-app -yarn -cd "$root_path" - -# If the node version is < 6, the script should just give an error. -nodeVersion=`node --version | cut -d v -f2` -nodeMajor=`echo $nodeVersion | cut -d. -f1` -nodeMinor=`echo $nodeVersion | cut -d. -f2` -if [[ nodeMajor -lt 6 ]] -then - cd $temp_app_path - err_output=`node "$root_path"/packages/create-react-app/index.js test-node-version 2>&1 > /dev/null || echo ''` - [[ $err_output =~ You\ are\ running\ Node ]] && exit 0 || exit 1 -fi - # We removed the postinstall, so do it manually here node bootstrap.js From 75d71e154167707be00d838e73680eb418ea1b82 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Thu, 11 Jan 2018 00:49:39 -0500 Subject: [PATCH 0489/1739] Use private registry (#3744) * Run e2e-simple in a realistic scenario * Use npx for everything * oops --- tasks/e2e-simple.sh | 95 +++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 68 deletions(-) diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 72bc757d9e8..b162adc924b 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -12,9 +12,8 @@ # Start in tasks/ even if run from root directory cd "$(dirname "$0")" -# CLI and app temporary locations +# App temporary location # http://unix.stackexchange.com/a/84980 -temp_cli_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_cli_path'` temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'` function cleanup { @@ -22,7 +21,7 @@ function cleanup { cd "$root_path" # Uncomment when snapshot testing is enabled by default: # rm ./packages/react-scripts/template/src/__snapshots__/App.test.js.snap - rm -rf "$temp_cli_path" $temp_app_path + rm -rf "$temp_app_path" } # Error messages are redirected to stderr @@ -39,30 +38,6 @@ function handle_exit { exit } -function create_react_app { - node "$temp_cli_path"/node_modules/create-react-app/index.js "$@" -} - -function install_package { - local pkg=$(basename $1) - - # Clean target (for safety) - rm -rf node_modules/$pkg/ - rm -rf node_modules/**/$pkg/ - - # Copy package into node_modules/ ignoring installed deps - # rsync -a ${1%/} node_modules/ --exclude node_modules - cp -R ${1%/} node_modules/ - rm -rf node_modules/$pkg/node_modules/ - - # Install `dependencies` - cd node_modules/$pkg/ - yarn --production - # Remove our packages to ensure side-by-side versions are used (which we link) - rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts} - cd ../.. -} - # Check for the existence of one or more files. function exists { for f in $*; do @@ -96,12 +71,31 @@ if [ "$EXPECTED" != "$ACTUAL" ]; then exit 1 fi +if hash npm 2>/dev/null +then + npm i -g npm@latest + npm cache clean || npm cache verify +fi + # Prevent bootstrap, we only want top-level dependencies cp package.json package.json.bak grep -v "postinstall" package.json > temp && mv temp package.json yarn mv package.json.bak package.json +# Start local registry +tmp_registry_log=`mktemp` +nohup npx verdaccio@2.7.2 &>$tmp_registry_log & +# Wait for `verdaccio` to boot +grep -q 'http address' <(tail -f $tmp_registry_log) + +# Set registry to local registry +npm set registry http://localhost:4873 +yarn config set registry http://localhost:4873 + +# Login so we can publish packages +npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r http://localhost:4873 --quotes + # We removed the postinstall, so do it manually here node bootstrap.js @@ -142,48 +136,18 @@ CI=true yarn test # Test local start command yarn start --smoke-test -# ****************************************************************************** -# Next, pack react-scripts and create-react-app so we can verify they work. -# ****************************************************************************** - -# Pack CLI -cd "$root_path"/packages/create-react-app -cli_path=$PWD/`npm pack` - -# Go to react-scripts -cd "$root_path"/packages/react-scripts - -# Save package.json because we're going to touch it -cp package.json package.json.orig - -# Replace own dependencies (those in the `packages` dir) with the local paths -# of those packages. -node "$root_path"/tasks/replace-own-deps.js - -# Finally, pack react-scripts -scripts_path="$root_path"/packages/react-scripts/`npm pack` - -# Restore package.json -rm package.json -mv package.json.orig package.json +git clean -f +./tasks/release.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest # ****************************************************************************** -# Now that we have packed them, create a clean app folder and install them. +# Install react-scripts prerelease via create-react-app prerelease. # ****************************************************************************** -# Install the CLI in a temporary location -cd "$temp_cli_path" - -# Initialize package.json before installing the CLI because npm will not install -# the CLI properly in the temporary location if it is missing. -yarn init --yes - -# Now we can install the CLI from the local package. -yarn add "$cli_path" - # Install the app in a temporary location cd $temp_app_path -create_react_app --scripts-version="$scripts_path" test-app +npx create-react-app test-app + +# TODO: verify we installed prerelease # ****************************************************************************** # Now that we used create-react-app to create an app depending on react-scripts, @@ -291,11 +255,6 @@ verify_module_scope # Eject... echo yes | npm run eject -# ...but still link to the local packages -install_package "$root_path"/packages/babel-preset-react-app -install_package "$root_path"/packages/eslint-config-react-app -install_package "$root_path"/packages/react-dev-utils - # Test the build yarn build # Check for expected output From 29e06fc91a31ae30e03bbbcbb53c384ec03499ec Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Thu, 11 Jan 2018 01:38:10 -0500 Subject: [PATCH 0490/1739] Follow-up: use private registry (#3746) * Convert e2e-installs * Convert kitchensink tests * Upgrade npm for kitchensink --- tasks/e2e-installs.sh | 56 +++++++++++++++---------- tasks/e2e-kitchensink.sh | 91 ++++++++++++---------------------------- 2 files changed, 59 insertions(+), 88 deletions(-) diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index d3c3bcf830b..3a40a78cbfb 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -14,13 +14,12 @@ cd "$(dirname "$0")" # CLI and app temporary locations # http://unix.stackexchange.com/a/84980 -temp_cli_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_cli_path'` temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'` function cleanup { echo 'Cleaning up.' cd "$root_path" - rm -rf "$temp_cli_path" "$temp_app_path" + rm -rf "$temp_app_path" } # Error messages are redirected to stderr @@ -55,10 +54,6 @@ function checkDependencies { fi } -function create_react_app { - node "$temp_cli_path"/node_modules/create-react-app/index.js $* -} - # Exit the script with a helpful error message when any error is encountered trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR @@ -72,6 +67,12 @@ set -x cd .. root_path=$PWD +if hash npm 2>/dev/null +then + npm i -g npm@latest + npm cache clean || npm cache verify +fi + # Prevent bootstrap, we only want top-level dependencies cp package.json package.json.bak grep -v "postinstall" package.json > temp && mv temp package.json @@ -86,23 +87,32 @@ yarn run build:prod cd ../.. # ****************************************************************************** -# First, pack and install create-react-app. +# First, publish the monorepo. # ****************************************************************************** -# Pack CLI -cd "$root_path"/packages/create-react-app -cli_path=$PWD/`npm pack` +# Start local registry +tmp_registry_log=`mktemp` +nohup npx verdaccio@2.7.2 &>$tmp_registry_log & +# Wait for `verdaccio` to boot +grep -q 'http address' <(tail -f $tmp_registry_log) + +# Set registry to local registry +npm set registry http://localhost:4873 +yarn config set registry http://localhost:4873 + +# Login so we can publish packages +npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r http://localhost:4873 --quotes -# Install the CLI in a temporary location -cd "$temp_cli_path" -yarn add "$cli_path" +# Publish the monorepo +git clean -f +./tasks/release.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest # ****************************************************************************** # Test --scripts-version with a version number # ****************************************************************************** cd "$temp_app_path" -create_react_app --scripts-version=1.0.17 test-app-version-number +npx create-react-app --scripts-version=1.0.17 test-app-version-number cd test-app-version-number # Check corresponding scripts version is installed. @@ -115,7 +125,7 @@ checkDependencies # ****************************************************************************** cd "$temp_app_path" -create_react_app --use-npm --scripts-version=1.0.17 test-use-npm-flag +npx create-react-app --use-npm --scripts-version=1.0.17 test-use-npm-flag cd test-use-npm-flag # Check corresponding scripts version is installed. @@ -129,7 +139,7 @@ checkDependencies # ****************************************************************************** cd "$temp_app_path" -create_react_app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-1.0.17.tgz test-app-tarball-url +npx create-react-app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-1.0.17.tgz test-app-tarball-url cd test-app-tarball-url # Check corresponding scripts version is installed. @@ -142,7 +152,7 @@ checkDependencies # ****************************************************************************** cd "$temp_app_path" -create_react_app --scripts-version=react-scripts-fork test-app-fork +npx create-react-app --scripts-version=react-scripts-fork test-app-fork cd test-app-fork # Check corresponding scripts version is installed. @@ -154,7 +164,7 @@ exists node_modules/react-scripts-fork cd "$temp_app_path" # we will install a non-existing package to simulate a failed installataion. -create_react_app --scripts-version=`date +%s` test-app-should-not-exist || true +npx create-react-app --scripts-version=`date +%s` test-app-should-not-exist || true # confirm that the project folder was deleted test ! -d test-app-should-not-exist @@ -166,7 +176,7 @@ cd "$temp_app_path" mkdir test-app-should-remain echo '## Hello' > ./test-app-should-remain/README.md # we will install a non-existing package to simulate a failed installataion. -create_react_app --scripts-version=`date +%s` test-app-should-remain || true +npx create-react-app --scripts-version=`date +%s` test-app-should-remain || true # confirm the file exist test -e test-app-should-remain/README.md # confirm only README.md is the only file in the directory @@ -180,7 +190,7 @@ fi cd $temp_app_path curl "https://registry.npmjs.org/@enoah_netzach/react-scripts/-/react-scripts-0.9.0.tgz" -o enoah-scripts-0.9.0.tgz -create_react_app --scripts-version=$temp_app_path/enoah-scripts-0.9.0.tgz test-app-scoped-fork-tgz +npx create-react-app --scripts-version=$temp_app_path/enoah-scripts-0.9.0.tgz test-app-scoped-fork-tgz cd test-app-scoped-fork-tgz # Check corresponding scripts version is installed. @@ -195,20 +205,20 @@ cd "$temp_app_path" mkdir test-app-nested-paths-t1 cd test-app-nested-paths-t1 mkdir -p test-app-nested-paths-t1/aa/bb/cc/dd -create_react_app test-app-nested-paths-t1/aa/bb/cc/dd +npx create-react-app test-app-nested-paths-t1/aa/bb/cc/dd cd test-app-nested-paths-t1/aa/bb/cc/dd yarn start --smoke-test # Testing a path that does not exist cd "$temp_app_path" -create_react_app test-app-nested-paths-t2/aa/bb/cc/dd +npx create-react-app test-app-nested-paths-t2/aa/bb/cc/dd cd test-app-nested-paths-t2/aa/bb/cc/dd yarn start --smoke-test # Testing a path that is half exists cd "$temp_app_path" mkdir -p test-app-nested-paths-t3/aa -create_react_app test-app-nested-paths-t3/aa/bb/cc/dd +npx create-react-app test-app-nested-paths-t3/aa/bb/cc/dd cd test-app-nested-paths-t3/aa/bb/cc/dd yarn start --smoke-test diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 085f62f5bc1..709d827530f 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -14,7 +14,6 @@ cd "$(dirname "$0")" # CLI, app, and test module temporary locations # http://unix.stackexchange.com/a/84980 -temp_cli_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_cli_path'` temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'` temp_module_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_module_path'` @@ -23,7 +22,7 @@ function cleanup { ps -ef | grep 'react-scripts' | grep -v grep | awk '{print $2}' | xargs kill -9 cd "$root_path" # TODO: fix "Device or resource busy" and remove ``|| $CI` - rm -rf "$temp_cli_path" "$temp_app_path" "$temp_module_path" || $CI + rm -rf "$temp_app_path" "$temp_module_path" || $CI } # Error messages are redirected to stderr @@ -40,30 +39,6 @@ function handle_exit { exit } -function create_react_app { - node "$temp_cli_path"/node_modules/create-react-app/index.js "$@" -} - -function install_package { - local pkg=$(basename $1) - - # Clean target (for safety) - rm -rf node_modules/$pkg/ - rm -rf node_modules/**/$pkg/ - - # Copy package into node_modules/ ignoring installed deps - # rsync -a ${1%/} node_modules/ --exclude node_modules - cp -R ${1%/} node_modules/ - rm -rf node_modules/$pkg/node_modules/ - - # Install `dependencies` - cd node_modules/$pkg/ - yarn --production - # Remove our packages to ensure side-by-side versions are used (which we link) - rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts} - cd ../.. -} - # Check for the existence of one or more files. function exists { for f in $*; do @@ -84,6 +59,12 @@ set -x cd .. root_path=$PWD +if hash npm 2>/dev/null +then + npm i -g npm@latest + npm cache clean || npm cache verify +fi + # Prevent bootstrap, we only want top-level dependencies cp package.json package.json.bak grep -v "postinstall" package.json > temp && mv temp package.json @@ -98,41 +79,33 @@ yarn build:prod cd ../.. # ****************************************************************************** -# First, pack react-scripts and create-react-app so we can use them. +# First, publish the monorepo. # ****************************************************************************** -# Pack CLI -cd "$root_path"/packages/create-react-app -cli_path=$PWD/`npm pack` - -# Go to react-scripts -cd "$root_path"/packages/react-scripts - -# Save package.json because we're going to touch it -cp package.json package.json.orig +# Start local registry +tmp_registry_log=`mktemp` +nohup npx verdaccio@2.7.2 &>$tmp_registry_log & +# Wait for `verdaccio` to boot +grep -q 'http address' <(tail -f $tmp_registry_log) -# Replace own dependencies (those in the `packages` dir) with the local paths -# of those packages. -node "$root_path"/tasks/replace-own-deps.js +# Set registry to local registry +npm set registry http://localhost:4873 +yarn config set registry http://localhost:4873 -# Finally, pack react-scripts -scripts_path="$root_path"/packages/react-scripts/`npm pack` +# Login so we can publish packages +npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r http://localhost:4873 --quotes -# Restore package.json -rm package.json -mv package.json.orig package.json +# Publish the monorepo +git clean -f +./tasks/release.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest # ****************************************************************************** -# Now that we have packed them, create a clean app folder and install them. +# Now that we have published them, create a clean app folder and install them. # ****************************************************************************** -# Install the CLI in a temporary location -cd "$temp_cli_path" -yarn add "$cli_path" - # Install the app in a temporary location cd $temp_app_path -create_react_app --scripts-version="$scripts_path" --internal-testing-template="$root_path"/packages/react-scripts/fixtures/kitchensink test-kitchensink +npx create-react-app --internal-testing-template="$root_path"/packages/react-scripts/fixtures/kitchensink test-kitchensink # Install the test module cd "$temp_module_path" @@ -146,14 +119,8 @@ yarn add test-integrity@^2.0.1 # Enter the app directory cd "$temp_app_path/test-kitchensink" -# Link to our preset -install_package "$root_path"/packages/babel-preset-react-app -# Link to error overlay package because now it's a dependency -# of react-dev-utils and not react-scripts -install_package "$root_path"/packages/react-error-overlay - # Link to test module -install_package "$temp_module_path/node_modules/test-integrity" +npm link "$temp_module_path/node_modules/test-integrity" # Test the build REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ @@ -198,16 +165,10 @@ E2E_FILE=./build/index.html \ # ****************************************************************************** # Eject... -echo yes | npm run eject - -# ...but still link to the local packages -install_package "$root_path"/packages/babel-preset-react-app -install_package "$root_path"/packages/eslint-config-react-app -install_package "$root_path"/packages/react-error-overlay -install_package "$root_path"/packages/react-dev-utils +echo yes | yarn eject # Link to test module -install_package "$temp_module_path/node_modules/test-integrity" +npm link "$temp_module_path/node_modules/test-integrity" # Test the build REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ From ebddb83dd6e07a25474ab8dd24dd3a1cccd22611 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Thu, 11 Jan 2018 01:40:03 -0500 Subject: [PATCH 0491/1739] Remove redundant steps in e2e tests (#3747) * This doesn't look needed anymore * Remove unnecessary rebuilds --- tasks/e2e-installs.sh | 12 +----------- tasks/e2e-kitchensink.sh | 12 +----------- tasks/e2e-simple.sh | 9 +-------- 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 3a40a78cbfb..73ca1c04b15 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -73,18 +73,8 @@ then npm cache clean || npm cache verify fi -# Prevent bootstrap, we only want top-level dependencies -cp package.json package.json.bak -grep -v "postinstall" package.json > temp && mv temp package.json +# Bootstrap monorepo yarn -mv package.json.bak package.json - -# We removed the postinstall, so do it manually -node bootstrap.js - -cd packages/react-error-overlay/ -yarn run build:prod -cd ../.. # ****************************************************************************** # First, publish the monorepo. diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 709d827530f..20c6dbb05e0 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -65,18 +65,8 @@ then npm cache clean || npm cache verify fi -# Prevent bootstrap, we only want top-level dependencies -cp package.json package.json.bak -grep -v "postinstall" package.json > temp && mv temp package.json +# Bootstrap monorepo yarn -mv package.json.bak package.json - -# We removed the postinstall, so do it manually -node bootstrap.js - -cd packages/react-error-overlay/ -yarn build:prod -cd ../.. # ****************************************************************************** # First, publish the monorepo. diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index b162adc924b..44ee14fb15c 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -77,11 +77,8 @@ then npm cache clean || npm cache verify fi -# Prevent bootstrap, we only want top-level dependencies -cp package.json package.json.bak -grep -v "postinstall" package.json > temp && mv temp package.json +# Bootstrap monorepo yarn -mv package.json.bak package.json # Start local registry tmp_registry_log=`mktemp` @@ -96,9 +93,6 @@ yarn config set registry http://localhost:4873 # Login so we can publish packages npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r http://localhost:4873 --quotes -# We removed the postinstall, so do it manually here -node bootstrap.js - # Lint own code ./node_modules/.bin/eslint --max-warnings 0 packages/babel-preset-react-app/ ./node_modules/.bin/eslint --max-warnings 0 packages/create-react-app/ @@ -108,7 +102,6 @@ node bootstrap.js cd packages/react-error-overlay/ ./node_modules/.bin/eslint --max-warnings 0 src/ yarn test -yarn build:prod cd ../.. cd packages/react-dev-utils/ yarn test From 1098a4a177521f06febb1fcf7da94791febb19ba Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Thu, 11 Jan 2018 02:21:25 -0500 Subject: [PATCH 0492/1739] Oops --- tasks/e2e-kitchensink.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 20c6dbb05e0..d12a3d645c0 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -155,7 +155,7 @@ E2E_FILE=./build/index.html \ # ****************************************************************************** # Eject... -echo yes | yarn eject +echo yes | npm run eject # Link to test module npm link "$temp_module_path/node_modules/test-integrity" From 89bf2fcc55ffea57e7541faacd1606c18b65a5b9 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 11 Jan 2018 04:29:35 -0800 Subject: [PATCH 0493/1739] Adding some more non-conflicting files to validFiles (#3740) --- packages/create-react-app/createReactApp.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index f91608f34dc..a2d9fdbd86b 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -619,6 +619,12 @@ function isSafeToCreateProjectIn(root, name) { '.hg', '.hgignore', '.hgcheck', + '.npmignore', + 'mkdocs.yml', + 'docs', + '.travis.yml', + '.gitlab-ci.yml', + '.gitattributes', ]; console.log(); From 4c0bf037d1255e41aa6596952913f6ceed5cf1cb Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 11 Jan 2018 12:35:51 +0000 Subject: [PATCH 0494/1739] Delete old file It's been here long enough. --- template/README.md | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 template/README.md diff --git a/template/README.md b/template/README.md deleted file mode 100644 index 32efd00ff82..00000000000 --- a/template/README.md +++ /dev/null @@ -1,4 +0,0 @@ -This page has moved!
-Please update your link to point [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md) instead. - -Sorry for the inconvenience! From b02fe6673264d03cd12d9a0e0adca1b724806b68 Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil Date: Fri, 12 Jan 2018 06:25:27 +0700 Subject: [PATCH 0495/1739] clean up changes to npm and yarn registry (#3756) --- tasks/e2e-installs.sh | 11 ++++++++--- tasks/e2e-kitchensink.sh | 11 ++++++++--- tasks/e2e-simple.sh | 11 ++++++++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 73ca1c04b15..9d7a0e99daa 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -15,11 +15,16 @@ cd "$(dirname "$0")" # CLI and app temporary locations # http://unix.stackexchange.com/a/84980 temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'` +custom_registry_url=http://localhost:4873 +original_npm_registry_url=`npm get registry` +original_yarn_registry_url=`yarn config get registry` function cleanup { echo 'Cleaning up.' cd "$root_path" rm -rf "$temp_app_path" + npm set registry "$original_npm_registry_url" + yarn config set registry "$original_yarn_registry_url" } # Error messages are redirected to stderr @@ -87,11 +92,11 @@ nohup npx verdaccio@2.7.2 &>$tmp_registry_log & grep -q 'http address' <(tail -f $tmp_registry_log) # Set registry to local registry -npm set registry http://localhost:4873 -yarn config set registry http://localhost:4873 +npm set registry "$custom_registry_url" +yarn config set registry "$custom_registry_url" # Login so we can publish packages -npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r http://localhost:4873 --quotes +npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r "$custom_registry_url" --quotes # Publish the monorepo git clean -f diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index d12a3d645c0..9dc2370dafc 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -16,6 +16,9 @@ cd "$(dirname "$0")" # http://unix.stackexchange.com/a/84980 temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'` temp_module_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_module_path'` +custom_registry_url=http://localhost:4873 +original_npm_registry_url=`npm get registry` +original_yarn_registry_url=`yarn config get registry` function cleanup { echo 'Cleaning up.' @@ -23,6 +26,8 @@ function cleanup { cd "$root_path" # TODO: fix "Device or resource busy" and remove ``|| $CI` rm -rf "$temp_app_path" "$temp_module_path" || $CI + npm set registry "$original_npm_registry_url" + yarn config set registry "$original_yarn_registry_url" } # Error messages are redirected to stderr @@ -79,11 +84,11 @@ nohup npx verdaccio@2.7.2 &>$tmp_registry_log & grep -q 'http address' <(tail -f $tmp_registry_log) # Set registry to local registry -npm set registry http://localhost:4873 -yarn config set registry http://localhost:4873 +npm set registry "$custom_registry_url" +yarn config set registry "$custom_registry_url" # Login so we can publish packages -npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r http://localhost:4873 --quotes +npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r "$custom_registry_url" --quotes # Publish the monorepo git clean -f diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 44ee14fb15c..98941f25661 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -15,6 +15,9 @@ cd "$(dirname "$0")" # App temporary location # http://unix.stackexchange.com/a/84980 temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'` +custom_registry_url=http://localhost:4873 +original_npm_registry_url=`npm get registry` +original_yarn_registry_url=`yarn config get registry` function cleanup { echo 'Cleaning up.' @@ -22,6 +25,8 @@ function cleanup { # Uncomment when snapshot testing is enabled by default: # rm ./packages/react-scripts/template/src/__snapshots__/App.test.js.snap rm -rf "$temp_app_path" + npm set registry "$original_npm_registry_url" + yarn config set registry "$original_yarn_registry_url" } # Error messages are redirected to stderr @@ -87,11 +92,11 @@ nohup npx verdaccio@2.7.2 &>$tmp_registry_log & grep -q 'http address' <(tail -f $tmp_registry_log) # Set registry to local registry -npm set registry http://localhost:4873 -yarn config set registry http://localhost:4873 +npm set registry "$custom_registry_url" +yarn config set registry "$custom_registry_url" # Login so we can publish packages -npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r http://localhost:4873 --quotes +npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r "$custom_registry_url" --quotes # Lint own code ./node_modules/.bin/eslint --max-warnings 0 packages/babel-preset-react-app/ From 3f7851deab848dbaf14844a55c27b09a6f5cb308 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 12 Jan 2018 00:01:30 +0000 Subject: [PATCH 0496/1739] Try updating Flow (#3757) --- packages/react-error-overlay/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index d4e528ea6c6..f2148885c1f 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -46,7 +46,7 @@ "eslint-plugin-import": "2.7.0", "eslint-plugin-jsx-a11y": "5.1.1", "eslint-plugin-react": "7.1.0", - "flow-bin": "^0.54.0", + "flow-bin": "^0.63.1", "html-entities": "1.2.1", "jest": "20.0.4", "jest-fetch-mock": "1.2.1", From 0aeffe62efb27abf489fa779647aad400a2dec0b Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 12 Jan 2018 01:54:53 +0000 Subject: [PATCH 0497/1739] Switch to Yarn Workspaces (#3755) * Switch to Yarn Workspaces * Feedback * Move flowconfig * Use publish script * Keep git status check * Fix Flow without perf penalty * Remove Flow from package.json "test" * Try running it from script directly (?) * Try magic incantations * lol flow COME ON * Try to skip Flow on AppVeyor * -df * -df * -df * Try to fix CI * Revert unrelated changes * Update CONTRIBUTING.md --- .yarnrc | 1 + CONTRIBUTING.md | 18 +++--- bootstrap.js | 67 ----------------------- lerna.json | 9 ++- package.json | 15 +++-- packages/react-error-overlay/.flowconfig | 14 +++-- packages/react-error-overlay/flow/env.js | 19 +++++++ packages/react-error-overlay/package.json | 2 +- tasks/e2e-installs.sh | 4 +- tasks/e2e-kitchensink.sh | 4 +- tasks/e2e-simple.sh | 10 +++- tasks/{release.sh => publish.sh} | 9 +-- 12 files changed, 65 insertions(+), 107 deletions(-) create mode 100644 .yarnrc delete mode 100644 bootstrap.js create mode 100644 packages/react-error-overlay/flow/env.js rename tasks/{release.sh => publish.sh} (84%) diff --git a/.yarnrc b/.yarnrc new file mode 100644 index 00000000000..acaaffdb73e --- /dev/null +++ b/.yarnrc @@ -0,0 +1 @@ +--install.no-lockfile true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8957c0c3de6..62908c39b6b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -75,20 +75,18 @@ All functionality must be retained (and configuration given to the user) if they 1. Clone the repo with `git clone https://github.com/facebookincubator/create-react-app` -2. Run `npm install` in the root `create-react-app` folder. +2. Run `yarn` in the root `create-react-app` folder. -Once it is done, you can modify any file locally and run `npm start`, `npm test` or `npm run build` just like in a generated project. +Once it is done, you can modify any file locally and run `yarn start`, `yarn test` or `yarn build` just like in a generated project. If you want to try out the end-to-end flow with the global CLI, you can do this too: ``` -npm run create-react-app my-app +yarn create-react-app my-app cd my-app ``` -and then run `npm start` or `npm run build`. - -*Note: if you are using yarn, we suggest that you use `yarn install --no-lockfile` instead of the bare `yarn` or `yarn install` because we [intentionally](https://github.com/facebookincubator/create-react-app/pull/2014#issuecomment-300811661) do not ignore or add yarn.lock to our repo.* +and then run `yarn start` or `yarn build`. ## Contributing to E2E (end to end) tests @@ -104,8 +102,8 @@ The scripts in tasks folder and other scripts in `package.json` will not work in A good step by step guide can be found [here](https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/) -### Install Node.js and npm -Even if you have node and npm installed on your windows, it would not be accessible from the bash shell. You would have to install it again. Installing via [`nvm`](https://github.com/creationix/nvm#install-script) is recommended. +### Install Node.js and yarn +Even if you have node and yarn installed on your windows, it would not be accessible from the bash shell. You would have to install it again. Installing via [`nvm`](https://github.com/creationix/nvm#install-script) is recommended. ### Line endings @@ -119,11 +117,11 @@ By default git would use `CRLF` line endings which would cause the scripts to fa 4. Note that files in `packages/create-react-app` should be modified with extreme caution. Since it’s a global CLI, any version of `create-react-app` (global CLI) including very old ones should work with the latest version of `react-scripts`. 5. Create a change log entry for the release: * You'll need an [access token for the GitHub API](https://help.github.com/articles/creating-an-access-token-for-command-line-use/). Save it to this environment variable: `export GITHUB_AUTH="..."` - * Run `npm run changelog`. The command will find all the labeled pull requests merged since the last release and group them by the label and affected packages, and create a change log entry with all the changes and links to PRs and their authors. Copy and paste it to `CHANGELOG.md`. + * Run `yarn changelog`. The command will find all the labeled pull requests merged since the last release and group them by the label and affected packages, and create a change log entry with all the changes and links to PRs and their authors. Copy and paste it to `CHANGELOG.md`. * Add a four-space indented paragraph after each non-trivial list item, explaining what changed and why. For each breaking change also write who it affects and instructions for migrating existing code. * Maybe add some newlines here and there. Preview the result on GitHub to get a feel for it. Changelog generator output is a bit too terse for my taste, so try to make it visually pleasing and well grouped. 6. Make sure to include “Migrating from ...” instructions for the previous release. Often you can copy and paste them. -7. **Do not run `npm publish`. Instead, run `npm run publish`.** +7. Run `yarn run publish`. (Don’t forget the `run` there.) 8. Wait for a long time, and it will get published. Don’t worry that it’s stuck. In the end the publish script will prompt for versions before publishing the packages. 9. After publishing, create a GitHub Release with the same text as the changelog entry. See previous Releases for inspiration. diff --git a/bootstrap.js b/bootstrap.js deleted file mode 100644 index b54a1ed9f36..00000000000 --- a/bootstrap.js +++ /dev/null @@ -1,67 +0,0 @@ -'use strict'; - -const { execSync, spawn } = require('child_process'); -const { resolve } = require('path'); -const { existsSync } = require('fs'); -const { platform } = require('os'); - -function shouldUseYarn() { - try { - execSync('yarnpkg --version', { stdio: 'ignore' }); - return true; - } catch (e) { - return false; - } -} - -function shouldUseNpmConcurrently() { - try { - const versionString = execSync('npm --version'); - const m = /^(\d+)[.]/.exec(versionString); - // NPM >= 5 support concurrent installs - return Number(m[1]) >= 5; - } catch (e) { - return false; - } -} - -const yarn = shouldUseYarn(); -const windows = platform() === 'win32'; -const lerna = resolve( - __dirname, - 'node_modules', - '.bin', - windows ? 'lerna.cmd' : 'lerna' -); - -if (!existsSync(lerna)) { - if (yarn) { - console.log('Cannot find lerna. Please run `yarn --check-files`.'); - } else { - console.log( - 'Cannot find lerna. Please remove `node_modules` and run `npm install`.' - ); - } - process.exit(1); -} - -let child; -if (yarn) { - // Yarn does not support concurrency - child = spawn(lerna, ['bootstrap', '--npm-client=yarn', '--concurrency=1'], { - stdio: 'inherit', - }); -} else { - let args = ['bootstrap']; - if ( - // The Windows filesystem does not handle concurrency well - windows || - // Only newer npm versions support concurrency - !shouldUseNpmConcurrently() - ) { - args.push('--concurrency=1'); - } - child = spawn(lerna, args, { stdio: 'inherit' }); -} - -child.on('close', code => process.exit(code)); diff --git a/lerna.json b/lerna.json index 1673f8a3187..f1d78d84bae 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,7 @@ { - "lerna": "2.0.0", + "lerna": "2.6.0", + "npmClient": "yarn", + "useWorkspaces": true, "version": "independent", "changelog": { "repo": "facebookincubator/create-react-app", @@ -12,8 +14,5 @@ "tag: internal": ":house: Internal" }, "cacheDir": ".changelog" - }, - "packages": [ - "packages/*" - ] + } } diff --git a/package.json b/package.json index 9cf2f50f14f..15f463a10d5 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,26 @@ { "private": true, + "workspaces": [ + "packages/*" + ], "scripts": { - "build": "node packages/react-scripts/scripts/build.js", + "build": "cd packages/react-scripts && node scripts/build.js", "changelog": "lerna-changelog", "create-react-app": "node tasks/cra.js", "e2e": "tasks/e2e-simple.sh", "e2e:docker": "tasks/local-test.sh", - "postinstall": "node bootstrap.js && cd packages/react-error-overlay/ && npm run build:prod", - "publish": "tasks/release.sh", - "start": "node packages/react-scripts/scripts/start.js", + "postinstall": "cd packages/react-error-overlay/ && yarn build:prod", + "publish": "tasks/publish.sh", + "start": "cd packages/react-scripts && node scripts/start.js", "screencast": "svg-term --cast hItN7sl5yfCPTHxvFg5glhhfp --out screencast.svg --window", - "test": "node packages/react-scripts/scripts/test.js --env=jsdom", + "test": "cd packages/react-scripts && node scripts/test.js --env=jsdom", "format": "prettier --trailing-comma es5 --single-quote --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'", "precommit": "lint-staged" }, "devDependencies": { "eslint": "^4.4.1", "husky": "^0.13.2", - "lerna": "^2.0.0", + "lerna": "^2.6.0", "lerna-changelog": "^0.6.0", "lint-staged": "^3.3.1", "prettier": "1.6.1", diff --git a/packages/react-error-overlay/.flowconfig b/packages/react-error-overlay/.flowconfig index 8d7de784e29..c976167c2a9 100644 --- a/packages/react-error-overlay/.flowconfig +++ b/packages/react-error-overlay/.flowconfig @@ -1,9 +1,15 @@ -[ignore] -.*/node_modules/eslint-plugin-jsx-a11y/.* - [include] -src/**/*.js +/src/**/*.js + +[ignore] +.*/node_modules/.* +.*/.git/.* +.*/__test__/.* +.*/fixtures/.* [libs] +flow/ [options] +module.file_ext=.js +sharedmemory.hash_table_pow=19 diff --git a/packages/react-error-overlay/flow/env.js b/packages/react-error-overlay/flow/env.js new file mode 100644 index 00000000000..12b151f5e4b --- /dev/null +++ b/packages/react-error-overlay/flow/env.js @@ -0,0 +1,19 @@ +declare module 'anser' { + declare module.exports: any; +} + +declare module 'babel-code-frame' { + declare module.exports: any; +} + +declare module 'html-entities' { + declare module.exports: any; +} + +declare module 'settle-promise' { + declare module.exports: any; +} + +declare module 'source-map' { + declare module.exports: any; +} diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index f2148885c1f..9808a9da81d 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -6,7 +6,7 @@ "scripts": { "prepublishOnly": "npm run build:prod && npm test", "start": "cross-env NODE_ENV=development node build.js --watch", - "test": "flow && cross-env NODE_ENV=test jest", + "test": "cross-env NODE_ENV=test jest", "build": "cross-env NODE_ENV=development node build.js", "build:prod": "cross-env NODE_ENV=production node build.js" }, diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 9d7a0e99daa..bcd616f3601 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -99,8 +99,8 @@ yarn config set registry "$custom_registry_url" npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r "$custom_registry_url" --quotes # Publish the monorepo -git clean -f -./tasks/release.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest +git clean -df +./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest # ****************************************************************************** # Test --scripts-version with a version number diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 9dc2370dafc..d73c45ddbfa 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -91,8 +91,8 @@ yarn config set registry "$custom_registry_url" npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r "$custom_registry_url" --quotes # Publish the monorepo -git clean -f -./tasks/release.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest +git clean -df +./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest # ****************************************************************************** # Now that we have published them, create a clean app folder and install them. diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 98941f25661..b566ae37a3d 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -107,6 +107,12 @@ npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r "$custom_reg cd packages/react-error-overlay/ ./node_modules/.bin/eslint --max-warnings 0 src/ yarn test + +if [ $APPVEYOR != 'True' ]; then + # Flow started hanging on AppVeyor after we moved to Yarn Workspaces :-( + yarn flow +fi + cd ../.. cd packages/react-dev-utils/ yarn test @@ -134,8 +140,8 @@ CI=true yarn test # Test local start command yarn start --smoke-test -git clean -f -./tasks/release.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest +git clean -df +./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest # ****************************************************************************** # Install react-scripts prerelease via create-react-app prerelease. diff --git a/tasks/release.sh b/tasks/publish.sh similarity index 84% rename from tasks/release.sh rename to tasks/publish.sh index 0f11bb0d60c..c1cae86c200 100755 --- a/tasks/release.sh +++ b/tasks/publish.sh @@ -26,21 +26,14 @@ set -x cd .. root_path=$PWD -# You can only release with npm >= 3 -if [ $(npm -v | head -c 1) -lt 3 ]; then - echo "Releasing requires npm >= 3. Aborting."; - exit 1; -fi; - if [ -n "$(git status --porcelain)" ]; then echo "Your git status is not clean. Aborting."; exit 1; fi -cd "$root_path" # Compile cd packages/react-error-overlay/ npm run build:prod cd ../.. # Go! -./node_modules/.bin/lerna publish --independent "$@" +./node_modules/.bin/lerna publish --independent "$@" \ No newline at end of file From 3f0994775f19bd33119dc303a0b4101eea2616e3 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 12 Jan 2018 13:50:42 +0000 Subject: [PATCH 0498/1739] Pin Lerna --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 15f463a10d5..9a32bc1350f 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "devDependencies": { "eslint": "^4.4.1", "husky": "^0.13.2", - "lerna": "^2.6.0", + "lerna": "2.6.0", "lerna-changelog": "^0.6.0", "lint-staged": "^3.3.1", "prettier": "1.6.1", From 238af4b1dac7e2e2026217c9d07eb58ba8422b2d Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 12 Jan 2018 22:14:27 -0500 Subject: [PATCH 0499/1739] Enable Yarn check files (#3769) * This is a good default. Adds approx 4 seconds to install time, but can save some headaches. * Add no lockfile for add, too --- .yarnrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.yarnrc b/.yarnrc index acaaffdb73e..07e44a9a5b2 100644 --- a/.yarnrc +++ b/.yarnrc @@ -1 +1,3 @@ --install.no-lockfile true +--install.check-files true +--add.no-lockfile true From a3d33c46084d88ece2c5ab49e61e5fc62f3a8187 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sun, 14 Jan 2018 02:48:15 +0000 Subject: [PATCH 0500/1739] Add an explicit link to Code of Conduct (#3781) All FB open source projects including this one enforce [our code of conduct](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct), but I just realized we haven't explicitly linked to it from a Markdown file. So I'm doing just that. --- CODE_OF_CONDUCT.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..55203be746a --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +# Code of Conduct + +Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct) so that you can understand what actions will and will not be tolerated. From 585608e3d6c33d99f53f3b14ead39c8eb069abbf Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sun, 14 Jan 2018 10:24:00 +0000 Subject: [PATCH 0501/1739] Update opn (#3784) --- packages/react-dev-utils/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 54606f33fe8..d6fe1bd3e45 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -47,7 +47,7 @@ "gzip-size": "3.0.0", "inquirer": "3.3.0", "is-root": "1.0.0", - "opn": "5.1.0", + "opn": "5.2.0", "react-error-overlay": "^3.0.0", "recursive-readdir": "2.2.1", "shell-quote": "1.6.1", From 77148107d9f3b20fb874a8da3146172c34e921db Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sun, 14 Jan 2018 11:52:10 +0000 Subject: [PATCH 0502/1739] Add npx note to quick overview --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d6945417abf..b09630e90ba 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ cd my-app npm start ``` +*([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))* + Then open [http://localhost:3000/](http://localhost:3000/) to see your app.
When you’re ready to deploy to production, create a minified bundle with `npm run build`. From 1e9eaf3630cbce6eeb54f456b847133d2309c378 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sun, 14 Jan 2018 15:05:38 +0000 Subject: [PATCH 0503/1739] Bump detect-port-alt (#3787) * Bump detect-port-alt * Bump again --- packages/react-dev-utils/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index d6fe1bd3e45..d4b933f7183 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -40,7 +40,7 @@ "babel-code-frame": "6.26.0", "chalk": "1.1.3", "cross-spawn": "5.1.0", - "detect-port-alt": "1.1.3", + "detect-port-alt": "1.1.5", "escape-string-regexp": "1.0.5", "filesize": "3.5.11", "global-modules": "1.0.0", From 22f9fe0d33dded7ec5a361ef08f69167874a4eb7 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sun, 14 Jan 2018 15:37:00 +0000 Subject: [PATCH 0504/1739] Always include destructuring transform (#3788) * Always include destructuring transform * Fix lint --- packages/babel-preset-react-app/index.js | 4 ++++ packages/babel-preset-react-app/package.json | 1 + .../kitchensink/src/features/syntax/ObjectDestructuring.js | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index 0d961af6f0f..d90fb6af50b 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -7,6 +7,10 @@ 'use strict'; const plugins = [ + // Necessary to include regardless of the environment because + // in practice some other transforms (such as object-rest-spread) + // don't work without it: https://github.com/babel/babel/issues/7215 + require.resolve('babel-plugin-transform-es2015-destructuring'), // class { handleClick = () => { } } require.resolve('babel-plugin-transform-class-properties'), // The following two plugins use Object.assign directly, instead of Babel's diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index f020f99e0b8..23c22142334 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -14,6 +14,7 @@ "babel-plugin-dynamic-import-node": "1.1.0", "babel-plugin-syntax-dynamic-import": "6.18.0", "babel-plugin-transform-class-properties": "6.24.1", + "babel-plugin-transform-es2015-destructuring": "6.23.0", "babel-plugin-transform-object-rest-spread": "6.26.0", "babel-plugin-transform-react-constant-elements": "6.23.0", "babel-plugin-transform-react-jsx": "6.24.1", diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js index be519175f69..14b06f7a4cc 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js @@ -40,7 +40,9 @@ export default class extends Component { return (
{this.state.users.map(user => { - const { id, name } = user; + const { id, ...rest } = user; + // eslint-disable-next-line no-unused-vars + const [{ name, ...innerRest }] = [{ ...rest }]; return
{name}
; })}
From b86fe056a36c2da948e9c3ad363217712b4a37bc Mon Sep 17 00:00:00 2001 From: Ian Sutherland Date: Sun, 14 Jan 2018 12:14:37 -0700 Subject: [PATCH 0505/1739] Add warning when HOST environment variable is set (#3730) * Add warning when HOST environment variable is set (#3719) * Improve HOST environment variable warning message * Adjust text and message Closes #3719 --- packages/react-scripts/scripts/start.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/react-scripts/scripts/start.js b/packages/react-scripts/scripts/start.js index 7eb7ad464c0..3ff1b91f435 100644 --- a/packages/react-scripts/scripts/start.js +++ b/packages/react-scripts/scripts/start.js @@ -51,6 +51,21 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000; const HOST = process.env.HOST || '0.0.0.0'; +if (process.env.HOST) { + console.log( + chalk.cyan( + `Attempting to bind to HOST environment variable: ${chalk.yellow( + chalk.bold(process.env.HOST) + )}` + ) + ); + console.log( + `If this was unintentional, check that you haven't mistakenly set it in your shell.` + ); + console.log(`Learn more here: ${chalk.yellow('http://bit.ly/2mwWSwH')}`); + console.log(); +} + // We attempt to use the default port but if it is busy, we offer the user to // run on a different port. `choosePort()` Promise resolves to the next free port. choosePort(HOST, DEFAULT_PORT) From 12d05447b925f121c9b03954b59c6378bf783693 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sun, 14 Jan 2018 23:57:49 +0000 Subject: [PATCH 0506/1739] Test Node 9 on CI (#3793) * Test Node 9 on CI * Oops --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ef223ffd5e4..860000b5c9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,8 @@ dist: trusty language: node_js node_js: - - 6 - 8 + - 9 cache: directories: - node_modules @@ -24,3 +24,5 @@ matrix: include: - node_js: 0.10 env: TEST_SUITE=old-node + - node_js: 6 + env: TEST_SUITE=kitchensink From 95b26012a4a0debeef98c8bc69214db3a83b5646 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 15 Jan 2018 00:36:53 +0000 Subject: [PATCH 0507/1739] Tweak section on expanding env variables --- packages/react-scripts/template/README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index e5c0cf6bf77..7c641456056 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -980,17 +980,20 @@ these defined as well. Consult their documentation how to do this. For example, #### Expanding Environment Variables In `.env` ->Note: this feature is available with `react-scripts@1.0.18` and higher. +>Note: this feature is available with `react-scripts@1.1.0` and higher. -Expand variables already on your machine for use in your .env file (using [dotenv-expand](https://github.com/motdotla/dotenv-expand)). See [#2223](https://github.com/facebookincubator/create-react-app/issues/2223). +Expand variables already on your machine for use in your `.env` file (using [dotenv-expand](https://github.com/motdotla/dotenv-expand)). For example, to get the environment variable `npm_package_version`: + ``` REACT_APP_VERSION=$npm_package_version # also works: # REACT_APP_VERSION=${npm_package_version} ``` + Or expand variables local to the current `.env` file: + ``` DOMAIN=www.example.com REACT_APP_FOO=$DOMAIN/foo From aa5bdcd05f490e9e1b529a45deb1f0ab6fa487fa Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 15 Jan 2018 00:37:46 +0000 Subject: [PATCH 0508/1739] Changelog for 1.1.0 (#3795) --- CHANGELOG.md | 187 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f233de0ade8..a2dfec8fec6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,190 @@ +## 1.1.0 (January 15, 2018) + +#### :rocket: New Feature + +* `react-scripts` + + * [#3387](https://github.com/facebookincubator/create-react-app/pull/3387) Add support for variable expansion in `.env` files. ([@moos](https://github.com/moos)) + +* `react-error-overlay` + + * [#3474](https://github.com/facebookincubator/create-react-app/pull/3474) Allow the error overlay to be unregistered. ([@Timer](https://github.com/Timer)) + +* `create-react-app` + + * [#3408](https://github.com/facebookincubator/create-react-app/pull/3408) Add `--info` flag to help gather bug reports. ([@tabrindle](https://github.com/tabrindle)) + * [#3409](https://github.com/facebookincubator/create-react-app/pull/3409) Add `--use-npm` flag to bypass Yarn even on systems that have it. ([@tabrindle](https://github.com/tabrindle)) + * [#3725](https://github.com/facebookincubator/create-react-app/pull/3725) Extend `--scripts-version` to include `.tar.gz` format. ([@SaschaDens](https://github.com/SaschaDens)) + * [#3629](https://github.com/facebookincubator/create-react-app/pull/3629) Allowing `"file:"` `--scripts-version` values. ([@GreenGremlin](https://github.com/GreenGremlin)) + + +#### :bug: Bug Fix + +* `babel-preset-react-app`, `react-scripts` + + * [#3788](https://github.com/facebookincubator/create-react-app/pull/3788) Fix object destructuring inside an array on Node 6. ([@gaearon](https://github.com/gaearon)) + +* `react-dev-utils` + + * [#3784](https://github.com/facebookincubator/create-react-app/pull/3784) Detach browser process from the shell on Linux. ([@gaearon](https://github.com/gaearon)) + * [#3726](https://github.com/facebookincubator/create-react-app/pull/3726) Use proxy for all request methods other than `GET`. ([@doshisid](https://github.com/doshisid)) + * [#3440](https://github.com/facebookincubator/create-react-app/pull/3440) Print full directory name from `lsof`. ([@rmccue](https://github.com/rmccue)) + * [#2071](https://github.com/facebookincubator/create-react-app/pull/2071) Fix broken console clearing on Windows. ([@danielverejan](https://github.com/danielverejan)) + * [#3686](https://github.com/facebookincubator/create-react-app/pull/3686) Fix starting a project in directory with `++` in the name. ([@Norris1z](https://github.com/Norris1z)) + +* `create-react-app` + + * [#3320](https://github.com/facebookincubator/create-react-app/pull/3320) Fix offline installation to respect proxy from `.npmrc`. ([@mdogadailo](https://github.com/mdogadailo)) + +* `react-scripts` + + * [#3537](https://github.com/facebookincubator/create-react-app/pull/3537) Add `mjs` and `jsx` filename extensions to `file-loader` exclude pattern. ([@iansu](https://github.com/iansu)) + * [#3511](https://github.com/facebookincubator/create-react-app/pull/3511) Unmount the component in the default generated test. ([@gaearon](https://github.com/gaearon)) + +#### :nail_care: Enhancement + +* `react-scripts` + + * [#3730](https://github.com/facebookincubator/create-react-app/pull/3730) Print when `HOST` environment variable is set. ([@iansu](https://github.com/iansu)) + * [#3455](https://github.com/facebookincubator/create-react-app/pull/3455) Add a localhost-only log message pointing folks to the PWA docs. ([@jeffposnick](https://github.com/jeffposnick)) + * [#3416](https://github.com/facebookincubator/create-react-app/pull/3416) Improve eject message. ([@xjlim](https://github.com/xjlim)) + +* `create-react-app` + + * [#3740](https://github.com/facebookincubator/create-react-app/pull/3740) Allow more non-conflicting files in initial project directory. ([@GreenGremlin](https://github.com/GreenGremlin)) + +* `react-dev-utils` + + * [#3104](https://github.com/facebookincubator/create-react-app/pull/3104) Add link to deployment docs after build. ([@viankakrisna](https://github.com/viankakrisna)) + * [#3652](https://github.com/facebookincubator/create-react-app/pull/3652) Add `code-insiders` to the editor list. ([@shrynx](https://github.com/shrynx)) + * [#3700](https://github.com/facebookincubator/create-react-app/pull/3700) Add editor support for Sublime Dev & VSCode Insiders. ([@yyx990803](https://github.com/yyx990803)) + * [#3545](https://github.com/facebookincubator/create-react-app/pull/3545) Autodetect MacVim editor. ([@gnapse](https://github.com/gnapse)) + +* `react-dev-utils`, `react-error-overlay` + + * [#3465](https://github.com/facebookincubator/create-react-app/pull/3465) Open editor to exact column from build error overlay. ([@tharakawj](https://github.com/tharakawj)) + +* `react-dev-utils`, `react-scripts` + + * [#3721](https://github.com/facebookincubator/create-react-app/pull/3721) Support setting `none` in `REACT_EDITOR` environment variable. ([@raerpo](https://github.com/raerpo)) + +* `eslint-config-react-app` + + * [#3716](https://github.com/facebookincubator/create-react-app/pull/3716) Relax `no-cond-assign` rule. ([@gaearon](https://github.com/gaearon)) + +#### :memo: Documentation + +* User Guide + + * [#3659](https://github.com/facebookincubator/create-react-app/pull/3659) Add info about service-worker and HTTP caching headers into Firebase section. ([@bobrosoft](https://github.com/bobrosoft)) + * [#3515](https://github.com/facebookincubator/create-react-app/pull/3515) Add Powershell commands to README.md. ([@Gua-naiko-che](https://github.com/Gua-naiko-che)) + * [#3656](https://github.com/facebookincubator/create-react-app/pull/3656) Better documentation for setupTests.js when ejecting. ([@dannycalleri](https://github.com/dannycalleri)) + * [#1791](https://github.com/facebookincubator/create-react-app/pull/1791) Add link for automatic deployment to azure. ([@ulrikstrid](https://github.com/ulrikstrid)) + * [#3717](https://github.com/facebookincubator/create-react-app/pull/3717) Update README.md. ([@maecapozzi](https://github.com/maecapozzi)) + * [#3710](https://github.com/facebookincubator/create-react-app/pull/3710) Link to an explanation for forking react-scripts. ([@gaearon](https://github.com/gaearon)) + * [#3709](https://github.com/facebookincubator/create-react-app/pull/3709) Document adding a router. ([@gaearon](https://github.com/gaearon)) + * [#3670](https://github.com/facebookincubator/create-react-app/pull/3670) Fix typo in the User Guide. ([@qbahers](https://github.com/qbahers)) + * [#3645](https://github.com/facebookincubator/create-react-app/pull/3645) Update README.md. ([@elie222](https://github.com/elie222)) + * [#3533](https://github.com/facebookincubator/create-react-app/pull/3533) Use safer/more aesthetic syntax for setting environment variables on Windows. ([@cdanielsen](https://github.com/cdanielsen)) + * [#3605](https://github.com/facebookincubator/create-react-app/pull/3605) Updated Debugging Tests for VSCode. ([@amadeogallardo](https://github.com/amadeogallardo)) + * [#3601](https://github.com/facebookincubator/create-react-app/pull/3601) Fixed typo in webpack.config.dev.js. ([@nmenglund](https://github.com/nmenglund)) + * [#3576](https://github.com/facebookincubator/create-react-app/pull/3576) Updates comment to reflect codebase. ([@rahulcs](https://github.com/rahulcs)) + * [#3510](https://github.com/facebookincubator/create-react-app/pull/3510) Update User Guide with deploying to GitHub User pages. ([@aaronlna](https://github.com/aaronlna)) + * [#3503](https://github.com/facebookincubator/create-react-app/pull/3503) Update Prettier editor integration link. ([@gaving](https://github.com/gaving)) + * [#3453](https://github.com/facebookincubator/create-react-app/pull/3453) Fix dead links. ([@vannio](https://github.com/vannio)) + * [#2992](https://github.com/facebookincubator/create-react-app/pull/2992) Docs: How to Debug Unit Tests. ([@MattMorgis](https://github.com/MattMorgis)) + +* Other + + * [#3729](https://github.com/facebookincubator/create-react-app/pull/3729) Update README.md to note Neutrino's support of react components. ([@eliperelman](https://github.com/eliperelman)) + * [#2841](https://github.com/facebookincubator/create-react-app/pull/2841) Documentation to help windows contributors. ([@Dubes](https://github.com/Dubes)) + * [#3489](https://github.com/facebookincubator/create-react-app/pull/3489) Add link to nvm-windows. ([@davidgilbertson](https://github.com/davidgilbertson)) + +* `eslint-config-react-app` + + * [#3460](https://github.com/facebookincubator/create-react-app/pull/3460) Fix broken link to `href-no-hash` eslint rule. ([@hazolsky](https://github.com/hazolsky)) + +#### :house: Internal + +* Other + + * [#3769](https://github.com/facebookincubator/create-react-app/pull/3769) Enable Yarn check files. ([@Timer](https://github.com/Timer)) + * [#3756](https://github.com/facebookincubator/create-react-app/pull/3756) Clean up changes to npm and yarn registry in E2E tests. ([@viankakrisna](https://github.com/viankakrisna)) + * [#3744](https://github.com/facebookincubator/create-react-app/pull/3744) Use private registry in E2E tests. ([@Timer](https://github.com/Timer)) + * [#3738](https://github.com/facebookincubator/create-react-app/pull/3738) Always use Yarn on CI. ([@gaearon](https://github.com/gaearon)) + * [#2309](https://github.com/facebookincubator/create-react-app/pull/2309) Port `cra.sh` development task to javascript. ([@ianschmitz](https://github.com/ianschmitz)) + * [#3411](https://github.com/facebookincubator/create-react-app/pull/3411) Simplify waiting for app start in E2E tests. ([@xjlim](https://github.com/xjlim)) + * [#3755](https://github.com/facebookincubator/create-react-app/pull/3755) Switch to Yarn Workspaces. ([@gaearon](https://github.com/gaearon)) + * [#3757](https://github.com/facebookincubator/create-react-app/pull/3757) Try updating Flow. ([@gaearon](https://github.com/gaearon)) + * [#3414](https://github.com/facebookincubator/create-react-app/pull/3414) Export `dismissRuntimeErrors` function. ([@skidding](https://github.com/skidding)) + * [#3036](https://github.com/facebookincubator/create-react-app/pull/3036) Cleaning up `printHostingInstructions` a bit. ([@GreenGremlin](https://github.com/GreenGremlin)) + * [#3514](https://github.com/facebookincubator/create-react-app/pull/3514) Fix `FileSizeReporter` for multi build Webpack setups. ([@iiska](https://github.com/iiska)) + * [#3362](https://github.com/facebookincubator/create-react-app/pull/3362) Refactor extra watch options regex to `react-dev-utils`. ([@xjlim](https://github.com/xjlim)) + +#### Committers: 47 + +- Aaron Lamb ([aaronlna](https://github.com/aaronlna)) +- Ade Viankakrisna Fadlil ([viankakrisna](https://github.com/viankakrisna)) +- Amadeo Gallardo ([amadeogallardo](https://github.com/amadeogallardo)) +- Andy Kenward ([andykenward](https://github.com/andykenward)) +- Christian Danielsen ([cdanielsen](https://github.com/cdanielsen)) +- Clayton Ray ([iamclaytonray](https://github.com/iamclaytonray)) +- Dan Abramov ([gaearon](https://github.com/gaearon)) +- Daniel Verejan ([danielverejan](https://github.com/danielverejan)) +- Danny Calleri ([dannycalleri](https://github.com/dannycalleri)) +- David Boyne ([boyney123](https://github.com/boyney123)) +- David Gilbertson ([davidgilbertson](https://github.com/davidgilbertson)) +- Eli Perelman ([eliperelman](https://github.com/eliperelman)) +- Elie ([elie222](https://github.com/elie222)) +- Ernesto García ([gnapse](https://github.com/gnapse)) +- Evan You ([yyx990803](https://github.com/yyx990803)) +- Gavin Gilmour ([gaving](https://github.com/gaving)) +- Ian Schmitz ([ianschmitz](https://github.com/ianschmitz)) +- Ian Sutherland ([iansu](https://github.com/iansu)) +- JANG SUN HYUK ([wkdtjsgur100](https://github.com/wkdtjsgur100)) +- Jeffrey Posnick ([jeffposnick](https://github.com/jeffposnick)) +- Joe Haddad ([Timer](https://github.com/Timer)) +- Joe Lim ([xjlim](https://github.com/xjlim)) +- Jonathan ([GreenGremlin](https://github.com/GreenGremlin)) +- Juhamatti Niemelä ([iiska](https://github.com/iiska)) +- Mae Capozzi ([maecapozzi](https://github.com/maecapozzi)) +- Maksym Dogadailo ([mdogadailo](https://github.com/mdogadailo)) +- Mario Nebl ([marionebl](https://github.com/marionebl)) +- Matt Morgis ([MattMorgis](https://github.com/MattMorgis)) +- Misha Khokhlov ([hazolsky](https://github.com/hazolsky)) +- Moos ([moos](https://github.com/moos)) +- Nils Magnus Englund ([nmenglund](https://github.com/nmenglund)) +- Norris Oduro ([Norris1z](https://github.com/Norris1z)) +- Ovidiu Cherecheș ([skidding](https://github.com/skidding)) +- Quentin Bahers ([qbahers](https://github.com/qbahers)) +- Rafael E. Poveda ([raerpo](https://github.com/raerpo)) +- Rahul Chanila ([rahulcs](https://github.com/rahulcs)) +- Ryan McCue ([rmccue](https://github.com/rmccue)) +- Sascha Dens ([SaschaDens](https://github.com/SaschaDens)) +- Siddharth Doshi ([doshisid](https://github.com/doshisid)) +- Tao Gómez Gil ([Gua-naiko-che](https://github.com/Gua-naiko-che)) +- Tharaka Wijebandara ([tharakawj](https://github.com/tharakawj)) +- Trevor Brindle ([tabrindle](https://github.com/tabrindle)) +- Ulrik Strid ([ulrikstrid](https://github.com/ulrikstrid)) +- Vladimir Tolstikov ([bobrosoft](https://github.com/bobrosoft)) +- [Dubes](https://github.com/Dubes) +- [vannio](https://github.com/vannio) +- shrynx ([shrynx](https://github.com/shrynx)) + +### Migrating from 1.0.17 to 1.1.0 + +Inside any created project that has not been ejected, run: + +``` +npm install --save --save-exact react-scripts@1.1.0 +``` + +or + +``` +yarn add --exact react-scripts@1.1.0 +``` + ## 1.0.17 (November 3, 2017) #### :nail_care: Enhancement From e73a783ef1f0deec3401f1d0c853a30b6c88bf71 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 15 Jan 2018 00:53:37 +0000 Subject: [PATCH 0509/1739] Publish - babel-preset-react-app@3.1.1 - create-react-app@1.5.0 - eslint-config-react-app@2.1.0 - react-dev-utils@5.0.0 - react-error-overlay@4.0.0 - react-scripts@1.1.0 --- packages/babel-preset-react-app/package.json | 2 +- packages/create-react-app/package.json | 2 +- packages/eslint-config-react-app/package.json | 2 +- packages/react-dev-utils/package.json | 4 ++-- packages/react-error-overlay/package.json | 6 +++--- packages/react-scripts/package.json | 8 ++++---- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index 23c22142334..c6a7e29441d 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.1.0", + "version": "3.1.1", "description": "Babel preset used by Create React App", "repository": "facebookincubator/create-react-app", "license": "MIT", diff --git a/packages/create-react-app/package.json b/packages/create-react-app/package.json index 1b3b60aac80..65ab56a1698 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.4.3", + "version": "1.5.0", "keywords": [ "react" ], diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index a10ef679952..c13b0417c46 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": "2.0.1", + "version": "2.1.0", "description": "ESLint configuration used by Create React App", "repository": "facebookincubator/create-react-app", "license": "MIT", diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index d4b933f7183..18f37c971e4 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "react-dev-utils", - "version": "4.2.1", + "version": "5.0.0", "description": "Webpack utilities used by Create React App", "repository": "facebookincubator/create-react-app", "license": "MIT", @@ -48,7 +48,7 @@ "inquirer": "3.3.0", "is-root": "1.0.0", "opn": "5.2.0", - "react-error-overlay": "^3.0.0", + "react-error-overlay": "^4.0.0", "recursive-readdir": "2.2.1", "shell-quote": "1.6.1", "sockjs-client": "1.1.4", diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 9808a9da81d..87099dd5e82 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -1,6 +1,6 @@ { "name": "react-error-overlay", - "version": "3.0.0", + "version": "4.0.0", "description": "An overlay for displaying stack frames.", "main": "lib/index.js", "scripts": { @@ -35,13 +35,13 @@ "babel-core": "^6.26.0", "babel-eslint": "7.2.3", "babel-loader": "^7.1.2", - "babel-preset-react-app": "^3.1.0", + "babel-preset-react-app": "^3.1.1", "babel-runtime": "6.26.0", "chalk": "^2.1.0", "chokidar": "^1.7.0", "cross-env": "5.0.5", "eslint": "4.4.1", - "eslint-config-react-app": "^2.0.1", + "eslint-config-react-app": "^2.1.0", "eslint-plugin-flowtype": "2.35.0", "eslint-plugin-import": "2.7.0", "eslint-plugin-jsx-a11y": "5.1.1", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index f6bff1deaa6..91d4a584cf4 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts", - "version": "1.0.17", + "version": "1.1.0", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", "license": "MIT", @@ -26,7 +26,7 @@ "babel-eslint": "7.2.3", "babel-jest": "20.0.3", "babel-loader": "7.1.2", - "babel-preset-react-app": "^3.1.0", + "babel-preset-react-app": "^3.1.1", "babel-runtime": "6.26.0", "case-sensitive-paths-webpack-plugin": "2.1.1", "chalk": "1.1.3", @@ -34,7 +34,7 @@ "dotenv": "4.0.0", "dotenv-expand": "4.0.1", "eslint": "4.10.0", - "eslint-config-react-app": "^2.0.1", + "eslint-config-react-app": "^2.1.0", "eslint-loader": "1.9.0", "eslint-plugin-flowtype": "2.39.1", "eslint-plugin-import": "2.8.0", @@ -50,7 +50,7 @@ "postcss-loader": "2.0.8", "promise": "8.0.1", "raf": "3.4.0", - "react-dev-utils": "^4.2.1", + "react-dev-utils": "^5.0.0", "style-loader": "0.19.0", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.6.2", From d9799641268dfadffb625af68ce0a78895147728 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 15 Jan 2018 00:55:15 +0000 Subject: [PATCH 0510/1739] Tweak publishing note --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 62908c39b6b..72994ebbf68 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -121,7 +121,7 @@ By default git would use `CRLF` line endings which would cause the scripts to fa * Add a four-space indented paragraph after each non-trivial list item, explaining what changed and why. For each breaking change also write who it affects and instructions for migrating existing code. * Maybe add some newlines here and there. Preview the result on GitHub to get a feel for it. Changelog generator output is a bit too terse for my taste, so try to make it visually pleasing and well grouped. 6. Make sure to include “Migrating from ...” instructions for the previous release. Often you can copy and paste them. -7. Run `yarn run publish`. (Don’t forget the `run` there.) +7. Run `npm run publish`. (It has to be `npm run publish` exactly, not just `npm publish` or `yarn publish`.) 8. Wait for a long time, and it will get published. Don’t worry that it’s stuck. In the end the publish script will prompt for versions before publishing the packages. 9. After publishing, create a GitHub Release with the same text as the changelog entry. See previous Releases for inspiration. From ff544949b904cf4d2ea5fe926fd25ff367a59999 Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil Date: Thu, 11 Jan 2018 09:59:42 +0700 Subject: [PATCH 0511/1739] Use uglifyjs-webpack-plugin v1 (#3618) --- .../config/webpack.config.prod.js | 42 +++++++++++-------- packages/react-scripts/package.json | 1 + 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 3b2a2068db2..e1d4bc14a28 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -12,6 +12,7 @@ const autoprefixer = require('autoprefixer'); const path = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); +const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const ManifestPlugin = require('webpack-manifest-plugin'); const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); @@ -290,24 +291,31 @@ module.exports = { // Otherwise React will be compiled in the very slow development mode. new webpack.DefinePlugin(env.stringified), // Minify the code. - new webpack.optimize.UglifyJsPlugin({ - compress: { - warnings: false, - // Disabled because of an issue with Uglify breaking seemingly valid code: - // https://github.com/facebookincubator/create-react-app/issues/2376 - // Pending further investigation: - // https://github.com/mishoo/UglifyJS2/issues/2011 - comparisons: false, - }, - mangle: { - safari10: true, - }, - output: { - comments: false, - // Turned on because emoji and regex is not minified properly using default - // https://github.com/facebookincubator/create-react-app/issues/2488 - ascii_only: true, + new UglifyJsPlugin({ + uglifyOptions: { + compress: { + warnings: false, + // Disabled because of an issue with Uglify breaking seemingly valid code: + // https://github.com/facebookincubator/create-react-app/issues/2376 + // Pending further investigation: + // https://github.com/mishoo/UglifyJS2/issues/2011 + comparisons: false, + }, + mangle: { + safari10: true, + }, + output: { + comments: false, + // Turned on because emoji and regex is not minified properly using default + // https://github.com/facebookincubator/create-react-app/issues/2488 + ascii_only: true, + }, }, + // Use multi-process parallel running to improve the build speed + // Default number of concurrent runs: os.cpus().length - 1 + parallel: true, + // Enable file caching + cache: true, sourceMap: shouldUseSourceMap, }), // Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`. diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 91d4a584cf4..6abfd73490c 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -53,6 +53,7 @@ "react-dev-utils": "^5.0.0", "style-loader": "0.19.0", "sw-precache-webpack-plugin": "0.11.4", + "uglifyjs-webpack-plugin": "1.1.4", "url-loader": "0.6.2", "webpack": "3.8.1", "webpack-dev-server": "2.9.4", From 1f18ab7879dff957efe51d342be8ece71a0b43b9 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Wed, 10 Jan 2018 22:20:33 -0500 Subject: [PATCH 0512/1739] Specify ecma version (#3743) --- packages/react-scripts/config/webpack.config.prod.js | 1 + packages/react-scripts/package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index e1d4bc14a28..b99db8a27ef 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -293,6 +293,7 @@ module.exports = { // Minify the code. new UglifyJsPlugin({ uglifyOptions: { + ecma: 5, compress: { warnings: false, // Disabled because of an issue with Uglify breaking seemingly valid code: diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 6abfd73490c..bc1f07b34c1 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -53,7 +53,7 @@ "react-dev-utils": "^5.0.0", "style-loader": "0.19.0", "sw-precache-webpack-plugin": "0.11.4", - "uglifyjs-webpack-plugin": "1.1.4", + "uglifyjs-webpack-plugin": "1.1.6", "url-loader": "0.6.2", "webpack": "3.8.1", "webpack-dev-server": "2.9.4", From 0a331710aa8cc8d9c76e17b06066eec5779ead1c Mon Sep 17 00:00:00 2001 From: Andrey Sitnik Date: Wed, 10 Jan 2018 02:39:13 +1000 Subject: [PATCH 0513/1739] Move browsers to cross-tool config (#3644) --- packages/react-scripts/config/webpack.config.dev.js | 6 ------ packages/react-scripts/config/webpack.config.prod.js | 6 ------ packages/react-scripts/scripts/init.js | 7 +++++++ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 9f3131b0660..843ec0dd318 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -200,12 +200,6 @@ module.exports = { plugins: () => [ require('postcss-flexbugs-fixes'), autoprefixer({ - browsers: [ - '>1%', - 'last 4 versions', - 'Firefox ESR', - 'not ie < 9', // React doesn't support IE8 anyway - ], flexbox: 'no-2009', }), ], diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index b99db8a27ef..2f37dbfe7f4 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -222,12 +222,6 @@ module.exports = { plugins: () => [ require('postcss-flexbugs-fixes'), autoprefixer({ - browsers: [ - '>1%', - 'last 4 versions', - 'Firefox ESR', - 'not ie < 9', // React doesn't support IE8 anyway - ], flexbox: 'no-2009', }), ], diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index b283bad6ee6..27b214e6431 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -43,6 +43,13 @@ module.exports = function( eject: 'react-scripts eject', }; + appPackage.browserslist = [ + '>1%', + 'last 4 versions', + 'Firefox ESR', + 'not ie < 9', + ]; + fs.writeFileSync( path.join(appPath, 'package.json'), JSON.stringify(appPackage, null, 2) From 3c3547f9428fc6d4ef4251f6a689de91b0b9c9df Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Tue, 9 Jan 2018 09:53:42 -0700 Subject: [PATCH 0514/1739] add experimental babel-plugin-macros support (#3675) * add experimental babel-plugin-macros support closes #2730 This will remain undocumented until the brave have tried it in the wild. **Test Plan:** There's currently no established way to test changes to `babel-preset-react-app`. But I did create [`unmaintained-react-scripts-babel-macros`](https://www.npmjs.com/package/unmaintained-react-scripts-babel-macros) [a while back](https://github.com/facebookincubator/create-react-app/issues/2730#issuecomment-328153982) and it worked well. * Pin the version --- packages/babel-preset-react-app/index.js | 3 +++ packages/babel-preset-react-app/package.json | 1 + 2 files changed, 4 insertions(+) diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index d90fb6af50b..d1639dd2161 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -7,6 +7,9 @@ 'use strict'; const plugins = [ + // Experimental macros support. Will be documented after it's had some time + // in the wild. + require.resolve('babel-plugin-macros'), // Necessary to include regardless of the environment because // in practice some other transforms (such as object-rest-spread) // don't work without it: https://github.com/babel/babel/issues/7215 diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index c6a7e29441d..108e1ea3cfa 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -12,6 +12,7 @@ ], "dependencies": { "babel-plugin-dynamic-import-node": "1.1.0", + "babel-plugin-macros": "2.0.0", "babel-plugin-syntax-dynamic-import": "6.18.0", "babel-plugin-transform-class-properties": "6.24.1", "babel-plugin-transform-es2015-destructuring": "6.23.0", From 813584ff35bc850383e4b075b7aa712b24ade993 Mon Sep 17 00:00:00 2001 From: everdimension Date: Wed, 10 Jan 2018 04:38:54 +0300 Subject: [PATCH 0515/1739] Redisable require.ensure() (#3121) --- packages/eslint-config-react-app/index.js | 13 ++++++------- packages/react-scripts/config/webpack.config.dev.js | 5 ++--- .../react-scripts/config/webpack.config.prod.js | 5 ++--- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index c7a619abd62..9b687663da9 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -225,13 +225,12 @@ module.exports = { 'valid-typeof': 'warn', 'no-restricted-properties': [ 'error', - // TODO: reenable once import() is no longer slow. - // https://github.com/facebookincubator/create-react-app/issues/2176 - // { - // object: 'require', - // property: 'ensure', - // message: 'Please use import() instead. More info: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting', - // }, + { + object: 'require', + property: 'ensure', + message: + 'Please use import() instead. More info: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting', + }, { object: 'System', property: 'import', diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 843ec0dd318..b509af97054 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -117,9 +117,8 @@ module.exports = { module: { strictExportPresence: true, rules: [ - // TODO: Disable require.ensure as it's not a standard language feature. - // We are waiting for https://github.com/facebookincubator/create-react-app/issues/2176. - // { parser: { requireEnsure: false } }, + // Disable require.ensure as it's not a standard language feature. + { parser: { requireEnsure: false } }, // First, run the linter. // It's important to do this before Babel processes the JS. diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 2f37dbfe7f4..d3673a723b5 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -124,9 +124,8 @@ module.exports = { module: { strictExportPresence: true, rules: [ - // TODO: Disable require.ensure as it's not a standard language feature. - // We are waiting for https://github.com/facebookincubator/create-react-app/issues/2176. - // { parser: { requireEnsure: false } }, + // Disable require.ensure as it's not a standard language feature. + { parser: { requireEnsure: false } }, // First, run the linter. // It's important to do this before Babel processes the JS. From b6aebb9e8f2e1bb049e855e739e578bd00d90021 Mon Sep 17 00:00:00 2001 From: Jeffrey Posnick Date: Tue, 9 Jan 2018 21:08:39 -0500 Subject: [PATCH 0516/1739] Remove the navigateFallback behavior from the generated service worker (#3419) * Disables navigateFallback and updates the README * Typos * Updated a URL in a comment. --- .../config/webpack.config.prod.js | 9 ++-- packages/react-scripts/template/README.md | 47 ++++++++++++++----- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index d3673a723b5..dea5b99eac6 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -344,13 +344,12 @@ module.exports = { console.log(message); }, minify: true, - // For unknown URLs, fallback to the index page - navigateFallback: publicUrl + '/index.html', - // Ignores URLs starting from /__ (useful for Firebase): - // https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219 - navigateFallbackWhitelist: [/^(?!\/__).*/], // Don't precache sourcemaps (they're large) and build asset manifest: staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/], + // `navigateFallback` and `navigateFallbackWhitelist` are disabled by default; see + // https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#service-worker-considerations + // navigateFallback: publicUrl + '/index.html', + // navigateFallbackWhitelist: [/^(?!\/__).*/], }), // Moment.js is an extremely popular library that bundles large locale files // by default due to how Webpack interprets its code. This is a practical diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 7c641456056..ee0860f0b6b 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -83,6 +83,7 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Static Server](#static-server) - [Other Solutions](#other-solutions) - [Serving Apps with Client-Side Routing](#serving-apps-with-client-side-routing) + - [Service Worker Considerations](#service-worker-considerations) - [Building for Relative Paths](#building-for-relative-paths) - [Azure](#azure) - [Firebase](#firebase) @@ -1791,8 +1792,14 @@ is integrated into production configuration, and it will take care of generating a service worker file that will automatically precache all of your local assets and keep them up to date as you deploy updates. The service worker will use a [cache-first strategy](https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network) -for handling all requests for local assets, including the initial HTML, ensuring -that your web app is reliably fast, even on a slow or unreliable network. +for handling all requests for local assets, including +[navigation requests](https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests) +for `/` and `/index.html`, ensuring that your web app is consistently fast, even +on a slow or unreliable network. + +>Note: If you are using the `pushState` history API and want to enable +cache-first navigations for URLs other than `/` and `/index.html`, please +[follow these steps](#service-worker-considerations). ### Opting Out of Caching @@ -1995,21 +2002,37 @@ If you’re using [Apache Tomcat](http://tomcat.apache.org/), you need to follow Now requests to `/todos/42` will be handled correctly both in development and in production. -On a production build, and in a browser that supports [service workers](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers), -the service worker will automatically handle all navigation requests, like for -`/todos/42`, by serving the cached copy of your `index.html`. This -service worker navigation routing can be configured or disabled by -[`eject`ing](#npm-run-eject) and then modifying the -[`navigateFallback`](https://github.com/GoogleChrome/sw-precache#navigatefallback-string) -and [`navigateFallbackWhitelist`](https://github.com/GoogleChrome/sw-precache#navigatefallbackwhitelist-arrayregexp) -options of the `SWPreachePlugin` [configuration](../config/webpack.config.prod.js). - -When users install your app to the homescreen of their device the default configuration will make a shortcut to `/index.html`. This may not work for client-side routers which expect the app to be served from `/`. Edit the web app manifest at [`public/manifest.json`](public/manifest.json) and change `start_url` to match the required URL scheme, for example: +When users install your app to the homescreen of their device the default +configuration will make a shortcut to `/index.html`. This may not work for +client-side routers which expect the app to be served from `/`. Edit the web app +manifest at [`public/manifest.json`](public/manifest.json) and change +`start_url` to match the required URL scheme, for example: ```js "start_url": ".", ``` +### Service Worker Considerations + +[Navigation requests](https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests) +for URLs like `/todos/42` will not be intercepted by the +[service worker](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers) +created by the production build. Navigations for those URLs will always +require a network connection, as opposed to navigations for `/` and +`/index.html`, both of which will be served from the cache by the service worker +and work without requiring a network connection. + +If you are using the `pushState` history API and would like to enable service +worker support for navigations to URLs like `/todos/42`, you need to +[`npm eject`](#npm-run-eject) and enable the +[`navigateFallback`](https://github.com/GoogleChrome/sw-precache#navigatefallback-string) +and [`navigateFallbackWhitelist`](https://github.com/GoogleChrome/sw-precache#navigatefallbackwhitelist-arrayregexp) +options of the `SWPreachePlugin` [configuration](../config/webpack.config.prod.js). + +>Note: This is a [change in default behavior](https://github.com/facebookincubator/create-react-app/issues/3248), +as earlier versions of `create-react-app` shipping with `navigateFallback` +enabled by default. + ### Building for Relative Paths By default, Create React App produces a build assuming your app is hosted at the server root.
From 3c79497eb016d02d6cf85e8b9dcec96b5fa2bb20 Mon Sep 17 00:00:00 2001 From: Rami Date: Wed, 10 Jan 2018 15:49:34 +0000 Subject: [PATCH 0517/1739] Change the default `start_url` to `.` (#3346) --- packages/react-scripts/template/README.md | 13 ++----------- .../react-scripts/template/public/manifest.json | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index ee0860f0b6b..044ccc0ecdd 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -2002,15 +2002,7 @@ If you’re using [Apache Tomcat](http://tomcat.apache.org/), you need to follow Now requests to `/todos/42` will be handled correctly both in development and in production. -When users install your app to the homescreen of their device the default -configuration will make a shortcut to `/index.html`. This may not work for -client-side routers which expect the app to be served from `/`. Edit the web app -manifest at [`public/manifest.json`](public/manifest.json) and change -`start_url` to match the required URL scheme, for example: - -```js - "start_url": ".", -``` +When users install your app to the homescreen of their device the default configuration will make a shortcut to `/`. This may not work if you don't use a client-side router and expect the app to be served from `/index.html`. In this case, the web app manifest at [`public/manifest.json`](public/manifest.json) and change `start_url` to `./index.html`. ### Service Worker Considerations @@ -2024,8 +2016,7 @@ and work without requiring a network connection. If you are using the `pushState` history API and would like to enable service worker support for navigations to URLs like `/todos/42`, you need to -[`npm eject`](#npm-run-eject) and enable the -[`navigateFallback`](https://github.com/GoogleChrome/sw-precache#navigatefallback-string) +[`npm eject`](#npm-run-eject) and enable the [`navigateFallback`](https://github.com/GoogleChrome/sw-precache#navigatefallback-string) and [`navigateFallbackWhitelist`](https://github.com/GoogleChrome/sw-precache#navigatefallbackwhitelist-arrayregexp) options of the `SWPreachePlugin` [configuration](../config/webpack.config.prod.js). diff --git a/packages/react-scripts/template/public/manifest.json b/packages/react-scripts/template/public/manifest.json index ef19ec243e7..1f2f141fafd 100644 --- a/packages/react-scripts/template/public/manifest.json +++ b/packages/react-scripts/template/public/manifest.json @@ -8,7 +8,7 @@ "type": "image/x-icon" } ], - "start_url": "./index.html", + "start_url": ".", "display": "standalone", "theme_color": "#000000", "background_color": "#ffffff" From 776d2d6036a32172a310e8dd05c9ad2c71443470 Mon Sep 17 00:00:00 2001 From: aisensiy Date: Thu, 11 Jan 2018 15:49:30 +0800 Subject: [PATCH 0518/1739] Update jest to 22 and support watchPathIgnorePatterns configuration (#3124) * update jest to 21.0.2 to support watchPathIgnorePatterns configuration * update jest to 21.1.0 * Try bumping Jest * Bump babel-jest * Try to debug weird CI failure * Remove debug code * Bump other Jest packages * ffs * temp * Revert "temp" This reverts commit 62aec9ac1ae70a995a89548feb7ac7870e5324c0. --- packages/react-dev-utils/package.json | 2 +- packages/react-error-overlay/package.json | 2 +- packages/react-scripts/package.json | 4 ++-- packages/react-scripts/scripts/utils/createJestConfig.js | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 18f37c971e4..d589710e67d 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -56,7 +56,7 @@ "text-table": "0.2.0" }, "devDependencies": { - "jest": "20.0.4" + "jest": "22.0.5" }, "scripts": { "test": "jest" diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 87099dd5e82..208be0d4017 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -48,7 +48,7 @@ "eslint-plugin-react": "7.1.0", "flow-bin": "^0.63.1", "html-entities": "1.2.1", - "jest": "20.0.4", + "jest": "22.0.5", "jest-fetch-mock": "1.2.1", "object-assign": "4.1.1", "promise": "8.0.1", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index bc1f07b34c1..59c6be2d13f 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -24,7 +24,7 @@ "autoprefixer": "7.1.6", "babel-core": "6.26.0", "babel-eslint": "7.2.3", - "babel-jest": "20.0.3", + "babel-jest": "22.0.4", "babel-loader": "7.1.2", "babel-preset-react-app": "^3.1.1", "babel-runtime": "6.26.0", @@ -44,7 +44,7 @@ "file-loader": "1.1.5", "fs-extra": "3.0.1", "html-webpack-plugin": "2.29.0", - "jest": "20.0.4", + "jest": "22.0.5", "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.2.0", "postcss-loader": "2.0.8", diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index b4c2cfa5ea9..4c2e6f1d002 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -62,6 +62,7 @@ module.exports = (resolve, rootDir, isEjecting) => { 'coverageReporters', 'coverageThreshold', 'snapshotSerializers', + 'watchPathIgnorePatterns', ]; if (overrides) { supportedKeys.forEach(key => { From 590df7eead1a2526828aa36ceff41397e82bd4dd Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 11 Jan 2018 14:14:17 +0000 Subject: [PATCH 0519/1739] Bump Jest to 22.0.6 (#3751) --- packages/react-dev-utils/package.json | 2 +- packages/react-error-overlay/package.json | 2 +- packages/react-scripts/package.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index d589710e67d..24f851b1cfc 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -56,7 +56,7 @@ "text-table": "0.2.0" }, "devDependencies": { - "jest": "22.0.5" + "jest": "22.0.6" }, "scripts": { "test": "jest" diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 208be0d4017..c6cbfeca108 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -48,7 +48,7 @@ "eslint-plugin-react": "7.1.0", "flow-bin": "^0.63.1", "html-entities": "1.2.1", - "jest": "22.0.5", + "jest": "22.0.6", "jest-fetch-mock": "1.2.1", "object-assign": "4.1.1", "promise": "8.0.1", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 59c6be2d13f..0b2f62eb825 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -24,7 +24,7 @@ "autoprefixer": "7.1.6", "babel-core": "6.26.0", "babel-eslint": "7.2.3", - "babel-jest": "22.0.4", + "babel-jest": "22.0.6", "babel-loader": "7.1.2", "babel-preset-react-app": "^3.1.1", "babel-runtime": "6.26.0", @@ -44,7 +44,7 @@ "file-loader": "1.1.5", "fs-extra": "3.0.1", "html-webpack-plugin": "2.29.0", - "jest": "22.0.5", + "jest": "22.0.6", "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.2.0", "postcss-loader": "2.0.8", From 1552949a3bce629de9e6fde1794e01c07226bf9c Mon Sep 17 00:00:00 2001 From: Clement Hoang Date: Thu, 11 Jan 2018 18:42:33 -0500 Subject: [PATCH 0520/1739] Switch to Babel 7 (#3522) * Update dependencies in react-scripts * Add first pass of working dependencies for babel-preset-react-app and react-scripts * Bump more dependency versions * Adjust more versions and edit fix options * Restore functionality of old preset * Disable Uglify in iframe webpack * Apply prettier * Re-enable cache in dev and clean deps * Lock packages and move babel/core to dep in preset * Bump babel-jest * Re-enable uglify * Nest forceAllTransforms correctly in webpack config * Install babel-core bridge for jest * Add jest-cli and babel-core bridge to make tests in react-error-overlay pass * Re-enable transform-dynamic-import * Add dynamic import syntax support back * Use new babel in kitchensink * Transform modules in test * Revert "Transform modules in test" This reverts commit 539e46a1d77259898b7e70d778a5e43fc25edc2a. * Attempt fix for ejected tests * try this * Add regenerator back * Bump babel deps to beta.34 * Remove bad files * Use default when requiring babel transform plugin * Bump deps * Try the fix? * Oopsie * Remove some weird things * Run Babel on react-error-overlay tests * Try fixing kitchensink * Use new API for codeFrame * Add missing (?) babelrc * Maybe this helps? * Maybe fix mocha * I shouldn't have deleted this :facepalm: --- packages/babel-preset-react-app/index.js | 195 ++++++++---------- packages/babel-preset-react-app/package.json | 30 ++- packages/eslint-config-react-app/package.json | 2 +- packages/react-dev-utils/package.json | 2 +- packages/react-error-overlay/package.json | 12 +- .../src/containers/StackFrameCodeBlock.js | 15 +- .../webpack.config.iframe.js | 19 +- .../config/webpack.config.dev.js | 6 +- .../config/webpack.config.prod.js | 6 +- .../fixtures/kitchensink/.babelrc | 4 - .../kitchensink/.template.dependencies.json | 6 +- packages/react-scripts/package.json | 9 +- tasks/e2e-kitchensink.sh | 25 ++- tasks/replace-own-deps.js | 10 +- 14 files changed, 178 insertions(+), 163 deletions(-) delete mode 100644 packages/react-scripts/fixtures/kitchensink/.babelrc diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index d1639dd2161..1a153606e2a 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -6,138 +6,117 @@ */ 'use strict'; -const plugins = [ - // Experimental macros support. Will be documented after it's had some time - // in the wild. - require.resolve('babel-plugin-macros'), - // Necessary to include regardless of the environment because - // in practice some other transforms (such as object-rest-spread) - // don't work without it: https://github.com/babel/babel/issues/7215 - require.resolve('babel-plugin-transform-es2015-destructuring'), - // class { handleClick = () => { } } - require.resolve('babel-plugin-transform-class-properties'), - // The following two plugins use Object.assign directly, instead of Babel's - // extends helper. Note that this assumes `Object.assign` is available. - // { ...todo, completed: true } - [ - require.resolve('babel-plugin-transform-object-rest-spread'), - { - useBuiltIns: true, - }, - ], - // Transforms JSX - [ - require.resolve('babel-plugin-transform-react-jsx'), - { - useBuiltIns: true, - }, - ], - // Polyfills the runtime needed for async/await and generators - [ - require.resolve('babel-plugin-transform-runtime'), - { - helpers: false, - polyfill: false, - regenerator: true, - }, - ], -]; - -// This is similar to how `env` works in Babel: -// https://babeljs.io/docs/usage/babelrc/#env-option -// We are not using `env` because it’s ignored in versions > babel-core@6.10.4: -// https://github.com/babel/babel/issues/4539 -// https://github.com/facebookincubator/create-react-app/issues/720 -// It’s also nice that we can enforce `NODE_ENV` being specified. -var env = process.env.BABEL_ENV || process.env.NODE_ENV; -if (env !== 'development' && env !== 'test' && env !== 'production') { - throw new Error( - 'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or ' + - '`BABEL_ENV` environment variables. Valid values are "development", ' + - '"test", and "production". Instead, received: ' + - JSON.stringify(env) + - '.' - ); -} +module.exports = function(api, opts) { + if (!opts) { + opts = {}; + } -if (env === 'development' || env === 'test') { - // The following two plugins are currently necessary to make React warnings - // include more valuable information. They are included here because they are - // currently not enabled in babel-preset-react. See the below threads for more info: - // https://github.com/babel/babel/issues/4702 - // https://github.com/babel/babel/pull/3540#issuecomment-228673661 - // https://github.com/facebookincubator/create-react-app/issues/989 - plugins.push.apply(plugins, [ - // Adds component stack to warning messages - require.resolve('babel-plugin-transform-react-jsx-source'), - // Adds __self attribute to JSX which React will use for some warnings - require.resolve('babel-plugin-transform-react-jsx-self'), - ]); -} + // This is similar to how `env` works in Babel: + // https://babeljs.io/docs/usage/babelrc/#env-option + // We are not using `env` because it’s ignored in versions > babel-core@6.10.4: + // https://github.com/babel/babel/issues/4539 + // https://github.com/facebookincubator/create-react-app/issues/720 + // It’s also nice that we can enforce `NODE_ENV` being specified. + var env = process.env.BABEL_ENV || process.env.NODE_ENV; + var isEnvDevelopment = env === 'development'; + var isEnvProduction = env === 'production'; + var isEnvTest = env === 'test'; + if (!isEnvDevelopment && !isEnvProduction && !isEnvTest) { + throw new Error( + 'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or ' + + '`BABEL_ENV` environment variables. Valid values are "development", ' + + '"test", and "production". Instead, received: ' + + JSON.stringify(env) + + '.' + ); + } -if (env === 'test') { - module.exports = { + return { presets: [ - // ES features necessary for user's Node version - [ - require('babel-preset-env').default, + isEnvTest && [ + // ES features necessary for user's Node version + require('@babel/preset-env').default, { targets: { - node: 'current', + node: '6.12', }, }, ], - // JSX, Flow - require.resolve('babel-preset-react'), - ], - plugins: plugins.concat([ - // Compiles import() to a deferred require() - require.resolve('babel-plugin-dynamic-import-node'), - ]), - }; -} else { - module.exports = { - presets: [ - // Latest stable ECMAScript features - [ - require.resolve('babel-preset-env'), + (isEnvProduction || isEnvDevelopment) && [ + // Latest stable ECMAScript features + require('@babel/preset-env').default, { targets: { // React parses on ie 9, so we should too ie: 9, - // We currently minify with uglify - // Remove after https://github.com/mishoo/UglifyJS2/issues/448 - uglify: true, }, + // We currently minify with uglify + // Remove after https://github.com/mishoo/UglifyJS2/issues/448 + forceAllTransforms: true, // Disable polyfill transforms useBuiltIns: false, // Do not transform modules to CJS modules: false, }, ], - // JSX, Flow - require.resolve('babel-preset-react'), - ], - plugins: plugins.concat([ - // function* () { yield 42; yield 43; } [ - require.resolve('babel-plugin-transform-regenerator'), + require('@babel/preset-react').default, + { + // Adds component stack to warning messages + // Adds __self attribute to JSX which React will use for some warnings + development: isEnvDevelopment || isEnvTest, + }, + ], + [require('@babel/preset-flow').default], + ].filter(Boolean), + plugins: [ + // Experimental macros support. Will be documented after it's had some time + // in the wild. + require('babel-plugin-macros'), + // Necessary to include regardless of the environment because + // in practice some other transforms (such as object-rest-spread) + // don't work without it: https://github.com/babel/babel/issues/7215 + require('@babel/plugin-transform-destructuring').default, + // class { handleClick = () => { } } + require('@babel/plugin-proposal-class-properties').default, + // The following two plugins use Object.assign directly, instead of Babel's + // extends helper. Note that this assumes `Object.assign` is available. + // { ...todo, completed: true } + [ + require('@babel/plugin-proposal-object-rest-spread').default, + { + useBuiltIns: true, + }, + ], + // Transforms JSX + [ + require('@babel/plugin-transform-react-jsx').default, + { + useBuiltIns: true, + }, + ], + // Polyfills the runtime needed for async/await and generators + [ + require('@babel/plugin-transform-runtime').default, + { + helpers: false, + polyfill: false, + regenerator: true, + }, + ], + // function* () { yield 42; yield 43; } + !isEnvTest && [ + require('@babel/plugin-transform-regenerator').default, { // Async functions are converted to generators by babel-preset-env async: false, }, ], // Adds syntax support for import() - require.resolve('babel-plugin-syntax-dynamic-import'), - ]), + require('@babel/plugin-syntax-dynamic-import').default, + isEnvTest && + // Transform dynamic import to require + require('babel-plugin-transform-dynamic-import').default, + ].filter(Boolean), }; - - if (env === 'production') { - // Optimization: hoist JSX that never changes out of render() - // 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 108e1ea3cfa..adb596cadd4 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -11,22 +11,20 @@ "index.js" ], "dependencies": { - "babel-plugin-dynamic-import-node": "1.1.0", + "@babel/core": "7.0.0-beta.36", + "@babel/plugin-proposal-class-properties": "7.0.0-beta.36", + "@babel/plugin-syntax-dynamic-import": "^7.0.0-beta.36", + "@babel/plugin-transform-classes": "7.0.0-beta.36", + "@babel/plugin-transform-destructuring": "7.0.0-beta.36", + "@babel/plugin-transform-react-constant-elements": "7.0.0-beta.36", + "@babel/plugin-transform-react-display-name": "7.0.0-beta.36", + "@babel/plugin-transform-react-jsx": "7.0.0-beta.36", + "@babel/plugin-transform-regenerator": "7.0.0-beta.36", + "@babel/plugin-transform-runtime": "7.0.0-beta.36", + "@babel/preset-env": "7.0.0-beta.36", + "@babel/preset-flow": "7.0.0-beta.36", + "@babel/preset-react": "7.0.0-beta.36", "babel-plugin-macros": "2.0.0", - "babel-plugin-syntax-dynamic-import": "6.18.0", - "babel-plugin-transform-class-properties": "6.24.1", - "babel-plugin-transform-es2015-destructuring": "6.23.0", - "babel-plugin-transform-object-rest-spread": "6.26.0", - "babel-plugin-transform-react-constant-elements": "6.23.0", - "babel-plugin-transform-react-jsx": "6.24.1", - "babel-plugin-transform-react-jsx-self": "6.22.0", - "babel-plugin-transform-react-jsx-source": "6.22.0", - "babel-plugin-transform-regenerator": "6.26.0", - "babel-plugin-transform-runtime": "6.23.0", - "babel-preset-env": "1.6.1", - "babel-preset-react": "6.24.1" - }, - "peerDependencies": { - "babel-runtime": "^6.23.0" + "babel-plugin-transform-dynamic-import": "2.0.0" } } diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index c13b0417c46..86cdbbaf1ef 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -11,7 +11,7 @@ "index.js" ], "peerDependencies": { - "babel-eslint": "^7.2.3", + "babel-eslint": "^8.0.2", "eslint": "^4.1.1", "eslint-plugin-flowtype": "^2.34.1", "eslint-plugin-import": "^2.6.0", diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 24f851b1cfc..1ab145a4b89 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -37,7 +37,7 @@ ], "dependencies": { "address": "1.0.3", - "babel-code-frame": "6.26.0", + "@babel/code-frame": "7.0.0-beta.36", "chalk": "1.1.3", "cross-spawn": "5.1.0", "detect-port-alt": "1.1.5", diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index c6cbfeca108..8b4aa4d443d 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -30,13 +30,15 @@ "lib/index.js" ], "devDependencies": { + "@babel/code-frame": "7.0.0-beta.36", + "@babel/core": "7.0.0-beta.36", + "@babel/runtime": "7.0.0-beta.36", "anser": "1.4.4", - "babel-code-frame": "6.26.0", - "babel-core": "^6.26.0", - "babel-eslint": "7.2.3", - "babel-loader": "^7.1.2", + "babel-core": "^7.0.0-bridge.0", + "babel-eslint": "^8.0.2", + "babel-jest": "^22.0.6", + "babel-loader": "^8.0.0-beta.0", "babel-preset-react-app": "^3.1.1", - "babel-runtime": "6.26.0", "chalk": "^2.1.0", "chokidar": "^1.7.0", "cross-env": "5.0.5", diff --git a/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js b/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js index 9bd36e019f7..eedf8006b84 100644 --- a/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js +++ b/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js @@ -14,7 +14,7 @@ import type { ScriptLine } from '../utils/stack-frame'; import { primaryErrorStyle, secondaryErrorStyle } from '../styles'; import generateAnsiHTML from '../utils/generateAnsiHTML'; -import codeFrame from 'babel-code-frame'; +import { codeFrameColumns } from '@babel/code-frame'; type StackFrameCodeBlockPropsType = {| lines: ScriptLine[], @@ -53,10 +53,17 @@ function StackFrameCodeBlock(props: Exact) { } sourceCode[line - 1] = text; }); - const ansiHighlight = codeFrame( + const ansiHighlight = codeFrameColumns( sourceCode.join('\n'), - lineNum, - columnNum == null ? 0 : columnNum - (isFinite(whiteSpace) ? whiteSpace : 0), + { + start: { + line: lineNum, + column: + columnNum == null + ? 0 + : columnNum - (isFinite(whiteSpace) ? whiteSpace : 0), + }, + }, { forceColor: true, linesAbove: contextSize, diff --git a/packages/react-error-overlay/webpack.config.iframe.js b/packages/react-error-overlay/webpack.config.iframe.js index c80b15afa14..2f26b43823f 100644 --- a/packages/react-error-overlay/webpack.config.iframe.js +++ b/packages/react-error-overlay/webpack.config.iframe.js @@ -19,7 +19,24 @@ module.exports = { rules: [ { test: /\.js$/, - include: path.resolve(__dirname, './src'), + include: [ + path.resolve(__dirname, './src'), + path.dirname( + require.resolve('chalk', { + paths: path.dirname(require.resolve('@babel/code-frame')), + }) + ), + path.dirname( + require.resolve( + 'ansi-styles', + path.dirname( + require.resolve('chalk', { + paths: path.dirname(require.resolve('@babel/code-frame')), + }) + ) + ) + ), + ], use: 'babel-loader', }, ], diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index b509af97054..2c6b364fe55 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -96,9 +96,9 @@ module.exports = { // Resolve Babel runtime relative to react-scripts. // It usually still works on npm 3 without this but it would be // unfortunate to rely on, as react-scripts could be symlinked, - // and thus babel-runtime might not be resolvable from the source. - 'babel-runtime': path.dirname( - require.resolve('babel-runtime/package.json') + // and thus @babel/runtime might not be resolvable from the source. + '@babel/runtime': path.dirname( + require.resolve('@babel/runtime/package.json') ), // @remove-on-eject-end // Support React Native Web diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index dea5b99eac6..0f1fc1c1704 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -103,9 +103,9 @@ module.exports = { // Resolve Babel runtime relative to react-scripts. // It usually still works on npm 3 without this but it would be // unfortunate to rely on, as react-scripts could be symlinked, - // and thus babel-runtime might not be resolvable from the source. - 'babel-runtime': path.dirname( - require.resolve('babel-runtime/package.json') + // and thus @babel/runtime might not be resolvable from the source. + '@babel/runtime': path.dirname( + require.resolve('@babel/runtime/package.json') ), // @remove-on-eject-end // Support React Native Web diff --git a/packages/react-scripts/fixtures/kitchensink/.babelrc b/packages/react-scripts/fixtures/kitchensink/.babelrc deleted file mode 100644 index 14397221e3b..00000000000 --- a/packages/react-scripts/fixtures/kitchensink/.babelrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "presets": ["react-app"], - "plugins": ["babel-plugin-transform-es2015-modules-commonjs"] -} diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index b8500f804b1..e4d3bec84f2 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -1,8 +1,8 @@ { "dependencies": { - "babel-register": "6.22.0", - "babel-plugin-transform-es2015-modules-commonjs": "6.22.0", - "babel-polyfill": "6.20.0", + "@babel/plugin-transform-modules-commonjs": "7.0.0-beta.36", + "@babel/polyfill": "7.0.0-beta.36", + "@babel/register": "7.0.0-beta.36", "chai": "3.5.0", "jsdom": "9.8.3", "mocha": "3.2.0", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 0b2f62eb825..357cc1bb376 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -21,13 +21,14 @@ "react-scripts": "./bin/react-scripts.js" }, "dependencies": { + "@babel/core": "7.0.0-beta.36", + "@babel/runtime": "7.0.0-beta.36", "autoprefixer": "7.1.6", - "babel-core": "6.26.0", - "babel-eslint": "7.2.3", + "babel-core": "7.0.0-bridge.0", + "babel-eslint": "8.0.2", "babel-jest": "22.0.6", - "babel-loader": "7.1.2", + "babel-loader": "8.0.0-beta.0", "babel-preset-react-app": "^3.1.1", - "babel-runtime": "6.26.0", "case-sensitive-paths-webpack-plugin": "2.1.1", "chalk": "1.1.3", "css-loader": "0.28.7", diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index d73c45ddbfa..7b17163ca9e 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -134,26 +134,37 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_ENV=test \ yarn test --no-cache --testPathPattern=src -# Test "development" environment +# Prepare "development" environment tmp_server_log=`mktemp` PORT=3001 \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_PATH=src \ nohup yarn start &>$tmp_server_log & grep -q 'You can now view' <(tail -f $tmp_server_log) + +# Before running Mocha, specify that it should use our preset +# TODO: this is very hacky and we should find some other solution +echo '{"presets":["react-app"]}' > .babelrc + +# Test "development" environment E2E_URL="http://localhost:3001" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ NODE_ENV=development \ - node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.test.js - + BABEL_ENV=test \ + node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ NODE_PATH=src \ NODE_ENV=production \ + BABEL_ENV=test \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.test.js + node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js + +# Remove the config we just created for Mocha +# TODO: this is very hacky and we should find some other solution +rm .babelrc # ****************************************************************************** # Finally, let's check that everything still works after ejecting. @@ -193,15 +204,17 @@ E2E_URL="http://localhost:3002" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ NODE_ENV=development \ - node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.test.js + BABEL_ENV=test \ + node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ NODE_ENV=production \ + BABEL_ENV=test \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.test.js + node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js # Cleanup cleanup diff --git a/tasks/replace-own-deps.js b/tasks/replace-own-deps.js index 9178b01029e..15d53d9dc86 100755 --- a/tasks/replace-own-deps.js +++ b/tasks/replace-own-deps.js @@ -16,13 +16,15 @@ const packagesDir = path.join(__dirname, '../packages'); const pkgFilename = path.join(packagesDir, 'react-scripts/package.json'); const data = require(pkgFilename); -fs.readdirSync(packagesDir).forEach((name) => { +fs.readdirSync(packagesDir).forEach(name => { if (data.dependencies[name]) { data.dependencies[name] = 'file:' + path.join(packagesDir, name); } -}) +}); -fs.writeFile(pkgFilename, JSON.stringify(data, null, 2), 'utf8', (err) => { - if (err) throw err; +fs.writeFile(pkgFilename, JSON.stringify(data, null, 2), 'utf8', err => { + if (err) { + throw err; + } console.log('Replaced local dependencies.'); }); From b90f2337d1c4bee35561e7a2c63d15a97de55f6d Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 12 Jan 2018 13:24:16 +0000 Subject: [PATCH 0521/1739] wip --- .../webpack.config.iframe.js | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/react-error-overlay/webpack.config.iframe.js b/packages/react-error-overlay/webpack.config.iframe.js index 2f26b43823f..8e9bed55b42 100644 --- a/packages/react-error-overlay/webpack.config.iframe.js +++ b/packages/react-error-overlay/webpack.config.iframe.js @@ -23,21 +23,27 @@ module.exports = { path.resolve(__dirname, './src'), path.dirname( require.resolve('chalk', { - paths: path.dirname(require.resolve('@babel/code-frame')), + paths: [path.dirname(require.resolve('@babel/code-frame'))], }) ), path.dirname( - require.resolve( - 'ansi-styles', - path.dirname( - require.resolve('chalk', { - paths: path.dirname(require.resolve('@babel/code-frame')), - }) - ) - ) + require.resolve('ansi-styles', { + paths: [ + path.dirname( + require.resolve('chalk', { + paths: [path.dirname(require.resolve('@babel/code-frame'))], + }) + ), + ], + }) ), ], - use: 'babel-loader', + use: { + loader: 'babel-loader', + options: { + presets: ['react-app'], + }, + }, }, ], }, From c8970c4e9a99db27fb541b471ab82a124f228b14 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 12 Jan 2018 18:10:40 +0000 Subject: [PATCH 0522/1739] Fix the build --- .../webpack.config.iframe.js | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/packages/react-error-overlay/webpack.config.iframe.js b/packages/react-error-overlay/webpack.config.iframe.js index 8e9bed55b42..1da7c9ba841 100644 --- a/packages/react-error-overlay/webpack.config.iframe.js +++ b/packages/react-error-overlay/webpack.config.iframe.js @@ -21,22 +21,7 @@ module.exports = { test: /\.js$/, include: [ path.resolve(__dirname, './src'), - path.dirname( - require.resolve('chalk', { - paths: [path.dirname(require.resolve('@babel/code-frame'))], - }) - ), - path.dirname( - require.resolve('ansi-styles', { - paths: [ - path.dirname( - require.resolve('chalk', { - paths: [path.dirname(require.resolve('@babel/code-frame'))], - }) - ), - ], - }) - ), + /\/node_modules\/(ansi-styles|chalk)\//, ], use: { loader: 'babel-loader', From 11b4fae3c746f4af5b51a6c458d93269418908e2 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 12 Jan 2018 19:55:28 +0000 Subject: [PATCH 0523/1739] Update appveyor.cleanup-cache.txt --- appveyor.cleanup-cache.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/appveyor.cleanup-cache.txt b/appveyor.cleanup-cache.txt index ea6d1b9c010..d48a91fdf35 100644 --- a/appveyor.cleanup-cache.txt +++ b/appveyor.cleanup-cache.txt @@ -2,5 +2,3 @@ Edit this file to trigger a cache rebuild. http://help.appveyor.com/discussions/questions/1310-delete-cache ---- -Just testing if this works. -lalala. From a573d37f36ad17a4e9f0a04b8382a85c48bb38bd Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 12 Jan 2018 20:00:42 +0000 Subject: [PATCH 0524/1739] Fix windows build --- packages/react-error-overlay/webpack.config.iframe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-error-overlay/webpack.config.iframe.js b/packages/react-error-overlay/webpack.config.iframe.js index 1da7c9ba841..e6a7f69de30 100644 --- a/packages/react-error-overlay/webpack.config.iframe.js +++ b/packages/react-error-overlay/webpack.config.iframe.js @@ -21,7 +21,7 @@ module.exports = { test: /\.js$/, include: [ path.resolve(__dirname, './src'), - /\/node_modules\/(ansi-styles|chalk)\//, + /[\/\\]node_modules[\/\\](ansi-styles|chalk)[\/\\]/, ], use: { loader: 'babel-loader', From bf02edbef2a20ff8af66b396d7ee6ae7901c45a0 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 12 Jan 2018 22:43:40 +0000 Subject: [PATCH 0525/1739] Bump eslint-plugin-jsx-a11y version (#2690) * Bump eslint-plugin-jsx-a11y * Update index.js * Update index.js * Update package.json * Don't use links for non-linky things --- packages/eslint-config-react-app/index.js | 7 ++++++- packages/eslint-config-react-app/package.json | 2 +- packages/react-error-overlay/package.json | 2 +- .../src/containers/CompileErrorContainer.js | 4 ++-- packages/react-error-overlay/src/containers/StackFrame.js | 8 ++++---- packages/react-scripts/package.json | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index 9b687663da9..836dd5aa0ae 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -270,13 +270,18 @@ module.exports = { 'jsx-a11y/accessible-emoji': 'warn', 'jsx-a11y/alt-text': 'warn', 'jsx-a11y/anchor-has-content': 'warn', + 'jsx-a11y/anchor-is-valid': [ + 'warn', + { + aspects: ['noHref', 'invalidHref'], + }, + ], 'jsx-a11y/aria-activedescendant-has-tabindex': 'warn', 'jsx-a11y/aria-props': 'warn', 'jsx-a11y/aria-proptypes': 'warn', 'jsx-a11y/aria-role': 'warn', 'jsx-a11y/aria-unsupported-elements': 'warn', 'jsx-a11y/heading-has-content': 'warn', - 'jsx-a11y/href-no-hash': 'warn', 'jsx-a11y/iframe-has-title': 'warn', 'jsx-a11y/img-redundant-alt': 'warn', 'jsx-a11y/no-access-key': 'warn', diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index 86cdbbaf1ef..b15be1dd29a 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -15,7 +15,7 @@ "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-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.1.0" } } diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 8b4aa4d443d..8d9f429ce76 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -46,7 +46,7 @@ "eslint-config-react-app": "^2.1.0", "eslint-plugin-flowtype": "2.35.0", "eslint-plugin-import": "2.7.0", - "eslint-plugin-jsx-a11y": "5.1.1", + "eslint-plugin-jsx-a11y": "6.0.2", "eslint-plugin-react": "7.1.0", "flow-bin": "^0.63.1", "html-entities": "1.2.1", diff --git a/packages/react-error-overlay/src/containers/CompileErrorContainer.js b/packages/react-error-overlay/src/containers/CompileErrorContainer.js index 9d1e399fd10..3e9d4611860 100644 --- a/packages/react-error-overlay/src/containers/CompileErrorContainer.js +++ b/packages/react-error-overlay/src/containers/CompileErrorContainer.js @@ -32,14 +32,14 @@ class CompileErrorContainer extends PureComponent { return (
- editorHandler(errLoc) : null } style={canOpenInEditor ? codeAnchorStyle : null} > - +