├── packages ├── react-scripts │ ├── .npmignore │ ├── template │ │ ├── src │ │ │ ├── shared │ │ │ │ └── styles │ │ │ │ │ ├── typography.scss │ │ │ │ │ ├── colors.scss │ │ │ │ │ ├── index.scss │ │ │ │ │ ├── z-index.scss │ │ │ │ │ └── mixins.scss │ │ │ ├── index.js │ │ │ └── components │ │ │ │ └── App │ │ │ │ ├── index.test.js │ │ │ │ ├── style.scss │ │ │ │ ├── index.js │ │ │ │ ├── logo.inline.svg │ │ │ │ └── logo.svg │ │ ├── public │ │ │ ├── favicon.ico │ │ │ ├── manifest.json │ │ │ └── index.html │ │ ├── .babelrc │ │ ├── .editorconfig │ │ ├── gitignore │ │ └── .eslintrc.js │ ├── fixtures │ │ └── kitchensink │ │ │ ├── src │ │ │ ├── features │ │ │ │ ├── webpack │ │ │ │ │ ├── assets │ │ │ │ │ │ ├── aFileWithExt.unknown │ │ │ │ │ │ ├── aFileWithoutExt │ │ │ │ │ │ ├── abstract.json │ │ │ │ │ │ ├── tiniest-cat.jpg │ │ │ │ │ │ ├── style.css │ │ │ │ │ │ └── logo.svg │ │ │ │ │ ├── CssInclusion.js │ │ │ │ │ ├── SvgInclusion.js │ │ │ │ │ ├── JsonInclusion.js │ │ │ │ │ ├── ImageInclusion.js │ │ │ │ │ ├── CssInclusion.test.js │ │ │ │ │ ├── SvgInclusion.test.js │ │ │ │ │ ├── JsonInclusion.test.js │ │ │ │ │ ├── ImageInclusion.test.js │ │ │ │ │ ├── NoExtInclusion.test.js │ │ │ │ │ ├── LinkedModules.js │ │ │ │ │ ├── NoExtInclusion.js │ │ │ │ │ ├── UnknownExtInclusion.test.js │ │ │ │ │ ├── UnknownExtInclusion.js │ │ │ │ │ └── LinkedModules.test.js │ │ │ │ ├── env │ │ │ │ │ ├── PublicUrl.js │ │ │ │ │ ├── ShellEnvVariables.js │ │ │ │ │ ├── PublicUrl.test.js │ │ │ │ │ ├── FileEnvVariables.test.js │ │ │ │ │ ├── ShellEnvVariables.test.js │ │ │ │ │ ├── ExpandEnvVariables.test.js │ │ │ │ │ ├── NodePath.test.js │ │ │ │ │ ├── ExpandEnvVariables.js │ │ │ │ │ ├── FileEnvVariables.js │ │ │ │ │ └── NodePath.js │ │ │ │ └── syntax │ │ │ │ │ ├── Generators.test.js │ │ │ │ │ ├── AsyncAwait.test.js │ │ │ │ │ ├── ArraySpread.test.js │ │ │ │ │ ├── ObjectSpread.test.js │ │ │ │ │ ├── RestAndDefault.test.js │ │ │ │ │ ├── RestParameters.test.js │ │ │ │ │ ├── ClassProperties.test.js │ │ │ │ │ ├── DefaultParameters.test.js │ │ │ │ │ ├── Promises.test.js │ │ │ │ │ ├── ArrayDestructuring.test.js │ │ │ │ │ ├── ComputedProperties.test.js │ │ │ │ │ ├── CustomInterpolation.test.js │ │ │ │ │ ├── ObjectDestructuring.test.js │ │ │ │ │ ├── DestructuringAndAwait.test.js │ │ │ │ │ ├── TemplateInterpolation.test.js │ │ │ │ │ ├── ClassProperties.js │ │ │ │ │ ├── ArrayDestructuring.js │ │ │ │ │ ├── AsyncAwait.js │ │ │ │ │ ├── ArraySpread.js │ │ │ │ │ ├── Promises.js │ │ │ │ │ ├── Generators.js │ │ │ │ │ ├── DefaultParameters.js │ │ │ │ │ ├── TemplateInterpolation.js │ │ │ │ │ ├── RestAndDefault.js │ │ │ │ │ ├── RestParameters.js │ │ │ │ │ ├── DestructuringAndAwait.js │ │ │ │ │ ├── ComputedProperties.js │ │ │ │ │ ├── ObjectSpread.js │ │ │ │ │ ├── ObjectDestructuring.js │ │ │ │ │ └── CustomInterpolation.js │ │ │ ├── subfolder │ │ │ │ └── lol.js │ │ │ ├── absoluteLoad.js │ │ │ └── index.js │ │ │ ├── .env.production │ │ │ ├── .env.development │ │ │ ├── .env.local │ │ │ ├── .flowconfig │ │ │ ├── .babelrc │ │ │ ├── public │ │ │ ├── favicon.ico │ │ │ └── index.html │ │ │ ├── gitignore │ │ │ ├── .env │ │ │ ├── .template.dependencies.json │ │ │ ├── integration │ │ │ ├── webpack.test.js │ │ │ └── initDOM.js │ │ │ └── README.md │ ├── config │ │ ├── jest │ │ │ ├── babelTransform.js │ │ │ ├── fileTransform.js │ │ │ └── cssTransform.js │ │ └── polyfills.js │ ├── README.md │ ├── bin │ │ └── react-scripts.js │ └── package.json ├── react-error-overlay │ ├── .gitignore │ ├── .gitattributes │ ├── .babelrc │ ├── .npmignore │ ├── fixtures │ │ ├── inline.es6.mjs │ │ ├── inline.mjs │ │ ├── junk-inline.mjs │ │ └── bundle-default.json │ ├── .eslintrc │ ├── .flowconfig │ ├── src │ │ ├── __tests__ │ │ │ ├── setupJest.js │ │ │ ├── __snapshots__ │ │ │ │ ├── script-lines.js.snap │ │ │ │ ├── stack-frame.js.snap │ │ │ │ └── lines-around.js.snap │ │ │ ├── script-lines.js │ │ │ ├── parser │ │ │ │ ├── react.js │ │ │ │ ├── safari.js │ │ │ │ ├── chrome.js │ │ │ │ ├── generic.js │ │ │ │ ├── __snapshots__ │ │ │ │ │ ├── safari.js.snap │ │ │ │ │ ├── react.js.snap │ │ │ │ │ └── chrome.js.snap │ │ │ │ └── firefox.js │ │ │ ├── lines-around.js │ │ │ ├── extract-source-map.js │ │ │ ├── stack-frame.js │ │ │ ├── get-source-map.js │ │ │ └── unmapper.js │ │ ├── utils │ │ │ ├── isInternalFile.js │ │ │ ├── isBultinErrorName.js │ │ │ ├── pollyfills.js │ │ │ ├── getLinesAround.js │ │ │ ├── dom │ │ │ │ ├── absolutifyCaret.js │ │ │ │ └── css.js │ │ │ ├── getStackFrames.js │ │ │ ├── getPrettyURL.js │ │ │ ├── warnings.js │ │ │ ├── parseCompileError.js │ │ │ └── mapper.js │ │ ├── components │ │ │ ├── Footer.js │ │ │ ├── Header.js │ │ │ ├── CloseButton.js │ │ │ ├── CodeBlock.js │ │ │ ├── NavigationBar.js │ │ │ ├── ErrorOverlay.js │ │ │ └── Collapsible.js │ │ ├── styles.js │ │ ├── effects │ │ │ ├── stackTraceLimit.js │ │ │ ├── unhandledError.js │ │ │ ├── unhandledRejection.js │ │ │ └── proxyConsole.js │ │ ├── containers │ │ │ ├── CompileErrorContainer.js │ │ │ ├── RuntimeError.js │ │ │ └── RuntimeErrorContainer.js │ │ ├── iframeScript.js │ │ └── listenToRuntimeErrors.js │ ├── flow │ │ └── env.js │ ├── README.md │ ├── webpack.config.js │ ├── webpack.config.iframe.js │ ├── package.json │ └── build.js ├── react-dev-utils │ ├── __tests__ │ │ ├── .eslintrc │ │ └── ignoredFiles.test.js │ ├── inquirer.js │ ├── crossSpawn.js │ ├── launchEditorEndpoint.js │ ├── clearConsole.js │ ├── ignoredFiles.js │ ├── errorOverlayMiddleware.js │ ├── checkRequiredFiles.js │ ├── WatchMissingNodeModulesPlugin.js │ ├── printBuildError.js │ ├── noopServiceWorkerMiddleware.js │ ├── InterpolateHtmlPlugin.js │ ├── package.json │ ├── getProcessForPort.js │ ├── openChrome.applescript │ ├── eslintFormatter.js │ └── ModuleScopePlugin.js ├── babel-preset-react-app │ ├── test.js │ ├── dev.js │ ├── prod.js │ ├── index.js │ ├── package.json │ └── README.md ├── create-react-app │ ├── README.md │ ├── package.json │ └── index.js └── eslint-config-react-app │ └── package.json ├── .yarnrc ├── .eslintignore ├── appveyor.cleanup-cache.txt ├── .gitignore ├── .github └── PULL_REQUEST_TEMPLATE.md ├── CODE_OF_CONDUCT.md ├── .eslintrc ├── lerna.json ├── .travis.yml ├── tasks ├── replace-own-deps.js ├── publish.sh └── e2e-old-node.sh ├── appveyor.yml ├── LICENSE └── package.json /packages/react-scripts/.npmignore: -------------------------------------------------------------------------------- 1 | /fixtures 2 | -------------------------------------------------------------------------------- /packages/react-error-overlay/.gitignore: -------------------------------------------------------------------------------- 1 | lib/ 2 | coverage/ 3 | -------------------------------------------------------------------------------- /packages/react-error-overlay/.gitattributes: -------------------------------------------------------------------------------- 1 | *.js text eol=lf 2 | -------------------------------------------------------------------------------- /packages/react-error-overlay/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-app"] 3 | } 4 | -------------------------------------------------------------------------------- /packages/react-error-overlay/.npmignore: -------------------------------------------------------------------------------- 1 | __tests__ 2 | *.test.js 3 | *.spec.js 4 | -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | --install.no-lockfile true 2 | --install.check-files true 3 | --add.no-lockfile true 4 | -------------------------------------------------------------------------------- /packages/react-dev-utils/__tests__/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "jest": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/react-scripts/template/src/shared/styles/typography.scss: -------------------------------------------------------------------------------- 1 | $fs-1: 1rem; 2 | $fs-2: 1.5rem; 3 | -------------------------------------------------------------------------------- /packages/react-scripts/template/src/shared/styles/colors.scss: -------------------------------------------------------------------------------- 1 | $brand-primary: #00d664; 2 | $white: #fff; 3 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/aFileWithExt.unknown: -------------------------------------------------------------------------------- 1 | Whoooo, spooky! 2 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | build 3 | my-app* 4 | packages/react-scripts/template 5 | packages/react-scripts/fixtures 6 | -------------------------------------------------------------------------------- /packages/react-error-overlay/fixtures/inline.es6.mjs: -------------------------------------------------------------------------------- 1 | function foo() { 2 | console.log('bar') 3 | } 4 | 5 | export { foo } 6 | -------------------------------------------------------------------------------- /packages/react-error-overlay/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "react-app", 3 | "rules": { 4 | "curly": "warn" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/aFileWithoutExt: -------------------------------------------------------------------------------- 1 | This is just a file without an extension 2 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/.env.production: -------------------------------------------------------------------------------- 1 | REACT_APP_X = x-from-production-env 2 | REACT_APP_PRODUCTION = production 3 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/abstract.json: -------------------------------------------------------------------------------- 1 | { 2 | "abstract": "This is an abstract." 3 | } 4 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/.env.development: -------------------------------------------------------------------------------- 1 | REACT_APP_X = x-from-development-env 2 | REACT_APP_DEVELOPMENT = development 3 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/.env.local: -------------------------------------------------------------------------------- 1 | REACT_APP_X = x-from-original-local-env 2 | REACT_APP_ORIGINAL_2 = override-from-original-local-env-2 3 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | /node_modules/fbjs/.* 3 | 4 | [include] 5 | 6 | [libs] 7 | 8 | [options] 9 | -------------------------------------------------------------------------------- /packages/react-scripts/template/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netguru/create-react-app/HEAD/packages/react-scripts/template/public/favicon.ico -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-app"], 3 | "plugins": ["babel-plugin-transform-es2015-modules-commonjs"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/react-scripts/template/src/shared/styles/index.scss: -------------------------------------------------------------------------------- 1 | @import './z-index.scss'; 2 | @import './colors.scss'; 3 | @import './typography.scss'; 4 | @import './mixins.scss'; 5 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netguru/create-react-app/HEAD/packages/react-scripts/fixtures/kitchensink/public/favicon.ico -------------------------------------------------------------------------------- /appveyor.cleanup-cache.txt: -------------------------------------------------------------------------------- 1 | Edit this file to trigger a cache rebuild. 2 | http://help.appveyor.com/discussions/questions/1310-delete-cache 3 | 4 | ---- 5 | Just testing if this works. 6 | lalala. 7 | -------------------------------------------------------------------------------- /packages/react-scripts/template/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ "env", { "modules": false } ], 4 | "es2015", 5 | "stage-2", 6 | "react" 7 | ], 8 | "plugins": ["react-hot-loader/babel"] 9 | } 10 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/tiniest-cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netguru/create-react-app/HEAD/packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/tiniest-cat.jpg -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vscode/ 3 | node_modules/ 4 | build 5 | .DS_Store 6 | *.tgz 7 | my-app* 8 | template/src/__tests__/__snapshots__/ 9 | lerna-debug.log 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | /.changelog 14 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /packages/react-scripts/template/src/shared/styles/z-index.scss: -------------------------------------------------------------------------------- 1 | $z-index-1: 1000; 2 | $z-index-2: 2000; 3 | $z-index-3: 3000; 4 | $z-index-4: 4000; 5 | $z-index-5: 5000; 6 | $z-index-6: 6000; 7 | $z-index-7: 7000; 8 | $z-index-8: 8000; 9 | $z-index-9: 9000; 10 | -------------------------------------------------------------------------------- /packages/react-error-overlay/.flowconfig: -------------------------------------------------------------------------------- 1 | [include] 2 | /src/**/*.js 3 | 4 | [ignore] 5 | .*/node_modules/.* 6 | .*/.git/.* 7 | .*/__test__/.* 8 | .*/fixtures/.* 9 | 10 | [libs] 11 | flow/ 12 | 13 | [options] 14 | module.file_ext=.js 15 | sharedmemory.hash_table_pow=19 16 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | 6 | # testing 7 | coverage 8 | 9 | # production 10 | build 11 | 12 | # misc 13 | .DS_Store 14 | .env 15 | npm-debug.log 16 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | 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. 4 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/setupJest.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | global.fetch = require('jest-fetch-mock'); 9 | -------------------------------------------------------------------------------- /packages/react-scripts/template/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | end_of_line = lf 10 | # editorconfig-tools is unable to ignore longs strings or urls 11 | max_line_length = null 12 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/subfolder/lol.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | module.exports = function() { 9 | return `haha`; 10 | }; 11 | -------------------------------------------------------------------------------- /packages/babel-preset-react-app/test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 'use strict'; 8 | 9 | const create = require('./create'); 10 | 11 | module.exports = create('test'); 12 | -------------------------------------------------------------------------------- /packages/react-dev-utils/inquirer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | var inquirer = require('inquirer'); 11 | 12 | module.exports = inquirer; 13 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Ensure CSS inclusion doesn't regress 3 | * https://github.com/facebookincubator/create-react-app/issues/2677 4 | */ 5 | @import '~normalize.css/normalize.css'; 6 | 7 | #feature-css-inclusion { 8 | background: palevioletred; 9 | color: papayawhip; 10 | } 11 | -------------------------------------------------------------------------------- /packages/react-scripts/template/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import 'normalize.css'; 4 | 5 | import App from 'components/App'; 6 | import registerServiceWorker from 'utils/registerServiceWorker'; 7 | 8 | ReactDOM.render(, document.getElementById('root')); 9 | 10 | registerServiceWorker(); 11 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint:recommended", 3 | "env": { 4 | "browser": true, 5 | "commonjs": true, 6 | "node": true, 7 | "es6": true 8 | }, 9 | "parserOptions": { 10 | "ecmaVersion": 6 11 | }, 12 | "rules": { 13 | "no-console": "off", 14 | "strict": ["error", "global"], 15 | "curly": "warn" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/babel-preset-react-app/dev.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 'use strict'; 8 | 9 | const create = require('./create'); 10 | 11 | module.exports = create('development'); 12 | -------------------------------------------------------------------------------- /packages/babel-preset-react-app/prod.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 'use strict'; 8 | 9 | const create = require('./create'); 10 | 11 | module.exports = create('production'); 12 | -------------------------------------------------------------------------------- /packages/react-dev-utils/crossSpawn.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | var crossSpawn = require('cross-spawn'); 11 | 12 | module.exports = crossSpawn; 13 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/.env: -------------------------------------------------------------------------------- 1 | REACT_APP_X = x-from-original-env 2 | REACT_APP_ORIGINAL_1 = from-original-env-1 3 | REACT_APP_ORIGINAL_2 = from-original-env-2 4 | REACT_APP_BASIC = basic 5 | REACT_APP_BASIC_EXPAND = ${REACT_APP_BASIC} 6 | REACT_APP_BASIC_EXPAND_SIMPLE = $REACT_APP_BASIC 7 | REACT_APP_EXPAND_EXISTING = $REACT_APP_SHELL_ENV_MESSAGE 8 | -------------------------------------------------------------------------------- /packages/react-scripts/template/src/components/App/index.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import { AppUnwrapped as App } from './index'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | React App 8 | 9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/react-dev-utils/launchEditorEndpoint.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 'use strict'; 8 | 9 | // TODO: we might want to make this injectable to support DEV-time non-root URLs. 10 | module.exports = '/__open-stack-frame-in-editor'; 11 | -------------------------------------------------------------------------------- /packages/react-scripts/template/gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | 12 | # misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/absoluteLoad.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | export default () => [ 9 | { id: 1, name: '1' }, 10 | { id: 2, name: '2' }, 11 | { id: 3, name: '3' }, 12 | { id: 4, name: '4' }, 13 | ]; 14 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | 10 | export default () => ( 11 | {process.env.PUBLIC_URL}. 12 | ); 13 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/.template.dependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "babel-register": "6.22.0", 4 | "babel-plugin-transform-es2015-modules-commonjs": "6.22.0", 5 | "babel-polyfill": "6.20.0", 6 | "chai": "3.5.0", 7 | "jsdom": "9.8.3", 8 | "mocha": "3.2.0", 9 | "normalize.css": "7.0.0", 10 | "prop-types": "15.5.6", 11 | "test-integrity": "1.0.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import App from './App'; 11 | 12 | ReactDOM.render(, document.getElementById('root')); 13 | -------------------------------------------------------------------------------- /packages/react-scripts/template/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": "./index.html", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssInclusion.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import './assets/style.css'; 10 | 11 | export default () =>

We love useless text.

; 12 | -------------------------------------------------------------------------------- /packages/react-error-overlay/flow/env.js: -------------------------------------------------------------------------------- 1 | declare module 'anser' { 2 | declare module.exports: any; 3 | } 4 | 5 | declare module 'babel-code-frame' { 6 | declare module.exports: any; 7 | } 8 | 9 | declare module 'html-entities' { 10 | declare module.exports: any; 11 | } 12 | 13 | declare module 'settle-promise' { 14 | declare module.exports: any; 15 | } 16 | 17 | declare module 'source-map' { 18 | declare module.exports: any; 19 | } 20 | -------------------------------------------------------------------------------- /packages/react-dev-utils/clearConsole.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | function clearConsole() { 11 | process.stdout.write(process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H'); 12 | } 13 | 14 | module.exports = clearConsole; 15 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/__snapshots__/script-lines.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`script line shape 1`] = ` 4 | ScriptLine { 5 | "content": "foobar", 6 | "highlight": true, 7 | "lineNumber": 5, 8 | } 9 | `; 10 | 11 | exports[`script line to provide default highlight 1`] = ` 12 | ScriptLine { 13 | "content": "foobar", 14 | "highlight": false, 15 | "lineNumber": 5, 16 | } 17 | `; 18 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/SvgInclusion.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import logo from './assets/logo.svg'; 10 | 11 | export default () => logo; 12 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import { abstract } from './assets/abstract.json'; 10 | 11 | export default () => {abstract}; 12 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | 10 | export default () => ( 11 | 12 | {process.env.REACT_APP_SHELL_ENV_MESSAGE}. 13 | 14 | ); 15 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import tiniestCat from './assets/tiniest-cat.jpg'; 10 | 11 | export default () => ( 12 | tiniest cat 13 | ); 14 | -------------------------------------------------------------------------------- /packages/react-scripts/config/jest/babelTransform.js: -------------------------------------------------------------------------------- 1 | // @remove-file-on-eject 2 | /** 3 | * Copyright (c) 2014-present, Facebook, Inc. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 'use strict'; 9 | 10 | const babelJest = require('babel-jest'); 11 | 12 | module.exports = babelJest.createTransformer({ 13 | presets: [require.resolve('babel-preset-react-app')], 14 | babelrc: false, 15 | }); 16 | -------------------------------------------------------------------------------- /packages/create-react-app/README.md: -------------------------------------------------------------------------------- 1 | # create-react-app 2 | 3 | This package includes the global command for [Create React App](https://github.com/facebookincubator/create-react-app).
4 | Please refer to its documentation: 5 | 6 | * [Getting Started](https://github.com/facebookincubator/create-react-app/blob/master/README.md#getting-started) – How to create a new app. 7 | * [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App. 8 | -------------------------------------------------------------------------------- /packages/react-scripts/README.md: -------------------------------------------------------------------------------- 1 | # react-scripts 2 | 3 | This package includes scripts and configuration used by [Create React App](https://github.com/facebookincubator/create-react-app).
4 | Please refer to its documentation: 5 | 6 | * [Getting Started](https://github.com/facebookincubator/create-react-app/blob/master/README.md#getting-started) – How to create a new app. 7 | * [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App. 8 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/script-lines.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import { ScriptLine } from '../utils/stack-frame'; 9 | 10 | test('script line shape', () => { 11 | expect(new ScriptLine(5, 'foobar', true)).toMatchSnapshot(); 12 | }); 13 | 14 | test('script line to provide default highlight', () => { 15 | expect(new ScriptLine(5, 'foobar')).toMatchSnapshot(); 16 | }); 17 | -------------------------------------------------------------------------------- /packages/react-dev-utils/ignoredFiles.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | const path = require('path'); 11 | const escape = require('escape-string-regexp'); 12 | 13 | module.exports = function ignoredFiles(appSrc) { 14 | return new RegExp( 15 | `^(?!${escape( 16 | path.normalize(appSrc + '/').replace(/[\\]+/g, '/') 17 | )}).+/node_modules/`, 18 | 'g' 19 | ); 20 | }; 21 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "2.6.0", 3 | "npmClient": "yarn", 4 | "useWorkspaces": true, 5 | "version": "independent", 6 | "changelog": { 7 | "repo": "facebookincubator/create-react-app", 8 | "labels": { 9 | "tag: new feature": ":rocket: New Feature", 10 | "tag: breaking change": ":boom: Breaking Change", 11 | "tag: bug fix": ":bug: Bug Fix", 12 | "tag: enhancement": ":nail_care: Enhancement", 13 | "tag: documentation": ":memo: Documentation", 14 | "tag: internal": ":house: Internal" 15 | }, 16 | "cacheDir": ".changelog" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import PublicUrl from './PublicUrl'; 11 | 12 | describe('PUBLIC_URL', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | ReactDOM.render(, div); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/react-error-overlay/fixtures/inline.mjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | function foo() { 7 | console.log('bar'); 8 | } 9 | 10 | exports.foo = foo; 11 | 12 | //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSxTQUFTLEdBQVQsR0FBZTtBQUNiLFVBQVEsR0FBUixDQUFZLEtBQVo7QUFDRDs7UUFFUSxHLEdBQUEsRyIsImZpbGUiOiJzdGRvdXQiLCJzb3VyY2VzQ29udGVudCI6WyJmdW5jdGlvbiBmb28oKSB7XG4gIGNvbnNvbGUubG9nKCdiYXInKVxufVxuXG5leHBvcnQgeyBmb28gfVxuIl19 13 | -------------------------------------------------------------------------------- /packages/react-scripts/template/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: 'airbnb', 3 | parser: 'babel-eslint', 4 | env: { 5 | jest: true, 6 | browser: true, 7 | }, 8 | settings: { 9 | 'import/resolver': { 10 | webpack: { 11 | config: { 12 | resolve: { 13 | modules: ['node_modules', 'src'], 14 | extensions: ['.js', '.json', '.jsx'], 15 | }, 16 | }, 17 | }, 18 | }, 19 | }, 20 | rules: { 21 | 'react/jsx-filename-extension': [ 22 | 2, { extensions: ['.js'] }, 23 | ], 24 | }, 25 | }; 26 | -------------------------------------------------------------------------------- /packages/react-error-overlay/fixtures/junk-inline.mjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | function foo() { 7 | console.log('bar'); 8 | } 9 | 10 | exports.foo = foo; 11 | 12 | //# sourceMappingURL=data:application/json;charset=utf-8;base64vlq,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSxTQUFTLEdBQVQsR0FBZTtBQUNiLFVBQVEsR0FBUixDQUFZLEtBQVo7QUFDRDs7UUFFUSxHLEdBQUEsRyIsImZpbGUiOiJzdGRvdXQiLCJzb3VyY2VzQ29udGVudCI6WyJmdW5jdGlvbiBmb28oKSB7XG4gIGNvbnNvbGUubG9nKCdiYXInKVxufVxuXG5leHBvcnQgeyBmb28gfVxuIl19 13 | -------------------------------------------------------------------------------- /packages/react-error-overlay/README.md: -------------------------------------------------------------------------------- 1 | # `react-error-overlay` 2 | 3 | `react-error-overlay` is an overlay which displays when there is a runtime error. 4 | 5 | ## Development 6 | 7 | When developing within this package, make sure you run `npm start` (or `yarn start`) so that the files are compiled as you work. 8 | This is ran in watch mode by default. 9 | 10 | If you would like to build this for production, run `npm run build:prod` (or `yarn build:prod`).
11 | If you would like to build this one-off for development, you can run `NODE_ENV=development npm run build` (or `NODE_ENV=development yarn build`). 12 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssInclusion.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import CssInclusion from './CssInclusion'; 11 | 12 | describe('css inclusion', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | ReactDOM.render(, div); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/SvgInclusion.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import SvgInclusion from './SvgInclusion'; 11 | 12 | describe('svg inclusion', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | ReactDOM.render(, div); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import JsonInclusion from './JsonInclusion'; 11 | 12 | describe('JSON inclusion', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | ReactDOM.render(, div); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import ImageInclusion from './ImageInclusion'; 11 | 12 | describe('image inclusion', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | ReactDOM.render(, div); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import NoExtInclusion from './NoExtInclusion'; 11 | 12 | describe('no ext inclusion', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | ReactDOM.render(, div); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import FileEnvVariables from './FileEnvVariables'; 11 | 12 | describe('.env variables', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | ReactDOM.render(, div); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import ShellEnvVariables from './ShellEnvVariables'; 11 | 12 | describe('shell env variables', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | ReactDOM.render(, div); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import './assets/style.css'; 10 | import { test, version } from 'test-integrity'; 11 | 12 | export default () => { 13 | const v = version(); 14 | if (!test() || v !== '2.0.0') { 15 | throw new Error('Functionality test did not pass.'); 16 | } 17 | return

{v}

; 18 | }; 19 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/env/ExpandEnvVariables.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import ExpandEnvVariables from './ExpandEnvVariables'; 11 | 12 | describe('expand .env variables', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | ReactDOM.render(, div); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import aFileWithoutExt from './assets/aFileWithoutExt'; 10 | 11 | const text = aFileWithoutExt.includes('base64') 12 | ? atob(aFileWithoutExt.split('base64,')[1]).trim() 13 | : aFileWithoutExt; 14 | 15 | export default () => ( 16 | 17 | aFileWithoutExt 18 | 19 | ); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import UnknownExtInclusion from './UnknownExtInclusion'; 11 | 12 | describe('unknown ext inclusion', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | ReactDOM.render(, div); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/parser/react.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import { parse } from '../../utils/parser'; 9 | 10 | test('15.y.z', () => { 11 | expect( 12 | parse( 13 | `Warning: Each child in array should have a unique "key" prop. Check render method of \`FileA\`. 14 | in div (at FileA.js:9) 15 | in FileA (at App.js:9) 16 | in div (at App.js:8) 17 | in App (at index.js:7)` 18 | ) 19 | ).toMatchSnapshot(); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import NodePath from './NodePath'; 11 | 12 | describe('NODE_PATH', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/config/jest/fileTransform.js: -------------------------------------------------------------------------------- 1 | // @remove-on-eject-begin 2 | /** 3 | * Copyright (c) 2014-present, Facebook, Inc. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | // @remove-on-eject-end 9 | 'use strict'; 10 | 11 | const path = require('path'); 12 | 13 | // This is a custom Jest transformer turning file imports into filenames. 14 | // http://facebook.github.io/jest/docs/en/webpack.html 15 | 16 | module.exports = { 17 | process(src, filename) { 18 | return `module.exports = ${JSON.stringify(path.basename(filename))};`; 19 | }, 20 | }; 21 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import Generators from './Generators'; 11 | 12 | describe('generators', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import AsyncAwait from './AsyncAwait'; 11 | 12 | describe('async/await', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/config/jest/cssTransform.js: -------------------------------------------------------------------------------- 1 | // @remove-on-eject-begin 2 | /** 3 | * Copyright (c) 2014-present, Facebook, Inc. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | // @remove-on-eject-end 9 | 'use strict'; 10 | 11 | // This is a custom Jest transformer turning style imports into empty objects. 12 | // http://facebook.github.io/jest/docs/en/webpack.html 13 | 14 | module.exports = { 15 | process() { 16 | return 'module.exports = {};'; 17 | }, 18 | getCacheKey() { 19 | // The output is always the same. 20 | return 'cssTransform'; 21 | }, 22 | }; 23 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import ArraySpread from './ArraySpread'; 11 | 12 | describe('array spread', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import aFileWithExtUnknown from './assets/aFileWithExt.unknown'; 10 | 11 | const text = aFileWithExtUnknown.includes('base64') 12 | ? atob(aFileWithExtUnknown.split('base64,')[1]).trim() 13 | : aFileWithExtUnknown; 14 | 15 | export default () => ( 16 | 17 | aFileWithExtUnknown 18 | 19 | ); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/template/src/components/App/style.scss: -------------------------------------------------------------------------------- 1 | @import '~shared/styles/index.scss'; 2 | 3 | .app { 4 | text-align: center; 5 | } 6 | 7 | .appLogo { 8 | @include circle(80px); 9 | 10 | background: $white; 11 | animation: appLogoSpin infinite 20s linear; 12 | } 13 | 14 | .appHeader { 15 | height: 150px; 16 | padding: 20px; 17 | color: $white; 18 | background: $brand-primary; 19 | } 20 | 21 | .appIntro { 22 | font-size: $fs-1; 23 | } 24 | 25 | .appTitle { 26 | font-size: $fs-2; 27 | } 28 | 29 | @keyframes appLogoSpin { 30 | from { 31 | transform: rotate(0deg); 32 | } 33 | 34 | to { 35 | transform: rotate(360deg); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import ObjectSpread from './ObjectSpread'; 11 | 12 | describe('object spread', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/eslint-config-react-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-config-react-app", 3 | "version": "2.1.0", 4 | "description": "ESLint configuration used by Create React App", 5 | "repository": "facebookincubator/create-react-app", 6 | "license": "MIT", 7 | "bugs": { 8 | "url": "https://github.com/facebookincubator/create-react-app/issues" 9 | }, 10 | "files": [ 11 | "index.js" 12 | ], 13 | "peerDependencies": { 14 | "babel-eslint": "^7.2.3", 15 | "eslint": "^4.1.1", 16 | "eslint-plugin-flowtype": "^2.34.1", 17 | "eslint-plugin-import": "^2.6.0", 18 | "eslint-plugin-jsx-a11y": "^5.1.1", 19 | "eslint-plugin-react": "^7.1.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/lines-around.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import { getLinesAround } from '../utils/getLinesAround'; 9 | 10 | const arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight']; 11 | 12 | test('should return lines around from a string', () => { 13 | expect(getLinesAround(4, 2, arr)).toMatchSnapshot(); 14 | }); 15 | 16 | test('should return lines around from an array', () => { 17 | expect(getLinesAround(4, 2, arr.join('\n'))).toMatchSnapshot(); 18 | }); 19 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import RestAndDefault from './RestAndDefault'; 11 | 12 | describe('rest + default', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import RestParameters from './RestParameters'; 11 | 12 | describe('rest parameters', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/utils/isInternalFile.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | function isInternalFile(sourceFileName: ?string, fileName: ?string) { 10 | return ( 11 | sourceFileName == null || 12 | sourceFileName === '' || 13 | sourceFileName.indexOf('/~/') !== -1 || 14 | sourceFileName.indexOf('/node_modules/') !== -1 || 15 | sourceFileName.trim().indexOf(' ') !== -1 || 16 | fileName == null || 17 | fileName === '' 18 | ); 19 | } 20 | 21 | export { isInternalFile }; 22 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import ClassProperties from './ClassProperties'; 11 | 12 | describe('class properties', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import DefaultParameters from './DefaultParameters'; 11 | 12 | describe('default parameters', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | 11 | describe('promises', () => { 12 | it('renders without crashing', () => { 13 | const div = document.createElement('div'); 14 | return import('./Promises').then(({ default: Promises }) => { 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/utils/isBultinErrorName.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | function isBultinErrorName(errorName: ?string) { 10 | switch (errorName) { 11 | case 'EvalError': 12 | case 'InternalError': 13 | case 'RangeError': 14 | case 'ReferenceError': 15 | case 'SyntaxError': 16 | case 'TypeError': 17 | case 'URIError': 18 | return true; 19 | default: 20 | return false; 21 | } 22 | } 23 | 24 | export { isBultinErrorName }; 25 | export default isBultinErrorName; 26 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import ArrayDestructuring from './ArrayDestructuring'; 11 | 12 | describe('array destructuring', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import ComputedProperties from './ComputedProperties'; 11 | 12 | describe('computed properties', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/parser/safari.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import { parse } from '../../utils/parser'; 9 | 10 | test('stack with eval', () => { 11 | expect( 12 | parse( 13 | `e@file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:25:18 14 | eval code 15 | eval@[native code] 16 | a@file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:8:10 17 | global code@file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:32:8` 18 | ) 19 | ).toMatchSnapshot(); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import CustomInterpolation from './CustomInterpolation'; 11 | 12 | describe('custom interpolation', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import ObjectDestructuring from './ObjectDestructuring'; 11 | 12 | describe('object destructuring', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import DestructuringAndAwait from './DestructuringAndAwait'; 11 | 12 | describe('destructuring and await', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import TemplateInterpolation from './TemplateInterpolation'; 11 | 12 | describe('template interpolation', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | return new Promise(resolve => { 16 | ReactDOM.render(, div); 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/env/ExpandEnvVariables.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | 10 | export default () => ( 11 | 12 | {process.env.REACT_APP_BASIC} 13 | {process.env.REACT_APP_BASIC_EXPAND} 14 | 15 | {process.env.REACT_APP_BASIC_EXPAND_SIMPLE} 16 | 17 | 18 | {process.env.REACT_APP_EXPAND_EXISTING} 19 | 20 | 21 | ); 22 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | import { test, version } from 'test-integrity'; 11 | import LinkedModules from './LinkedModules'; 12 | 13 | describe('linked modules', () => { 14 | it('has integrity', () => { 15 | expect(test()); 16 | expect(version() === '2.0.0'); 17 | }); 18 | 19 | it('renders without crashing', () => { 20 | const div = document.createElement('div'); 21 | ReactDOM.render(, div); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /packages/babel-preset-react-app/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 'use strict'; 8 | 9 | const create = require('./create'); 10 | 11 | // This is similar to how `env` works in Babel: 12 | // https://babeljs.io/docs/usage/babelrc/#env-option 13 | // We are not using `env` because it’s ignored in versions > babel-core@6.10.4: 14 | // https://github.com/babel/babel/issues/4539 15 | // https://github.com/facebookincubator/create-react-app/issues/720 16 | // It’s also nice that we can enforce `NODE_ENV` being specified. 17 | var env = process.env.BABEL_ENV || process.env.NODE_ENV; 18 | 19 | module.exports = create(env); 20 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dist: trusty 3 | language: node_js 4 | node_js: 5 | - 8 6 | - 9 7 | cache: 8 | directories: 9 | - node_modules 10 | - packages/create-react-app/node_modules 11 | - packages/react-scripts/node_modules 12 | install: true 13 | script: 14 | - 'if [ $TEST_SUITE = "simple" ]; then tasks/e2e-simple.sh; fi' 15 | - 'if [ $TEST_SUITE = "installs" ]; then tasks/e2e-installs.sh; fi' 16 | - 'if [ $TEST_SUITE = "kitchensink" ]; then tasks/e2e-kitchensink.sh; fi' 17 | - 'if [ $TEST_SUITE = "old-node" ]; then tasks/e2e-old-node.sh; fi' 18 | env: 19 | matrix: 20 | - TEST_SUITE=simple 21 | - TEST_SUITE=installs 22 | - TEST_SUITE=kitchensink 23 | matrix: 24 | include: 25 | - node_js: 0.10 26 | env: TEST_SUITE=old-node 27 | - node_js: 6 28 | env: TEST_SUITE=kitchensink 29 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/components/Footer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | import React from 'react'; 10 | import { darkGray } from '../styles'; 11 | 12 | const footerStyle = { 13 | fontFamily: 'sans-serif', 14 | color: darkGray, 15 | marginTop: '0.5rem', 16 | flex: '0 0 auto', 17 | }; 18 | 19 | type FooterPropsType = {| 20 | line1: string, 21 | line2?: string, 22 | |}; 23 | 24 | function Footer(props: FooterPropsType) { 25 | return ( 26 |
27 | {props.line1} 28 |
29 | {props.line2} 30 |
31 | ); 32 | } 33 | 34 | export default Footer; 35 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React from 'react'; 9 | 10 | export default () => ( 11 | 12 | 13 | {process.env.REACT_APP_ORIGINAL_1} 14 | 15 | 16 | {process.env.REACT_APP_ORIGINAL_2} 17 | 18 | 19 | {process.env.REACT_APP_DEVELOPMENT} 20 | {process.env.REACT_APP_PRODUCTION} 21 | 22 | {process.env.REACT_APP_X} 23 | 24 | ); 25 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/utils/pollyfills.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | if (typeof Promise === 'undefined') { 9 | // Rejection tracking prevents a common issue where React gets into an 10 | // inconsistent state due to an error, but it gets swallowed by a Promise, 11 | // and the user has no idea what causes React's erratic future behavior. 12 | require('promise/lib/rejection-tracking').enable(); 13 | window.Promise = require('promise/lib/es6-extensions.js'); 14 | } 15 | 16 | // Object.assign() is commonly used with React. 17 | // It will use the native implementation if it's present and isn't buggy. 18 | Object.assign = require('object-assign'); 19 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/parser/chrome.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import { parse } from '../../utils/parser'; 9 | 10 | test('stack with eval', () => { 11 | expect( 12 | parse( 13 | `TypeError: window[f] is not a function 14 | at e (file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:25:18) 15 | at eval (eval at c (file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:12:9), :1:1) 16 | at a (file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:8:9) 17 | at file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:32:7` 18 | ) 19 | ).toMatchSnapshot(); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/react-dev-utils/errorOverlayMiddleware.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 'use strict'; 8 | 9 | const launchEditor = require('./launchEditor'); 10 | const launchEditorEndpoint = require('./launchEditorEndpoint'); 11 | 12 | module.exports = function createLaunchEditorMiddleware() { 13 | return function launchEditorMiddleware(req, res, next) { 14 | if (req.url.startsWith(launchEditorEndpoint)) { 15 | const lineNumber = parseInt(req.query.lineNumber, 10) || 1; 16 | const colNumber = parseInt(req.query.colNumber, 10) || 1; 17 | launchEditor(req.query.fileName, lineNumber, colNumber); 18 | res.end(); 19 | } else { 20 | next(); 21 | } 22 | }; 23 | }; 24 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/parser/generic.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import { parse } from '../../utils/parser'; 9 | 10 | test('throws on null', () => { 11 | expect.assertions(2); 12 | try { 13 | parse(null); 14 | } catch (e) { 15 | expect(e instanceof Error).toBe(true); 16 | expect(e.message).toBe('You cannot pass a null object.'); 17 | } 18 | }); 19 | 20 | test('throws on unparsable', () => { 21 | expect.assertions(2); 22 | try { 23 | parse({}); 24 | } catch (e) { 25 | expect(e instanceof Error).toBe(true); 26 | expect(e.message).toBe( 27 | 'The error you provided does not contain a stack trace.' 28 | ); 29 | } 30 | }); 31 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/__snapshots__/stack-frame.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`proper empty shape 1`] = ` 4 | StackFrame { 5 | "_originalColumnNumber": null, 6 | "_originalFileName": null, 7 | "_originalFunctionName": null, 8 | "_originalLineNumber": null, 9 | "_originalScriptCode": null, 10 | "_scriptCode": null, 11 | "columnNumber": null, 12 | "fileName": null, 13 | "functionName": null, 14 | "lineNumber": null, 15 | } 16 | `; 17 | 18 | exports[`proper full shape 1`] = ` 19 | StackFrame { 20 | "_originalColumnNumber": 13, 21 | "_originalFileName": "test.js", 22 | "_originalFunctionName": "apple", 23 | "_originalLineNumber": 37, 24 | "_originalScriptCode": null, 25 | "_scriptCode": null, 26 | "columnNumber": 37, 27 | "fileName": "b.js", 28 | "functionName": "a", 29 | "lineNumber": 13, 30 | } 31 | `; 32 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/components/Header.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | import React from 'react'; 10 | import { red } from '../styles'; 11 | 12 | const headerStyle = { 13 | fontSize: '2em', 14 | fontFamily: 'sans-serif', 15 | color: red, 16 | whiteSpace: 'pre-wrap', 17 | // Top bottom margin spaces header 18 | // Right margin revents overlap with close button 19 | margin: '0 2rem 0.75rem 0', 20 | flex: '0 0 auto', 21 | maxHeight: '50%', 22 | overflow: 'auto', 23 | }; 24 | 25 | type HeaderPropType = {| 26 | headerText: string, 27 | |}; 28 | 29 | function Header(props: HeaderPropType) { 30 | return
{props.headerText}
; 31 | } 32 | 33 | export default Header; 34 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/components/CloseButton.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | import React from 'react'; 10 | import { black } from '../styles'; 11 | 12 | const closeButtonStyle = { 13 | color: black, 14 | lineHeight: '1rem', 15 | fontSize: '1.5rem', 16 | padding: '1rem', 17 | cursor: 'pointer', 18 | position: 'absolute', 19 | right: 0, 20 | top: 0, 21 | }; 22 | 23 | type CloseCallback = () => void; 24 | function CloseButton({ close }: {| close: CloseCallback |}) { 25 | return ( 26 | 31 | × 32 | 33 | ); 34 | } 35 | 36 | export default CloseButton; 37 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | export default class extends Component { 12 | static propTypes = { 13 | onReady: PropTypes.func.isRequired, 14 | }; 15 | 16 | users = [ 17 | { id: 1, name: '1' }, 18 | { id: 2, name: '2' }, 19 | { id: 3, name: '3' }, 20 | { id: 4, name: '4' }, 21 | ]; 22 | 23 | componentDidMount() { 24 | this.props.onReady(); 25 | } 26 | 27 | render() { 28 | return ( 29 |
30 | {this.users.map(user =>
{user.name}
)} 31 |
32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/create-react-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "create-react-app", 3 | "version": "1.5.2", 4 | "keywords": [ 5 | "react" 6 | ], 7 | "description": "Create React apps with no build configuration.", 8 | "repository": "facebookincubator/create-react-app", 9 | "license": "MIT", 10 | "engines": { 11 | "node": ">=4" 12 | }, 13 | "bugs": { 14 | "url": "https://github.com/facebookincubator/create-react-app/issues" 15 | }, 16 | "files": [ 17 | "index.js", 18 | "createReactApp.js" 19 | ], 20 | "bin": { 21 | "create-react-app": "./index.js" 22 | }, 23 | "dependencies": { 24 | "chalk": "^1.1.1", 25 | "commander": "^2.9.0", 26 | "cross-spawn": "^4.0.0", 27 | "envinfo": "3.4.2", 28 | "fs-extra": "^1.0.0", 29 | "hyperquest": "^2.1.2", 30 | "semver": "^5.0.3", 31 | "tar-pack": "^3.4.0", 32 | "tmp": "0.0.31", 33 | "validate-npm-package-name": "^3.0.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tasks/replace-own-deps.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /** 3 | * Copyright (c) 2015-present, Facebook, Inc. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | 'use strict'; 9 | 10 | // Replaces internal dependencies in package.json with local package paths. 11 | 12 | const fs = require('fs'); 13 | const path = require('path'); 14 | 15 | const packagesDir = path.join(__dirname, '../packages'); 16 | const pkgFilename = path.join(packagesDir, 'react-scripts/package.json'); 17 | const data = require(pkgFilename); 18 | 19 | fs.readdirSync(packagesDir).forEach((name) => { 20 | if (data.dependencies[name]) { 21 | data.dependencies[name] = 'file:' + path.join(packagesDir, name); 22 | } 23 | }) 24 | 25 | fs.writeFile(pkgFilename, JSON.stringify(data, null, 2), 'utf8', (err) => { 26 | if (err) throw err; 27 | console.log('Replaced local dependencies.'); 28 | }); 29 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2017 2 | 3 | environment: 4 | matrix: 5 | - nodejs_version: 8 6 | test_suite: "simple" 7 | - nodejs_version: 8 8 | test_suite: "installs" 9 | - nodejs_version: 8 10 | test_suite: "kitchensink" 11 | - nodejs_version: 6 12 | test_suite: "simple" 13 | - nodejs_version: 6 14 | test_suite: "installs" 15 | - nodejs_version: 6 16 | test_suite: "kitchensink" 17 | 18 | cache: 19 | - node_modules -> appveyor.cleanup-cache.txt 20 | - packages\react-scripts\node_modules -> appveyor.cleanup-cache.txt 21 | 22 | clone_depth: 50 23 | 24 | matrix: 25 | fast_finish: true 26 | 27 | platform: 28 | - x64 29 | 30 | install: 31 | - ps: Install-Product node $env:nodejs_version $env:platform 32 | 33 | build: off 34 | 35 | skip_commits: 36 | files: 37 | - '**/*.md' 38 | 39 | test_script: 40 | - node --version 41 | - npm --version 42 | - bash tasks/e2e-%test_suite%.sh 43 | -------------------------------------------------------------------------------- /packages/react-error-overlay/webpack.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 'use strict'; 8 | 9 | const path = require('path'); 10 | 11 | module.exports = { 12 | entry: './src/index.js', 13 | output: { 14 | path: path.join(__dirname, './lib'), 15 | filename: 'index.js', 16 | library: 'ReactErrorOverlay', 17 | libraryTarget: 'umd', 18 | }, 19 | module: { 20 | rules: [ 21 | { 22 | test: /iframe-bundle\.js$/, 23 | use: 'raw-loader', 24 | }, 25 | { 26 | test: /\.js$/, 27 | include: path.resolve(__dirname, './src'), 28 | use: 'babel-loader', 29 | }, 30 | ], 31 | }, 32 | resolve: { 33 | alias: { 34 | iframeScript$: path.resolve(__dirname, './lib/iframe-bundle.js'), 35 | }, 36 | }, 37 | }; 38 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/extract-source-map.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import { extractSourceMapUrl } from '../utils/getSourceMap'; 9 | 10 | test('extracts last source map directive', async () => { 11 | const res = await extractSourceMapUrl( 12 | `test.js`, 13 | `//# sourceMappingURL=test.js.map\nconsole.log('a')\n//# sourceMappingURL=bundle.js.map` 14 | ); 15 | expect(res).toBe('bundle.js.map'); 16 | }); 17 | 18 | test('errors when no source map', async () => { 19 | expect.assertions(1); 20 | 21 | const testFileName = 'test.js'; 22 | try { 23 | await extractSourceMapUrl( 24 | testFileName, 25 | `console.log('hi')\n\nconsole.log('bye')` 26 | ); 27 | } catch (e) { 28 | expect(e).toBe(`Cannot find a source map directive for ${testFileName}.`); 29 | } 30 | }); 31 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | import load from 'absoluteLoad'; 11 | 12 | export default class extends Component { 13 | static propTypes = { 14 | onReady: PropTypes.func.isRequired, 15 | }; 16 | 17 | constructor(props) { 18 | super(props); 19 | this.state = { users: [] }; 20 | } 21 | 22 | async componentDidMount() { 23 | const users = load(); 24 | this.setState({ users }); 25 | } 26 | 27 | componentDidUpdate() { 28 | this.props.onReady(); 29 | } 30 | 31 | render() { 32 | return ( 33 |
34 | {this.state.users.map(user =>
{user.name}
)} 35 |
36 | ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/react-dev-utils/checkRequiredFiles.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | var fs = require('fs'); 11 | var path = require('path'); 12 | var chalk = require('chalk'); 13 | 14 | function checkRequiredFiles(files) { 15 | var currentFilePath; 16 | try { 17 | files.forEach(filePath => { 18 | currentFilePath = filePath; 19 | fs.accessSync(filePath, fs.F_OK); 20 | }); 21 | return true; 22 | } catch (err) { 23 | var dirName = path.dirname(currentFilePath); 24 | var fileName = path.basename(currentFilePath); 25 | console.log(chalk.red('Could not find a required file.')); 26 | console.log(chalk.red(' Name: ') + chalk.cyan(fileName)); 27 | console.log(chalk.red(' Searched in: ') + chalk.cyan(dirName)); 28 | return false; 29 | } 30 | } 31 | 32 | module.exports = checkRequiredFiles; 33 | -------------------------------------------------------------------------------- /packages/react-scripts/template/src/shared/styles/mixins.scss: -------------------------------------------------------------------------------- 1 | @mixin _position($position, $args) { 2 | @each $dir in top, left, bottom, right { 3 | $i: index($args, $dir); 4 | 5 | @if $i { 6 | #{$dir}: nth($args, $i + 1); 7 | } 8 | } 9 | 10 | position: $position; 11 | } 12 | 13 | @mixin absolute($args) { 14 | @include _position(absolute, $args); 15 | } 16 | 17 | @mixin relative($args) { 18 | @include _position(relative, $args); 19 | } 20 | 21 | @mixin fixed($args) { 22 | @include _position(fixed, $args); 23 | } 24 | 25 | @mixin sizing($args, $prefix: "") { 26 | $width: if(length($args) == 2, nth($args, 1), $args); 27 | $height: if(length($args) == 2, nth($args, 2), $args); 28 | 29 | #{$prefix}width: $width; 30 | #{$prefix}height: $height; 31 | } 32 | 33 | @mixin min-sizing($args) { 34 | @include sizing($args, "min-"); 35 | } 36 | 37 | @mixin max-sizing($args) { 38 | @include sizing($args, "max-"); 39 | } 40 | 41 | @mixin circle($args) { 42 | @include sizing($args); 43 | 44 | border-radius: 50%; 45 | } 46 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/stack-frame.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import { StackFrame } from '../utils/stack-frame'; 9 | 10 | test('proper empty shape', () => { 11 | const empty = new StackFrame(); 12 | expect(empty).toMatchSnapshot(); 13 | 14 | expect(empty.getFunctionName()).toBe('(anonymous function)'); 15 | expect(empty.getSource()).toBe(''); 16 | expect(empty.toString()).toBe('(anonymous function)'); 17 | }); 18 | 19 | test('proper full shape', () => { 20 | const empty = new StackFrame( 21 | 'a', 22 | 'b.js', 23 | 13, 24 | 37, 25 | undefined, 26 | 'apple', 27 | 'test.js', 28 | 37, 29 | 13 30 | ); 31 | expect(empty).toMatchSnapshot(); 32 | 33 | expect(empty.getFunctionName()).toBe('a'); 34 | expect(empty.getSource()).toBe('b.js:13:37'); 35 | expect(empty.toString()).toBe('a (b.js:13:37)'); 36 | }); 37 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/utils/getLinesAround.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | import { ScriptLine } from './stack-frame'; 10 | 11 | /** 12 | * 13 | * @param {number} line The line number to provide context around. 14 | * @param {number} count The number of lines you'd like for context. 15 | * @param {string[] | string} lines The source code. 16 | */ 17 | function getLinesAround( 18 | line: number, 19 | count: number, 20 | lines: string[] | string 21 | ): ScriptLine[] { 22 | if (typeof lines === 'string') { 23 | lines = lines.split('\n'); 24 | } 25 | const result = []; 26 | for ( 27 | let index = Math.max(0, line - 1 - count); 28 | index <= Math.min(lines.length - 1, line - 1 + count); 29 | ++index 30 | ) { 31 | result.push(new ScriptLine(index + 1, lines[index], index === line - 1)); 32 | } 33 | return result; 34 | } 35 | 36 | export { getLinesAround }; 37 | export default getLinesAround; 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2013-present, Facebook, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | function load() { 12 | return [[1, '1'], [2, '2'], [3, '3'], [4, '4']]; 13 | } 14 | 15 | export default class extends Component { 16 | static propTypes = { 17 | onReady: PropTypes.func.isRequired, 18 | }; 19 | 20 | constructor(props) { 21 | super(props); 22 | this.state = { users: [] }; 23 | } 24 | 25 | async componentDidMount() { 26 | const users = load(); 27 | this.setState({ users }); 28 | } 29 | 30 | componentDidUpdate() { 31 | this.props.onReady(); 32 | } 33 | 34 | render() { 35 | return ( 36 |
37 | {this.state.users.map(user => { 38 | const [id, name] = user; 39 | return
{name}
; 40 | })} 41 |
42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | async function load() { 12 | return [ 13 | { id: 1, name: '1' }, 14 | { id: 2, name: '2' }, 15 | { id: 3, name: '3' }, 16 | { id: 4, name: '4' }, 17 | ]; 18 | } 19 | 20 | export default class extends Component { 21 | static propTypes = { 22 | onReady: PropTypes.func.isRequired, 23 | }; 24 | 25 | constructor(props) { 26 | super(props); 27 | this.state = { users: [] }; 28 | } 29 | 30 | async componentDidMount() { 31 | const users = await load(); 32 | this.setState({ users }); 33 | } 34 | 35 | componentDidUpdate() { 36 | this.props.onReady(); 37 | } 38 | 39 | render() { 40 | return ( 41 |
42 | {this.state.users.map(user =>
{user.name}
)} 43 |
44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | function load(users) { 12 | return [ 13 | { id: 1, name: '1' }, 14 | { id: 2, name: '2' }, 15 | { id: 3, name: '3' }, 16 | ...users, 17 | ]; 18 | } 19 | 20 | export default class extends Component { 21 | static propTypes = { 22 | onReady: PropTypes.func.isRequired, 23 | }; 24 | 25 | constructor(props) { 26 | super(props); 27 | this.state = { users: [] }; 28 | } 29 | 30 | async componentDidMount() { 31 | const users = load([{ id: 42, name: '42' }]); 32 | this.setState({ users }); 33 | } 34 | 35 | componentDidUpdate() { 36 | this.props.onReady(); 37 | } 38 | 39 | render() { 40 | return ( 41 |
42 | {this.state.users.map(user =>
{user.name}
)} 43 |
44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | function load() { 12 | return Promise.resolve([ 13 | { id: 1, name: '1' }, 14 | { id: 2, name: '2' }, 15 | { id: 3, name: '3' }, 16 | { id: 4, name: '4' }, 17 | ]); 18 | } 19 | 20 | export default class extends Component { 21 | static propTypes = { 22 | onReady: PropTypes.func.isRequired, 23 | }; 24 | 25 | constructor(props) { 26 | super(props); 27 | this.state = { users: [] }; 28 | } 29 | 30 | componentDidMount() { 31 | load().then(users => { 32 | this.setState({ users }); 33 | }); 34 | } 35 | 36 | componentDidUpdate() { 37 | this.props.onReady(); 38 | } 39 | 40 | render() { 41 | return ( 42 |
43 | {this.state.users.map(user =>
{user.name}
)} 44 |
45 | ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | function* load(limit) { 12 | let i = 1; 13 | while (i <= limit) { 14 | yield { id: i, name: i }; 15 | i++; 16 | } 17 | } 18 | 19 | export default class extends Component { 20 | static propTypes = { 21 | onReady: PropTypes.func.isRequired, 22 | }; 23 | 24 | constructor(props) { 25 | super(props); 26 | this.state = { users: [] }; 27 | } 28 | 29 | componentDidMount() { 30 | const users = []; 31 | for (let user of load(4)) { 32 | users.push(user); 33 | } 34 | this.setState({ users }); 35 | } 36 | 37 | componentDidUpdate() { 38 | this.props.onReady(); 39 | } 40 | 41 | render() { 42 | return ( 43 |
44 | {this.state.users.map(user =>
{user.name}
)} 45 |
46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | function load(id = 0) { 12 | return [ 13 | { id: id + 1, name: '1' }, 14 | { id: id + 2, name: '2' }, 15 | { id: id + 3, name: '3' }, 16 | { id: id + 4, name: '4' }, 17 | ]; 18 | } 19 | 20 | export default class extends Component { 21 | static propTypes = { 22 | onReady: PropTypes.func.isRequired, 23 | }; 24 | 25 | constructor(props) { 26 | super(props); 27 | this.state = { users: [] }; 28 | } 29 | 30 | async componentDidMount() { 31 | const users = load(); 32 | this.setState({ users }); 33 | } 34 | 35 | componentDidUpdate() { 36 | this.props.onReady(); 37 | } 38 | 39 | render() { 40 | return ( 41 |
42 | {this.state.users.map(user =>
{user.name}
)} 43 |
44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/utils/dom/absolutifyCaret.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | function removeNextBr(parent, component: ?Element) { 10 | while (component != null && component.tagName.toLowerCase() !== 'br') { 11 | component = component.nextElementSibling; 12 | } 13 | if (component != null) { 14 | parent.removeChild(component); 15 | } 16 | } 17 | 18 | function absolutifyCaret(component: Node) { 19 | const ccn = component.childNodes; 20 | for (let index = 0; index < ccn.length; ++index) { 21 | const c = ccn[index]; 22 | // $FlowFixMe 23 | if (c.tagName.toLowerCase() !== 'span') { 24 | continue; 25 | } 26 | const _text = c.innerText; 27 | if (_text == null) { 28 | continue; 29 | } 30 | const text = _text.replace(/\s/g, ''); 31 | if (text !== '|^') { 32 | continue; 33 | } 34 | // $FlowFixMe 35 | c.style.position = 'absolute'; 36 | // $FlowFixMe 37 | removeNextBr(component, c); 38 | } 39 | } 40 | 41 | export { absolutifyCaret }; 42 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | function load(name) { 12 | return [ 13 | { id: 1, name: `${name}1` }, 14 | { id: 2, name: `${name}2` }, 15 | { id: 3, name: `${name}3` }, 16 | { id: 4, name: `${name}4` }, 17 | ]; 18 | } 19 | 20 | export default class extends Component { 21 | static propTypes = { 22 | onReady: PropTypes.func.isRequired, 23 | }; 24 | 25 | constructor(props) { 26 | super(props); 27 | this.state = { users: [] }; 28 | } 29 | 30 | async componentDidMount() { 31 | const users = load('user_'); 32 | this.setState({ users }); 33 | } 34 | 35 | componentDidUpdate() { 36 | this.props.onReady(); 37 | } 38 | 39 | render() { 40 | return ( 41 |
42 | {this.state.users.map(user =>
{user.name}
)} 43 |
44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/react-scripts/config/polyfills.js: -------------------------------------------------------------------------------- 1 | // @remove-on-eject-begin 2 | /** 3 | * Copyright (c) 2015-present, Facebook, Inc. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | */ 8 | // @remove-on-eject-end 9 | 'use strict'; 10 | 11 | if (typeof Promise === 'undefined') { 12 | // Rejection tracking prevents a common issue where React gets into an 13 | // inconsistent state due to an error, but it gets swallowed by a Promise, 14 | // and the user has no idea what causes React's erratic future behavior. 15 | require('promise/lib/rejection-tracking').enable(); 16 | window.Promise = require('promise/lib/es6-extensions.js'); 17 | } 18 | 19 | // fetch() polyfill for making API calls. 20 | require('whatwg-fetch'); 21 | 22 | // Object.assign() is commonly used with React. 23 | // It will use the native implementation if it's present and isn't buggy. 24 | Object.assign = require('object-assign'); 25 | 26 | // In tests, polyfill requestAnimationFrame since jsdom doesn't provide it yet. 27 | // We don't polyfill it in the browser--this is user's responsibility. 28 | if (process.env.NODE_ENV === 'test') { 29 | require('raf').polyfill(global); 30 | } 31 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | function load({ id, ...rest } = { id: 0, user: { id: 42, name: '42' } }) { 12 | return [ 13 | { id: id + 1, name: '1' }, 14 | { id: id + 2, name: '2' }, 15 | { id: id + 3, name: '3' }, 16 | rest.user, 17 | ]; 18 | } 19 | 20 | export default class extends Component { 21 | static propTypes = { 22 | onReady: PropTypes.func.isRequired, 23 | }; 24 | 25 | constructor(props) { 26 | super(props); 27 | this.state = { users: [] }; 28 | } 29 | 30 | async componentDidMount() { 31 | const users = load(); 32 | this.setState({ users }); 33 | } 34 | 35 | componentDidUpdate() { 36 | this.props.onReady(); 37 | } 38 | 39 | render() { 40 | return ( 41 |
42 | {this.state.users.map(user =>
{user.name}
)} 43 |
44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | function load({ id = 0, ...rest }) { 12 | return [ 13 | { id: id + 1, name: '1' }, 14 | { id: id + 2, name: '2' }, 15 | { id: id + 3, name: '3' }, 16 | rest.user, 17 | ]; 18 | } 19 | 20 | export default class extends Component { 21 | static propTypes = { 22 | onReady: PropTypes.func.isRequired, 23 | }; 24 | 25 | constructor(props) { 26 | super(props); 27 | this.state = { users: [] }; 28 | } 29 | 30 | async componentDidMount() { 31 | const users = load({ id: 0, user: { id: 42, name: '42' } }); 32 | this.setState({ users }); 33 | } 34 | 35 | componentDidUpdate() { 36 | this.props.onReady(); 37 | } 38 | 39 | render() { 40 | return ( 41 |
42 | {this.state.users.map(user =>
{user.name}
)} 43 |
44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | async function load() { 12 | return { 13 | users: [ 14 | { id: 1, name: '1' }, 15 | { id: 2, name: '2' }, 16 | { id: 3, name: '3' }, 17 | { id: 4, name: '4' }, 18 | ], 19 | }; 20 | } 21 | 22 | export default class extends Component { 23 | static propTypes = { 24 | onReady: PropTypes.func.isRequired, 25 | }; 26 | 27 | constructor(props) { 28 | super(props); 29 | this.state = { users: [] }; 30 | } 31 | 32 | async componentDidMount() { 33 | const { users } = await load(); 34 | this.setState({ users }); 35 | } 36 | 37 | componentDidUpdate() { 38 | this.props.onReady(); 39 | } 40 | 41 | render() { 42 | return ( 43 |
44 | {this.state.users.map(user =>
{user.name}
)} 45 |
46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/styles.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | const black = '#293238', 10 | darkGray = '#878e91', 11 | red = '#ce1126', 12 | redTransparent = 'rgba(206, 17, 38, 0.05)', 13 | lightRed = '#fccfcf', 14 | yellow = '#fbf5b4', 15 | yellowTransparent = 'rgba(251, 245, 180, 0.3)', 16 | white = '#ffffff'; 17 | 18 | const iframeStyle = { 19 | position: 'fixed', 20 | top: '0', 21 | left: '0', 22 | width: '100%', 23 | height: '100%', 24 | border: 'none', 25 | 'z-index': 2147483647, 26 | }; 27 | 28 | const overlayStyle = { 29 | width: '100%', 30 | height: '100%', 31 | 'box-sizing': 'border-box', 32 | 'text-align': 'center', 33 | 'background-color': white, 34 | }; 35 | 36 | const primaryErrorStyle = { 37 | 'background-color': lightRed, 38 | }; 39 | 40 | const secondaryErrorStyle = { 41 | 'background-color': yellow, 42 | }; 43 | 44 | export { 45 | iframeStyle, 46 | overlayStyle, 47 | primaryErrorStyle, 48 | secondaryErrorStyle, 49 | black, 50 | darkGray, 51 | red, 52 | redTransparent, 53 | yellowTransparent, 54 | }; 55 | -------------------------------------------------------------------------------- /packages/react-dev-utils/WatchMissingNodeModulesPlugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | // This Webpack plugin ensures `npm install ` forces a project rebuild. 9 | // We’re not sure why this isn't Webpack's default behavior. 10 | // See https://github.com/facebookincubator/create-react-app/issues/186. 11 | 12 | 'use strict'; 13 | 14 | class WatchMissingNodeModulesPlugin { 15 | constructor(nodeModulesPath) { 16 | this.nodeModulesPath = nodeModulesPath; 17 | } 18 | 19 | apply(compiler) { 20 | compiler.plugin('emit', (compilation, callback) => { 21 | var missingDeps = compilation.missingDependencies; 22 | var nodeModulesPath = this.nodeModulesPath; 23 | 24 | // If any missing files are expected to appear in node_modules... 25 | if (missingDeps.some(file => file.indexOf(nodeModulesPath) !== -1)) { 26 | // ...tell webpack to watch node_modules recursively until they appear. 27 | compilation.contextDependencies.push(nodeModulesPath); 28 | } 29 | 30 | callback(); 31 | }); 32 | } 33 | } 34 | 35 | module.exports = WatchMissingNodeModulesPlugin; 36 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | function load(prefix) { 12 | return [ 13 | { id: 1, [`${prefix} name`]: '1' }, 14 | { id: 2, [`${prefix} name`]: '2' }, 15 | { id: 3, [`${prefix} name`]: '3' }, 16 | { id: 4, [`${prefix} name`]: '4' }, 17 | ]; 18 | } 19 | 20 | export default class extends Component { 21 | static propTypes = { 22 | onReady: PropTypes.func.isRequired, 23 | }; 24 | 25 | constructor(props) { 26 | super(props); 27 | this.state = { users: [] }; 28 | } 29 | 30 | async componentDidMount() { 31 | const users = load('user_'); 32 | this.setState({ users }); 33 | } 34 | 35 | componentDidUpdate() { 36 | this.props.onReady(); 37 | } 38 | 39 | render() { 40 | return ( 41 |
42 | {this.state.users.map(user => ( 43 |
{user.user_name}
44 | ))} 45 |
46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/babel-preset-react-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-preset-react-app", 3 | "version": "3.1.2", 4 | "description": "Babel preset used by Create React App", 5 | "repository": "facebookincubator/create-react-app", 6 | "license": "MIT", 7 | "bugs": { 8 | "url": "https://github.com/facebookincubator/create-react-app/issues" 9 | }, 10 | "files": [ 11 | "index.js", 12 | "create.js", 13 | "dev.js", 14 | "prod.js", 15 | "test.js" 16 | ], 17 | "dependencies": { 18 | "babel-plugin-dynamic-import-node": "1.1.0", 19 | "babel-plugin-syntax-dynamic-import": "6.18.0", 20 | "babel-plugin-transform-class-properties": "6.24.1", 21 | "babel-plugin-transform-es2015-destructuring": "6.23.0", 22 | "babel-plugin-transform-object-rest-spread": "6.26.0", 23 | "babel-plugin-transform-react-constant-elements": "6.23.0", 24 | "babel-plugin-transform-react-jsx": "6.24.1", 25 | "babel-plugin-transform-react-jsx-self": "6.22.0", 26 | "babel-plugin-transform-react-jsx-source": "6.22.0", 27 | "babel-plugin-transform-regenerator": "6.26.0", 28 | "babel-plugin-transform-runtime": "6.23.0", 29 | "babel-preset-env": "1.6.1", 30 | "babel-preset-react": "6.24.1" 31 | }, 32 | "peerDependencies": { 33 | "babel-runtime": "^6.23.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | function load(baseUser) { 12 | return [ 13 | { id: 1, name: '1', ...baseUser }, 14 | { id: 2, name: '2', ...baseUser }, 15 | { id: 3, name: '3', ...baseUser }, 16 | { id: 4, name: '4', ...baseUser }, 17 | ]; 18 | } 19 | 20 | export default class extends Component { 21 | static propTypes = { 22 | onReady: PropTypes.func.isRequired, 23 | }; 24 | 25 | constructor(props) { 26 | super(props); 27 | this.state = { users: [] }; 28 | } 29 | 30 | async componentDidMount() { 31 | const users = load({ age: 42 }); 32 | this.setState({ users }); 33 | } 34 | 35 | componentDidUpdate() { 36 | this.props.onReady(); 37 | } 38 | 39 | render() { 40 | return ( 41 |
42 | {this.state.users.map(user => ( 43 |
44 | {user.name}: {user.age} 45 |
46 | ))} 47 |
48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /tasks/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2015-present, Facebook, Inc. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # ****************************************************************************** 8 | # This releases an update to the `react-scripts` package. 9 | # Don't use `npm publish` for it. 10 | # Read the release instructions: 11 | # https://github.com/facebookincubator/create-react-app/blob/master/CONTRIBUTING.md#cutting-a-release 12 | # ****************************************************************************** 13 | 14 | # Start in tasks/ even if run from root directory 15 | cd "$(dirname "$0")" 16 | 17 | # Exit the script on any command with non 0 return code 18 | # We assume that all the commands in the pipeline set their return code 19 | # properly and that we do not need to validate that the output is correct 20 | set -e 21 | 22 | # Echo every command being executed 23 | set -x 24 | 25 | # Go to root 26 | cd .. 27 | root_path=$PWD 28 | 29 | if [ -n "$(git status --porcelain)" ]; then 30 | echo "Your git status is not clean. Aborting."; 31 | exit 1; 32 | fi 33 | 34 | # Compile 35 | cd packages/react-error-overlay/ 36 | npm run build:prod 37 | cd ../.. 38 | # Go! 39 | ./node_modules/.bin/lerna publish --independent "$@" -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "workspaces": [ 4 | "packages/*" 5 | ], 6 | "scripts": { 7 | "build": "cd packages/react-scripts && node scripts/build.js", 8 | "changelog": "lerna-changelog", 9 | "create-react-app": "node tasks/cra.js", 10 | "e2e": "tasks/e2e-simple.sh", 11 | "e2e:docker": "tasks/local-test.sh", 12 | "postinstall": "cd packages/react-error-overlay/ && yarn build:prod", 13 | "publish": "tasks/publish.sh", 14 | "start": "cd packages/react-scripts && node scripts/start.js", 15 | "screencast": "svg-term --cast hItN7sl5yfCPTHxvFg5glhhfp --out screencast.svg --window", 16 | "test": "cd packages/react-scripts && node scripts/test.js --env=jsdom", 17 | "format": "prettier --trailing-comma es5 --single-quote --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'", 18 | "precommit": "lint-staged" 19 | }, 20 | "devDependencies": { 21 | "eslint": "^4.4.1", 22 | "husky": "^0.13.2", 23 | "lerna": "2.6.0", 24 | "lerna-changelog": "^0.6.0", 25 | "lint-staged": "^3.3.1", 26 | "prettier": "1.6.1", 27 | "svg-term-cli": "^2.0.3" 28 | }, 29 | "lint-staged": { 30 | "*.js": [ 31 | "prettier --trailing-comma es5 --single-quote --write", 32 | "git add" 33 | ], 34 | "yarn.lock": [ 35 | "git rm --cached" 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/react-scripts/template/src/components/App/index.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { hot } from 'react-hot-loader'; 3 | import logo from './logo.svg'; 4 | import LogoInline from './logo.inline.svg'; 5 | import styles from './style.scss'; 6 | 7 | class App extends Component { 8 | state = { 9 | count: 0, 10 | }; 11 | 12 | componentDidMount() { 13 | setInterval(this.increment, 1000); 14 | } 15 | 16 | componentWillUnmount() { 17 | clearInterval(this.increment); 18 | } 19 | 20 | increment = () => { 21 | this.setState(prevState => ({ 22 | count: prevState.count + 1, 23 | })); 24 | }; 25 | 26 | render() { 27 | return ( 28 |
29 |
30 | 31 | logo 32 |

33 | Welcome to React | Count: {this.state.count} 34 |

35 |
36 |

37 | To get started, edit src/components/App/index.js and save 38 | to reload. 39 |

40 |
41 | ); 42 | } 43 | } 44 | 45 | export { App as AppUnwrapped }; 46 | export default hot(module)(App); 47 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/components/CodeBlock.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | import React from 'react'; 10 | import { redTransparent, yellowTransparent } from '../styles'; 11 | 12 | const _preStyle = { 13 | display: 'block', 14 | padding: '0.5em', 15 | marginTop: '0.5em', 16 | marginBottom: '0.5em', 17 | overflowX: 'auto', 18 | whiteSpace: 'pre-wrap', 19 | borderRadius: '0.25rem', 20 | }; 21 | 22 | const primaryPreStyle = { 23 | ..._preStyle, 24 | backgroundColor: redTransparent, 25 | }; 26 | 27 | const secondaryPreStyle = { 28 | ..._preStyle, 29 | backgroundColor: yellowTransparent, 30 | }; 31 | 32 | const codeStyle = { 33 | fontFamily: 'Consolas, Menlo, monospace', 34 | }; 35 | 36 | type CodeBlockPropsType = {| 37 | main: boolean, 38 | codeHTML: string, 39 | |}; 40 | 41 | function CodeBlock(props: CodeBlockPropsType) { 42 | const preStyle = props.main ? primaryPreStyle : secondaryPreStyle; 43 | const codeBlock = { __html: props.codeHTML }; 44 | 45 | return ( 46 |
47 |       
48 |     
49 | ); 50 | } 51 | 52 | export default CodeBlock; 53 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/effects/stackTraceLimit.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | let stackTraceRegistered: boolean = false; 10 | // Default: https://docs.microsoft.com/en-us/scripting/javascript/reference/stacktracelimit-property-error-javascript 11 | let restoreStackTraceValue: number = 10; 12 | 13 | const MAX_STACK_LENGTH: number = 50; 14 | 15 | function registerStackTraceLimit(limit: number = MAX_STACK_LENGTH) { 16 | if (stackTraceRegistered) { 17 | return; 18 | } 19 | try { 20 | restoreStackTraceValue = Error.stackTraceLimit; 21 | Error.stackTraceLimit = limit; 22 | stackTraceRegistered = true; 23 | } catch (e) { 24 | // Not all browsers support this so we don't care if it errors 25 | } 26 | } 27 | 28 | function unregisterStackTraceLimit() { 29 | if (!stackTraceRegistered) { 30 | return; 31 | } 32 | try { 33 | Error.stackTraceLimit = restoreStackTraceValue; 34 | stackTraceRegistered = false; 35 | } catch (e) { 36 | // Not all browsers support this so we don't care if it errors 37 | } 38 | } 39 | 40 | export { 41 | registerStackTraceLimit as register, 42 | unregisterStackTraceLimit as unregister, 43 | }; 44 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | function load() { 12 | return [ 13 | { id: 1, name: '1' }, 14 | { id: 2, name: '2' }, 15 | { id: 3, name: '3' }, 16 | { id: 4, name: '4' }, 17 | ]; 18 | } 19 | 20 | export default class extends Component { 21 | static propTypes = { 22 | onReady: PropTypes.func.isRequired, 23 | }; 24 | 25 | constructor(props) { 26 | super(props); 27 | this.state = { users: [] }; 28 | } 29 | 30 | async componentDidMount() { 31 | const users = load(); 32 | this.setState({ users }); 33 | } 34 | 35 | componentDidUpdate() { 36 | this.props.onReady(); 37 | } 38 | 39 | render() { 40 | return ( 41 |
42 | {this.state.users.map(user => { 43 | const { id, ...rest } = user; 44 | // eslint-disable-next-line no-unused-vars 45 | const [{ name, ...innerRest }] = [{ ...rest }]; 46 | return
{name}
; 47 | })} 48 |
49 | ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/__snapshots__/lines-around.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should return lines around from a string 1`] = ` 4 | Array [ 5 | ScriptLine { 6 | "content": "two", 7 | "highlight": false, 8 | "lineNumber": 2, 9 | }, 10 | ScriptLine { 11 | "content": "three", 12 | "highlight": false, 13 | "lineNumber": 3, 14 | }, 15 | ScriptLine { 16 | "content": "four", 17 | "highlight": true, 18 | "lineNumber": 4, 19 | }, 20 | ScriptLine { 21 | "content": "five", 22 | "highlight": false, 23 | "lineNumber": 5, 24 | }, 25 | ScriptLine { 26 | "content": "six", 27 | "highlight": false, 28 | "lineNumber": 6, 29 | }, 30 | ] 31 | `; 32 | 33 | exports[`should return lines around from an array 1`] = ` 34 | Array [ 35 | ScriptLine { 36 | "content": "two", 37 | "highlight": false, 38 | "lineNumber": 2, 39 | }, 40 | ScriptLine { 41 | "content": "three", 42 | "highlight": false, 43 | "lineNumber": 3, 44 | }, 45 | ScriptLine { 46 | "content": "four", 47 | "highlight": true, 48 | "lineNumber": 4, 49 | }, 50 | ScriptLine { 51 | "content": "five", 52 | "highlight": false, 53 | "lineNumber": 5, 54 | }, 55 | ScriptLine { 56 | "content": "six", 57 | "highlight": false, 58 | "lineNumber": 6, 59 | }, 60 | ] 61 | `; 62 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/effects/unhandledError.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | let boundErrorHandler = null; 10 | 11 | type ErrorCallback = (error: Error) => void; 12 | 13 | function errorHandler(callback: ErrorCallback, e: Event): void { 14 | if (!e.error) { 15 | return; 16 | } 17 | // $FlowFixMe 18 | const { error } = e; 19 | if (error instanceof Error) { 20 | callback(error); 21 | } else { 22 | // A non-error was thrown, we don't have a trace. :( 23 | // Look in your browser's devtools for more information 24 | callback(new Error(error)); 25 | } 26 | } 27 | 28 | function registerUnhandledError(target: EventTarget, callback: ErrorCallback) { 29 | if (boundErrorHandler !== null) { 30 | return; 31 | } 32 | boundErrorHandler = errorHandler.bind(undefined, callback); 33 | target.addEventListener('error', boundErrorHandler); 34 | } 35 | 36 | function unregisterUnhandledError(target: EventTarget) { 37 | if (boundErrorHandler === null) { 38 | return; 39 | } 40 | target.removeEventListener('error', boundErrorHandler); 41 | boundErrorHandler = null; 42 | } 43 | 44 | export { 45 | registerUnhandledError as register, 46 | unregisterUnhandledError as unregister, 47 | }; 48 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/utils/dom/css.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | let injectedCount = 0; 10 | const injectedCache = {}; 11 | 12 | function getHead(document: Document) { 13 | return document.head || document.getElementsByTagName('head')[0]; 14 | } 15 | 16 | function injectCss(document: Document, css: string): number { 17 | const head = getHead(document); 18 | const style = document.createElement('style'); 19 | style.type = 'text/css'; 20 | style.appendChild(document.createTextNode(css)); 21 | head.appendChild(style); 22 | 23 | injectedCache[++injectedCount] = style; 24 | return injectedCount; 25 | } 26 | 27 | function removeCss(document: Document, ref: number) { 28 | if (injectedCache[ref] == null) { 29 | return; 30 | } 31 | const head = getHead(document); 32 | head.removeChild(injectedCache[ref]); 33 | delete injectedCache[ref]; 34 | } 35 | 36 | function applyStyles(element: HTMLElement, styles: Object) { 37 | element.setAttribute('style', ''); 38 | for (const key in styles) { 39 | if (!styles.hasOwnProperty(key)) { 40 | continue; 41 | } 42 | // $FlowFixMe 43 | element.style[key] = styles[key]; 44 | } 45 | } 46 | 47 | export { getHead, injectCss, removeCss, applyStyles }; 48 | -------------------------------------------------------------------------------- /packages/react-dev-utils/printBuildError.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | const chalk = require('chalk'); 11 | 12 | module.exports = function printBuildError(err) { 13 | const message = err != null && err.message; 14 | const stack = err != null && err.stack; 15 | 16 | // Add more helpful message for UglifyJs error 17 | if ( 18 | stack && 19 | typeof message === 'string' && 20 | message.indexOf('from UglifyJs') !== -1 21 | ) { 22 | try { 23 | const matched = /(.+)\[(.+):(.+),(.+)\]\[.+\]/.exec(stack); 24 | if (!matched) { 25 | throw new Error('Using errors for control flow is bad.'); 26 | } 27 | const problemPath = matched[2]; 28 | const line = matched[3]; 29 | const column = matched[4]; 30 | console.log( 31 | 'Failed to minify the code from this file: \n\n', 32 | chalk.yellow( 33 | `\t${problemPath}:${line}${column !== '0' ? ':' + column : ''}` 34 | ), 35 | '\n' 36 | ); 37 | } catch (ignored) { 38 | console.log('Failed to minify the bundle.', err); 39 | } 40 | console.log('Read more here: http://bit.ly/2tRViJ9'); 41 | } else { 42 | console.log((message || err) + '\n'); 43 | } 44 | console.log(); 45 | }; 46 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/parser/__snapshots__/safari.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`stack with eval 1`] = ` 4 | Array [ 5 | StackFrame { 6 | "_originalColumnNumber": null, 7 | "_originalFileName": null, 8 | "_originalFunctionName": null, 9 | "_originalLineNumber": null, 10 | "_originalScriptCode": null, 11 | "_scriptCode": null, 12 | "columnNumber": 18, 13 | "fileName": "file:///Users/joe/Documents/Development/OSS/stack-frame/index.html", 14 | "functionName": "e", 15 | "lineNumber": 25, 16 | }, 17 | StackFrame { 18 | "_originalColumnNumber": null, 19 | "_originalFileName": null, 20 | "_originalFunctionName": null, 21 | "_originalLineNumber": null, 22 | "_originalScriptCode": null, 23 | "_scriptCode": null, 24 | "columnNumber": 10, 25 | "fileName": "file:///Users/joe/Documents/Development/OSS/stack-frame/index.html", 26 | "functionName": "a", 27 | "lineNumber": 8, 28 | }, 29 | StackFrame { 30 | "_originalColumnNumber": null, 31 | "_originalFileName": null, 32 | "_originalFunctionName": null, 33 | "_originalLineNumber": null, 34 | "_originalScriptCode": null, 35 | "_scriptCode": null, 36 | "columnNumber": 8, 37 | "fileName": "file:///Users/joe/Documents/Development/OSS/stack-frame/index.html", 38 | "functionName": "global code", 39 | "lineNumber": 32, 40 | }, 41 | ] 42 | `; 43 | -------------------------------------------------------------------------------- /packages/react-error-overlay/webpack.config.iframe.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 'use strict'; 8 | 9 | const path = require('path'); 10 | const webpack = require('webpack'); 11 | 12 | module.exports = { 13 | entry: './src/iframeScript.js', 14 | output: { 15 | path: path.join(__dirname, './lib'), 16 | filename: 'iframe-bundle.js', 17 | }, 18 | module: { 19 | rules: [ 20 | { 21 | test: /\.js$/, 22 | include: path.resolve(__dirname, './src'), 23 | use: 'babel-loader', 24 | }, 25 | ], 26 | }, 27 | plugins: [ 28 | new webpack.DefinePlugin({ 29 | // We set process.env.NODE_ENV to 'production' so that React is built 30 | // in production mode. 31 | 'process.env': { NODE_ENV: '"production"' }, 32 | // This prevents our bundled React from accidentally hijacking devtools. 33 | __REACT_DEVTOOLS_GLOBAL_HOOK__: '({})', 34 | }), 35 | // This code is embedded as a string, so it would never be optimized 36 | // elsewhere. 37 | new webpack.optimize.UglifyJsPlugin({ 38 | compress: { 39 | warnings: false, 40 | comparisons: false, 41 | }, 42 | output: { 43 | comments: false, 44 | ascii_only: false, 45 | }, 46 | }), 47 | ], 48 | }; 49 | -------------------------------------------------------------------------------- /packages/react-dev-utils/noopServiceWorkerMiddleware.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | module.exports = function createNoopServiceWorkerMiddleware() { 11 | return function noopServiceWorkerMiddleware(req, res, next) { 12 | if (req.url === '/service-worker.js') { 13 | res.setHeader('Content-Type', 'text/javascript'); 14 | res.send( 15 | `// This service worker file is effectively a 'no-op' that will reset any 16 | // previous service worker registered for the same host:port combination. 17 | // In the production build, this file is replaced with an actual service worker 18 | // file that will precache your site's local assets. 19 | // See https://github.com/facebookincubator/create-react-app/issues/2272#issuecomment-302832432 20 | 21 | self.addEventListener('install', () => self.skipWaiting()); 22 | 23 | self.addEventListener('activate', () => { 24 | self.clients.matchAll({ type: 'window' }).then(windowClients => { 25 | for (let windowClient of windowClients) { 26 | // Force open pages to refresh, so that they have a chance to load the 27 | // fresh navigation response from the local dev server. 28 | windowClient.navigate(windowClient.url); 29 | } 30 | }); 31 | }); 32 | ` 33 | ); 34 | } else { 35 | next(); 36 | } 37 | }; 38 | }; 39 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/utils/getStackFrames.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | import type { StackFrame } from './stack-frame'; 10 | import { parse } from './parser'; 11 | import { map } from './mapper'; 12 | import { unmap } from './unmapper'; 13 | 14 | function getStackFrames( 15 | error: Error, 16 | unhandledRejection: boolean = false, 17 | contextSize: number = 3 18 | ): Promise { 19 | const parsedFrames = parse(error); 20 | let enhancedFramesPromise; 21 | if (error.__unmap_source) { 22 | enhancedFramesPromise = unmap( 23 | // $FlowFixMe 24 | error.__unmap_source, 25 | parsedFrames, 26 | contextSize 27 | ); 28 | } else { 29 | enhancedFramesPromise = map(parsedFrames, contextSize); 30 | } 31 | return enhancedFramesPromise.then(enhancedFrames => { 32 | if ( 33 | enhancedFrames 34 | .map(f => f._originalFileName) 35 | .filter(f => f != null && f.indexOf('node_modules') === -1).length === 0 36 | ) { 37 | return null; 38 | } 39 | return enhancedFrames.filter( 40 | ({ functionName }) => 41 | functionName == null || 42 | functionName.indexOf('__stack_frame_overlay_proxy_console__') === -1 43 | ); 44 | }); 45 | } 46 | 47 | export default getStackFrames; 48 | export { getStackFrames }; 49 | -------------------------------------------------------------------------------- /packages/react-dev-utils/InterpolateHtmlPlugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | // This Webpack plugin lets us interpolate custom variables into `index.html`. 9 | // Usage: `new InterpolateHtmlPlugin({ 'MY_VARIABLE': 42 })` 10 | // Then, you can use %MY_VARIABLE% in your `index.html`. 11 | 12 | // It works in tandem with HtmlWebpackPlugin. 13 | // Learn more about creating plugins like this: 14 | // https://github.com/ampedandwired/html-webpack-plugin#events 15 | 16 | 'use strict'; 17 | const escapeStringRegexp = require('escape-string-regexp'); 18 | 19 | class InterpolateHtmlPlugin { 20 | constructor(replacements) { 21 | this.replacements = replacements; 22 | } 23 | 24 | apply(compiler) { 25 | compiler.plugin('compilation', compilation => { 26 | compilation.plugin( 27 | 'html-webpack-plugin-before-html-processing', 28 | (data, callback) => { 29 | // Run HTML through a series of user-specified string replacements. 30 | Object.keys(this.replacements).forEach(key => { 31 | const value = this.replacements[key]; 32 | data.html = data.html.replace( 33 | new RegExp('%' + escapeStringRegexp(key) + '%', 'g'), 34 | value 35 | ); 36 | }); 37 | callback(null, data); 38 | } 39 | ); 40 | }); 41 | } 42 | } 43 | 44 | module.exports = InterpolateHtmlPlugin; 45 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import React, { Component } from 'react'; 9 | import PropTypes from 'prop-types'; 10 | 11 | const styled = ([style]) => 12 | style 13 | .trim() 14 | .split(/\s*;\s*/) 15 | .map(rule => rule.split(/\s*:\s*/)) 16 | .reduce((rules, rule) => ({ ...rules, [rule[0]]: rule[1] }), {}); 17 | 18 | function load() { 19 | return [ 20 | { id: 1, name: '1' }, 21 | { id: 2, name: '2' }, 22 | { id: 3, name: '3' }, 23 | { id: 4, name: '4' }, 24 | ]; 25 | } 26 | 27 | export default class extends Component { 28 | static propTypes = { 29 | onReady: PropTypes.func.isRequired, 30 | }; 31 | 32 | constructor(props) { 33 | super(props); 34 | this.state = { users: [] }; 35 | } 36 | 37 | async componentDidMount() { 38 | const users = load(); 39 | this.setState({ users }); 40 | } 41 | 42 | componentDidUpdate() { 43 | this.props.onReady(); 44 | } 45 | 46 | render() { 47 | const veryInlineStyle = styled` 48 | background: palevioletred; 49 | color: papayawhip; 50 | `; 51 | 52 | return ( 53 |
54 | {this.state.users.map(user => ( 55 |
56 | {user.name} 57 |
58 | ))} 59 |
60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/effects/unhandledRejection.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | let boundRejectionHandler = null; 10 | 11 | type ErrorCallback = (error: Error) => void; 12 | 13 | function rejectionHandler( 14 | callback: ErrorCallback, 15 | e: PromiseRejectionEvent 16 | ): void { 17 | if (e == null || e.reason == null) { 18 | return callback(new Error('Unknown')); 19 | } 20 | let { reason } = e; 21 | if (reason instanceof Error) { 22 | return callback(reason); 23 | } 24 | // A non-error was rejected, we don't have a trace :( 25 | // Look in your browser's devtools for more information 26 | return callback(new Error(reason)); 27 | } 28 | 29 | function registerUnhandledRejection( 30 | target: EventTarget, 31 | callback: ErrorCallback 32 | ) { 33 | if (boundRejectionHandler !== null) { 34 | return; 35 | } 36 | boundRejectionHandler = rejectionHandler.bind(undefined, callback); 37 | // $FlowFixMe 38 | target.addEventListener('unhandledrejection', boundRejectionHandler); 39 | } 40 | 41 | function unregisterUnhandledRejection(target: EventTarget) { 42 | if (boundRejectionHandler === null) { 43 | return; 44 | } 45 | // $FlowFixMe 46 | target.removeEventListener('unhandledrejection', boundRejectionHandler); 47 | boundRejectionHandler = null; 48 | } 49 | 50 | export { 51 | registerUnhandledRejection as register, 52 | unregisterUnhandledRejection as unregister, 53 | }; 54 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/parser/__snapshots__/react.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`15.y.z 1`] = ` 4 | Array [ 5 | StackFrame { 6 | "_originalColumnNumber": null, 7 | "_originalFileName": null, 8 | "_originalFunctionName": null, 9 | "_originalLineNumber": null, 10 | "_originalScriptCode": null, 11 | "_scriptCode": null, 12 | "columnNumber": null, 13 | "fileName": "FileA.js", 14 | "functionName": "div", 15 | "lineNumber": 9, 16 | }, 17 | StackFrame { 18 | "_originalColumnNumber": null, 19 | "_originalFileName": null, 20 | "_originalFunctionName": null, 21 | "_originalLineNumber": null, 22 | "_originalScriptCode": null, 23 | "_scriptCode": null, 24 | "columnNumber": null, 25 | "fileName": "App.js", 26 | "functionName": "FileA", 27 | "lineNumber": 9, 28 | }, 29 | StackFrame { 30 | "_originalColumnNumber": null, 31 | "_originalFileName": null, 32 | "_originalFunctionName": null, 33 | "_originalLineNumber": null, 34 | "_originalScriptCode": null, 35 | "_scriptCode": null, 36 | "columnNumber": null, 37 | "fileName": "App.js", 38 | "functionName": "div", 39 | "lineNumber": 8, 40 | }, 41 | StackFrame { 42 | "_originalColumnNumber": null, 43 | "_originalFileName": null, 44 | "_originalFunctionName": null, 45 | "_originalLineNumber": null, 46 | "_originalScriptCode": null, 47 | "_scriptCode": null, 48 | "columnNumber": null, 49 | "fileName": "index.js", 50 | "functionName": "App", 51 | "lineNumber": 7, 52 | }, 53 | ] 54 | `; 55 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/utils/getPrettyURL.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | function getPrettyURL( 10 | sourceFileName: ?string, 11 | sourceLineNumber: ?number, 12 | sourceColumnNumber: ?number, 13 | fileName: ?string, 14 | lineNumber: ?number, 15 | columnNumber: ?number, 16 | compiled: boolean 17 | ): string { 18 | let prettyURL; 19 | if (!compiled && sourceFileName && typeof sourceLineNumber === 'number') { 20 | // Remove everything up to the first /src/ or /node_modules/ 21 | const trimMatch = /^[/|\\].*?[/|\\]((src|node_modules)[/|\\].*)/.exec( 22 | sourceFileName 23 | ); 24 | if (trimMatch && trimMatch[1]) { 25 | prettyURL = trimMatch[1]; 26 | } else { 27 | prettyURL = sourceFileName; 28 | } 29 | prettyURL += ':' + sourceLineNumber; 30 | // Note: we intentionally skip 0's because they're produced by cheap Webpack maps 31 | if (sourceColumnNumber) { 32 | prettyURL += ':' + sourceColumnNumber; 33 | } 34 | } else if (fileName && typeof lineNumber === 'number') { 35 | prettyURL = fileName + ':' + lineNumber; 36 | // Note: we intentionally skip 0's because they're produced by cheap Webpack maps 37 | if (columnNumber) { 38 | prettyURL += ':' + columnNumber; 39 | } 40 | } else { 41 | prettyURL = 'unknown'; 42 | } 43 | return prettyURL.replace('webpack://', '.'); 44 | } 45 | 46 | export { getPrettyURL }; 47 | export default getPrettyURL; 48 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/utils/warnings.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | import type { ReactFrame } from '../effects/proxyConsole'; 10 | 11 | function stripInlineStacktrace(message: string): string { 12 | return message 13 | .split('\n') 14 | .filter(line => !line.match(/^\s*in/)) 15 | .join('\n'); // " in Foo" 16 | } 17 | 18 | function massage( 19 | warning: string, 20 | frames: ReactFrame[] 21 | ): { message: string, stack: string } { 22 | let message = stripInlineStacktrace(warning); 23 | 24 | // Reassemble the stack with full filenames provided by React 25 | let stack = ''; 26 | let lastFilename; 27 | let lastLineNumber; 28 | for (let index = 0; index < frames.length; ++index) { 29 | const { fileName, lineNumber } = frames[index]; 30 | if (fileName == null || lineNumber == null) { 31 | continue; 32 | } 33 | 34 | // TODO: instead, collapse them in the UI 35 | if ( 36 | fileName === lastFilename && 37 | typeof lineNumber === 'number' && 38 | typeof lastLineNumber === 'number' && 39 | Math.abs(lineNumber - lastLineNumber) < 3 40 | ) { 41 | continue; 42 | } 43 | lastFilename = fileName; 44 | lastLineNumber = lineNumber; 45 | 46 | let { name } = frames[index]; 47 | name = name || '(anonymous function)'; 48 | stack += `in ${name} (at ${fileName}:${lineNumber})\n`; 49 | } 50 | 51 | return { message, stack }; 52 | } 53 | 54 | export { massage }; 55 | -------------------------------------------------------------------------------- /packages/babel-preset-react-app/README.md: -------------------------------------------------------------------------------- 1 | # babel-preset-react-app 2 | 3 | This package includes the Babel preset used by [Create React App](https://github.com/facebookincubator/create-react-app).
4 | Please refer to its documentation: 5 | 6 | * [Getting Started](https://github.com/facebookincubator/create-react-app/blob/master/README.md#getting-started) – How to create a new app. 7 | * [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App. 8 | 9 | ## Usage in Create React App Projects 10 | 11 | The easiest way to use this configuration is with [Create React App](https://github.com/facebookincubator/create-react-app), which includes it by default. **You don’t need to install it separately in Create React App projects.** 12 | 13 | ## Usage Outside of Create React App 14 | 15 | If you want to use this Babel preset in a project not built with Create React App, you can install it with following steps. 16 | 17 | First, [install Babel](https://babeljs.io/docs/setup/). 18 | 19 | Then install babel-preset-react-app. 20 | 21 | ```sh 22 | npm install babel-preset-react-app --save-dev 23 | ``` 24 | 25 | Then create a file named `.babelrc` with following contents in the root folder of your project: 26 | 27 | ```js 28 | { 29 | "presets": ["react-app"] 30 | } 31 | ``` 32 | 33 | This preset uses the `useBuiltIns` option with [transform-object-rest-spread](http://babeljs.io/docs/plugins/transform-object-rest-spread/) and [transform-react-jsx](http://babeljs.io/docs/plugins/transform-react-jsx/), which assumes that `Object.assign` is available or polyfilled. 34 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/__tests__/parser/firefox.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | import { parse } from '../../utils/parser'; 9 | 10 | test('eval 1', () => { 11 | expect( 12 | parse( 13 | `test1@file:///C:/example.html line 7 > eval line 1 > eval:1:1 14 | test2@file:///C:/example.html line 7 > eval:1:1 15 | test3@file:///C:/example.html:7:6`.split('\n') 16 | ) 17 | ).toMatchSnapshot(); 18 | }); 19 | 20 | test('eval 2', () => { 21 | expect( 22 | parse({ 23 | stack: `anonymous@file:///C:/example.html line 7 > Function:1:1 24 | @file:///C:/example.html:7:6`, 25 | }) 26 | ).toMatchSnapshot(); 27 | }); 28 | 29 | test('stack with eval', () => { 30 | expect( 31 | parse( 32 | `e@file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:25:9 33 | @file:///Users/joe/Documents/Development/OSS/stack-frame/index.html line 17 > eval:1:1 34 | a@file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:8:9 35 | @file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:32:7` 36 | ) 37 | ).toMatchSnapshot(); 38 | }); 39 | 40 | test('v14 to v29', () => { 41 | expect( 42 | parse( 43 | `trace@file:///C:/example.html:9 44 | b@file:///C:/example.html:16 45 | a@file:///C:/example.html:19 46 | @file:///C:/example.html:21` 47 | ) 48 | ).toMatchSnapshot(); 49 | }); 50 | 51 | test('v30+', () => { 52 | expect( 53 | parse( 54 | `trace@file:///C:/example.html:9:17 55 | b@file:///C:/example.html:16:13 56 | a@file:///C:/example.html:19:13 57 | @file:///C:/example.html:21:9` 58 | ) 59 | ).toMatchSnapshot(); 60 | }); 61 | -------------------------------------------------------------------------------- /packages/react-scripts/template/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 22 | React App 23 | 24 | 25 | 28 |
29 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /packages/react-error-overlay/src/containers/CompileErrorContainer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | /* @flow */ 9 | import React, { PureComponent } from 'react'; 10 | import ErrorOverlay from '../components/ErrorOverlay'; 11 | import Footer from '../components/Footer'; 12 | import Header from '../components/Header'; 13 | import CodeBlock from '../components/CodeBlock'; 14 | import generateAnsiHTML from '../utils/generateAnsiHTML'; 15 | import parseCompileError from '../utils/parseCompileError'; 16 | import type { ErrorLocation } from '../utils/parseCompileError'; 17 | 18 | const codeAnchorStyle = { 19 | cursor: 'pointer', 20 | }; 21 | 22 | type Props = {| 23 | error: string, 24 | editorHandler: (errorLoc: ErrorLocation) => void, 25 | |}; 26 | 27 | class CompileErrorContainer extends PureComponent { 28 | render() { 29 | const { error, editorHandler } = this.props; 30 | const errLoc: ?ErrorLocation = parseCompileError(error); 31 | const canOpenInEditor = errLoc !== null && editorHandler !== null; 32 | return ( 33 | 34 |
35 | editorHandler(errLoc) : null 38 | } 39 | style={canOpenInEditor ? codeAnchorStyle : null} 40 | > 41 | 42 | 43 |