├── test ├── fixtures │ ├── typescript │ │ ├── .disable-pnp │ │ ├── package.json │ │ ├── tsconfig.json │ │ ├── index.test.js │ │ └── src │ │ │ ├── App.test.ts │ │ │ └── App.ts │ ├── boostrap-sass │ │ ├── .disable-pnp │ │ ├── src │ │ │ ├── index.sass │ │ │ └── index.js │ │ ├── package.json │ │ └── index.test.js │ ├── typescript-advanced │ │ ├── .disable-pnp │ │ ├── src │ │ │ ├── index.tsx │ │ │ ├── App.test.ts │ │ │ └── App.tsx │ │ ├── package.json │ │ └── index.test.js │ ├── typescript-typecheck │ │ ├── .disable-pnp │ │ ├── src │ │ │ ├── index.tsx │ │ │ └── App.tsx │ │ ├── package.json │ │ └── index.test.js │ ├── webpack-message-formatting │ │ ├── .disable-pnp │ │ ├── src │ │ │ ├── Export5.js │ │ │ ├── AppCss.css │ │ │ ├── AppSass.scss │ │ │ ├── ExportNoDefault.js │ │ │ ├── FooExport.js │ │ │ ├── index.js │ │ │ ├── AppLintWarning.js │ │ │ ├── AppCss.js │ │ │ ├── AppSass.js │ │ │ ├── AppBabel.js │ │ │ ├── AppLintError.js │ │ │ ├── AppIncorrectCase.js │ │ │ ├── AppNoDefault.js │ │ │ ├── AppUnknownFile.js │ │ │ ├── AppOutOfScopeImport.js │ │ │ ├── AppMissingPackage.js │ │ │ ├── AppUnknownExport.js │ │ │ └── AppAliasUnknownExport.js │ │ └── package.json │ ├── issue-5176-flow-class-properties │ │ ├── package.json │ │ ├── src │ │ │ ├── App.test.js │ │ │ └── App.js │ │ └── index.test.js │ ├── relative-paths │ │ ├── src │ │ │ ├── index.js │ │ │ └── index.css │ │ ├── package.json │ │ └── index.test.js │ ├── issue-5947-not-typescript │ │ ├── package.json │ │ └── index.test.js │ ├── mjs-support │ │ ├── src │ │ │ ├── index.js │ │ │ └── App.js │ │ ├── __snapshots__ │ │ │ └── index.test.js.snap │ │ ├── package.json │ │ └── index.test.js │ ├── __shared__ │ │ ├── template │ │ │ └── public │ │ │ │ └── index.html │ │ └── test-setup.js │ └── builds-with-multiple-runtimes │ │ ├── package.json │ │ ├── index.test.js │ │ └── src │ │ └── index.js └── jest.config.js ├── tasks ├── .gitignore ├── screencast.sh ├── screencast-start.js ├── verdaccio.yaml ├── publish.sh └── compile-lockfile.js ├── packages ├── react-scripts │ ├── .npmignore │ ├── fixtures │ │ └── kitchensink │ │ │ ├── src │ │ │ ├── features │ │ │ │ ├── webpack │ │ │ │ │ ├── assets │ │ │ │ │ │ ├── aFileWithExt.unknown │ │ │ │ │ │ ├── aFileWithoutExt │ │ │ │ │ │ ├── abstract.json │ │ │ │ │ │ ├── svg.css │ │ │ │ │ │ ├── sass-styles.sass │ │ │ │ │ │ ├── sass-styles.module.sass │ │ │ │ │ │ ├── style.module.css │ │ │ │ │ │ ├── index.module.css │ │ │ │ │ │ ├── index.module.sass │ │ │ │ │ │ ├── index.module.scss │ │ │ │ │ │ ├── scss-styles.module.scss │ │ │ │ │ │ ├── tiniest-cat.jpg │ │ │ │ │ │ ├── style.css │ │ │ │ │ │ └── scss-styles.scss │ │ │ │ │ ├── SvgInCss.js │ │ │ │ │ ├── SvgInCss.test.js │ │ │ │ │ ├── CssInclusion.js │ │ │ │ │ ├── SassInclusion.js │ │ │ │ │ ├── ScssInclusion.js │ │ │ │ │ ├── SvgInclusion.js │ │ │ │ │ ├── JsonInclusion.js │ │ │ │ │ ├── ImageInclusion.js │ │ │ │ │ ├── CssInclusion.test.js │ │ │ │ │ ├── SvgInclusion.test.js │ │ │ │ │ ├── JsonInclusion.test.js │ │ │ │ │ ├── SassInclusion.test.js │ │ │ │ │ ├── ScssInclusion.test.js │ │ │ │ │ ├── SvgComponent.js │ │ │ │ │ ├── ImageInclusion.test.js │ │ │ │ │ ├── NoExtInclusion.test.js │ │ │ │ │ ├── LinkedModules.js │ │ │ │ │ ├── CssModulesInclusion.test.js │ │ │ │ │ ├── NoExtInclusion.js │ │ │ │ │ ├── UnknownExtInclusion.test.js │ │ │ │ │ ├── SassModulesInclusion.test.js │ │ │ │ │ ├── ScssModulesInclusion.test.js │ │ │ │ │ ├── UnknownExtInclusion.js │ │ │ │ │ ├── CssModulesInclusion.js │ │ │ │ │ ├── SassModulesInclusion.js │ │ │ │ │ ├── ScssModulesInclusion.js │ │ │ │ │ ├── LinkedModules.test.js │ │ │ │ │ └── SvgComponent.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 │ │ │ │ │ ├── ArraySpread.js │ │ │ │ │ ├── Promises.js │ │ │ │ │ ├── Generators.js │ │ │ │ │ ├── DefaultParameters.js │ │ │ │ │ ├── TemplateInterpolation.js │ │ │ │ │ ├── RestAndDefault.js │ │ │ │ │ ├── RestParameters.js │ │ │ │ │ ├── DestructuringAndAwait.js │ │ │ │ │ ├── ComputedProperties.js │ │ │ │ │ ├── ObjectSpread.js │ │ │ │ │ ├── ObjectDestructuring.js │ │ │ │ │ └── AsyncAwait.js │ │ │ ├── subfolder │ │ │ │ └── lol.js │ │ │ ├── absoluteLoad.js │ │ │ └── index.js │ │ │ ├── .env.production │ │ │ ├── .env.development │ │ │ ├── .env.local │ │ │ ├── .flowconfig │ │ │ ├── public │ │ │ ├── favicon.ico │ │ │ └── index.html │ │ │ ├── jest.transform.js │ │ │ ├── jest.integration.config.js │ │ │ ├── .template.dependencies.json │ │ │ ├── gitignore │ │ │ └── .env │ ├── template │ │ ├── public │ │ │ ├── favicon.ico │ │ │ └── manifest.json │ │ ├── src │ │ │ ├── App.test.js │ │ │ ├── index.css │ │ │ ├── index.js │ │ │ ├── App.css │ │ │ └── App.js │ │ └── gitignore │ ├── template-typescript │ │ ├── public │ │ │ ├── favicon.ico │ │ │ └── manifest.json │ │ ├── src │ │ │ ├── App.test.tsx │ │ │ ├── index.css │ │ │ ├── index.tsx │ │ │ ├── App.css │ │ │ └── App.tsx │ │ └── gitignore │ ├── README.md │ ├── config │ │ └── jest │ │ │ ├── babelTransform.js │ │ │ ├── cssTransform.js │ │ │ └── fileTransform.js │ ├── LICENSE │ └── lib │ │ └── react-app.d.ts ├── react-error-overlay │ ├── .gitignore │ ├── .gitattributes │ ├── .babelrc │ ├── .npmignore │ ├── fixtures │ │ ├── inline.es6.mjs │ │ ├── inline.mjs │ │ └── junk-inline.mjs │ ├── .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 │ │ │ ├── lines-around.js │ │ │ ├── extract-source-map.js │ │ │ └── stack-frame.js │ │ ├── utils │ │ │ ├── isInternalFile.js │ │ │ ├── isBultinErrorName.js │ │ │ ├── getLinesAround.js │ │ │ ├── dom │ │ │ │ ├── absolutifyCaret.js │ │ │ │ └── css.js │ │ │ └── getStackFrames.js │ │ ├── components │ │ │ ├── Footer.js │ │ │ ├── Header.js │ │ │ ├── CloseButton.js │ │ │ └── CodeBlock.js │ │ ├── styles.js │ │ └── effects │ │ │ ├── stackTraceLimit.js │ │ │ └── unhandledError.js │ ├── flow │ │ └── env.js │ ├── README.md │ ├── LICENSE │ └── webpack.config.js ├── react-dev-utils │ ├── __tests__ │ │ └── .eslintrc │ ├── chalk.js │ ├── immer.js │ ├── globby.js │ ├── inquirer.js │ ├── crossSpawn.js │ ├── launchEditorEndpoint.js │ ├── ForkTsCheckerWebpackPlugin.js │ ├── clearConsole.js │ ├── ignoredFiles.js │ ├── getCacheIdentifier.js │ ├── errorOverlayMiddleware.js │ ├── checkRequiredFiles.js │ ├── LICENSE │ ├── WatchMissingNodeModulesPlugin.js │ ├── getCSSModuleLocalIdent.js │ ├── printBuildError.js │ └── noopServiceWorkerMiddleware.js ├── babel-preset-react-app │ ├── test.js │ ├── dev.js │ ├── prod.js │ ├── index.js │ ├── LICENSE │ ├── webpack-overrides.js │ └── package.json ├── create-react-app │ ├── README.md │ ├── package.json │ └── LICENSE ├── react-app-polyfill │ ├── jsdom.js │ ├── package.json │ ├── LICENSE │ ├── ie11.js │ ├── ie9.js │ └── README.md ├── confusing-browser-globals │ ├── package.json │ ├── test.js │ ├── LICENSE │ ├── index.js │ └── README.md ├── babel-plugin-named-asset-import │ ├── package.json │ └── LICENSE └── eslint-config-react-app │ ├── package.json │ └── LICENSE ├── .prettierrc ├── .github ├── CODEOWNERS ├── PULL_REQUEST_TEMPLATE.md └── lock.yml ├── .eslintignore ├── docusaurus ├── website │ ├── static │ │ ├── img │ │ │ ├── logo-og.png │ │ │ ├── update.png │ │ │ ├── oss_logo.png │ │ │ └── favicon │ │ │ │ └── favicon.ico │ │ └── css │ │ │ └── custom.css │ └── package.json └── docs │ ├── installing-a-dependency.md │ ├── alternatives-to-ejecting.md │ ├── using-global-variables.md │ ├── adding-a-router.md │ ├── can-i-use-decorators.md │ ├── documentation-intro.md │ ├── analyzing-the-bundle-size.md │ ├── adding-relay.md │ ├── using-https-in-development.md │ ├── pre-rendering-into-static-html-files.md │ ├── integrating-with-an-api-backend.md │ ├── adding-flow.md │ ├── folder-structure.md │ └── updating-to-new-releases.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── netlify.toml ├── .eslintrc.json ├── lerna.json ├── .travis.yml └── LICENSE /test/fixtures/typescript/.disable-pnp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tasks/.gitignore: -------------------------------------------------------------------------------- 1 | htpasswd 2 | storage 3 | -------------------------------------------------------------------------------- /test/fixtures/boostrap-sass/.disable-pnp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/react-scripts/.npmignore: -------------------------------------------------------------------------------- 1 | /fixtures 2 | -------------------------------------------------------------------------------- /test/fixtures/typescript-advanced/.disable-pnp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/typescript-typecheck/.disable-pnp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/.disable-pnp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/react-error-overlay/.gitignore: -------------------------------------------------------------------------------- 1 | lib/ 2 | coverage/ 3 | -------------------------------------------------------------------------------- /packages/react-error-overlay/.gitattributes: -------------------------------------------------------------------------------- 1 | *.js text eol=lf 2 | -------------------------------------------------------------------------------- /test/fixtures/issue-5176-flow-class-properties/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/fixtures/relative-paths/src/index.js: -------------------------------------------------------------------------------- 1 | import './index.css'; 2 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/Export5.js: -------------------------------------------------------------------------------- 1 | export default 5; 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 | -------------------------------------------------------------------------------- /test/fixtures/boostrap-sass/src/index.sass: -------------------------------------------------------------------------------- 1 | @import "~bootstrap/scss/bootstrap.scss"; 2 | -------------------------------------------------------------------------------- /test/fixtures/issue-5947-not-typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": {} 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/AppCss.css: -------------------------------------------------------------------------------- 1 | .App { 2 | color: red; 3 | }} 4 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/AppSass.scss: -------------------------------------------------------------------------------- 1 | .App { 2 | color: red; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/ExportNoDefault.js: -------------------------------------------------------------------------------- 1 | export const six = 6; 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "es5", 3 | "singleQuote": true, 4 | "semi": true 5 | } 6 | -------------------------------------------------------------------------------- /packages/react-dev-utils/__tests__/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "jest": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/aFileWithExt.unknown: -------------------------------------------------------------------------------- 1 | Whoooo, spooky! 2 | -------------------------------------------------------------------------------- /test/fixtures/typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "typescript": "3.1.3" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/FooExport.js: -------------------------------------------------------------------------------- 1 | export function foo() { 2 | console.log('bar'); 3 | } 4 | -------------------------------------------------------------------------------- /packages/react-error-overlay/fixtures/inline.es6.mjs: -------------------------------------------------------------------------------- 1 | function foo() { 2 | console.log('bar') 3 | } 4 | 5 | export { foo } 6 | -------------------------------------------------------------------------------- /test/fixtures/typescript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "experimentalDecorators": true 4 | } 5 | } 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 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | packages/ @amyrlam @bugzpodder @gaearon @ianschmitz @iansu @mrmckeb @petetnt @timer 2 | docusaurus/ @amyrlam @iansu 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | build 3 | my-app* 4 | packages/react-scripts/template 5 | packages/react-scripts/fixtures 6 | fixtures/ 7 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/.env.development: -------------------------------------------------------------------------------- 1 | REACT_APP_X = x-from-development-env 2 | REACT_APP_DEVELOPMENT = development 3 | -------------------------------------------------------------------------------- /docusaurus/website/static/img/logo-og.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesknelson/create-react-app/HEAD/docusaurus/website/static/img/logo-og.png -------------------------------------------------------------------------------- /docusaurus/website/static/img/update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesknelson/create-react-app/HEAD/docusaurus/website/static/img/update.png -------------------------------------------------------------------------------- /docusaurus/website/static/img/oss_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesknelson/create-react-app/HEAD/docusaurus/website/static/img/oss_logo.png -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/svg.css: -------------------------------------------------------------------------------- 1 | #feature-svg-in-css { 2 | background-image: url("./logo.svg"); 3 | } 4 | -------------------------------------------------------------------------------- /docusaurus/website/static/img/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesknelson/create-react-app/HEAD/docusaurus/website/static/img/favicon/favicon.ico -------------------------------------------------------------------------------- /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/fixtures/kitchensink/src/features/webpack/assets/sass-styles.sass: -------------------------------------------------------------------------------- 1 | #feature-sass-inclusion 2 | background: ghostwhite 3 | color: crimson 4 | -------------------------------------------------------------------------------- /packages/react-scripts/template/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesknelson/create-react-app/HEAD/packages/react-scripts/template/public/favicon.ico -------------------------------------------------------------------------------- /test/fixtures/relative-paths/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "react": "latest", 4 | "react-dom": "latest" 5 | }, 6 | "homepage": "." 7 | } 8 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/sass-styles.module.sass: -------------------------------------------------------------------------------- 1 | .sassModulesInclusion 2 | background: darkblue 3 | color: lightblue 4 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/style.module.css: -------------------------------------------------------------------------------- 1 | .cssModulesInclusion { 2 | background: darkblue; 3 | color: lightblue; 4 | } 5 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/index.module.css: -------------------------------------------------------------------------------- 1 | .cssModulesIndexInclusion { 2 | background: darkblue; 3 | color: lightblue; 4 | } 5 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/index.module.sass: -------------------------------------------------------------------------------- 1 | .sassModulesIndexInclusion 2 | background: darkblue 3 | color: lightblue 4 | 5 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/index.module.scss: -------------------------------------------------------------------------------- 1 | .scssModulesIndexInclusion { 2 | background: darkblue; 3 | color: lightblue; 4 | } 5 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/scss-styles.module.scss: -------------------------------------------------------------------------------- 1 | .scssModulesInclusion { 2 | background: darkblue; 3 | color: lightblue; 4 | } 5 | -------------------------------------------------------------------------------- /packages/react-scripts/template-typescript/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesknelson/create-react-app/HEAD/packages/react-scripts/template-typescript/public/favicon.ico -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesknelson/create-react-app/HEAD/packages/react-scripts/fixtures/kitchensink/public/favicon.ico -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/jest.transform.js: -------------------------------------------------------------------------------- 1 | const babelOptions = { presets: ['react-app'] }; 2 | 3 | module.exports = require('babel-jest').createTransformer(babelOptions); 4 | -------------------------------------------------------------------------------- /test/fixtures/boostrap-sass/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "bootstrap": "4.x", 4 | "node-sass": "4.x", 5 | "react": "latest", 6 | "react-dom": "latest" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/SvgInCss.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './assets/svg.css'; 3 | 4 | export default () =>
; 5 | -------------------------------------------------------------------------------- /test/fixtures/boostrap-sass/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.sass'; 4 | 5 | ReactDOM.render(
, document.getElementById('root')); 6 | -------------------------------------------------------------------------------- /test/fixtures/mjs-support/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | ReactDOM.render(, document.getElementById('root')); 6 | -------------------------------------------------------------------------------- /test/jest.config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | testEnvironment: 'node', 5 | testMatch: ['/**/*.test.js'], 6 | testPathIgnorePatterns: ['/src/', 'node_modules'], 7 | }; 8 | -------------------------------------------------------------------------------- /test/fixtures/issue-5176-flow-class-properties/src/App.test.js: -------------------------------------------------------------------------------- 1 | import App from './App'; 2 | 3 | it('creates instance without', () => { 4 | const app = new App(); 5 | expect(app.foo()).toBe('bar'); 6 | }); 7 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "react": "latest", 4 | "react-dom": "latest" 5 | }, 6 | "browserslist": [ 7 | ">0.2%" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/typescript-advanced/src/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import * as ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | ReactDOM.render(, document.getElementById('root')); 6 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | ReactDOM.render(, document.getElementById('root')); 6 | -------------------------------------------------------------------------------- /test/fixtures/relative-paths/src/index.css: -------------------------------------------------------------------------------- 1 | .RootSvg:before { 2 | display: block; 3 | content: ' '; 4 | background-image: url(./logo.svg); 5 | background-size: 28px 28px; 6 | height: 28px; 7 | width: 28px; 8 | } 9 | -------------------------------------------------------------------------------- /test/fixtures/typescript-typecheck/src/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import * as ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | ReactDOM.render(, document.getElementById('root')); 6 | -------------------------------------------------------------------------------- /test/fixtures/__shared__/template/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | React App 5 | 6 | 7 |
8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/jest.integration.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | testMatch: ['**/integration/*.test.js'], 4 | transform: { '^.+\\.js$': './jest.transform.js' }, 5 | }; 6 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/tiniest-cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesknelson/create-react-app/HEAD/packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/tiniest-cat.jpg -------------------------------------------------------------------------------- /test/fixtures/builds-with-multiple-runtimes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "dva": "2.4.0", 4 | "history": "4.7.2", 5 | "ky": "0.3.0", 6 | "react": "latest", 7 | "react-dom": "latest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/typescript-typecheck/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "@types/react": "*", 4 | "@types/react-dom": "*", 5 | "react": "*", 6 | "react-dom": "*", 7 | "typescript": "3.1.3" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/mjs-support/__snapshots__/index.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`can use mjs library in development 1`] = `"Pikachu"`; 4 | 5 | exports[`can use mjs library in production 1`] = `"Pikachu"`; 6 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /.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 | .npm/ 15 | -------------------------------------------------------------------------------- /test/fixtures/issue-5176-flow-class-properties/src/App.js: -------------------------------------------------------------------------------- 1 | class App { 2 | constructor() { 3 | this.foo = this.foo.bind(this); 4 | } 5 | foo: void => void; 6 | foo() { 7 | return 'bar'; 8 | } 9 | } 10 | 11 | export default App; 12 | -------------------------------------------------------------------------------- /test/fixtures/typescript-advanced/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "@types/react": "*", 4 | "@types/react-dom": "*", 5 | "@types/jest": "*", 6 | "react": "*", 7 | "react-dom": "*", 8 | "typescript": "3.1.3" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/AppLintWarning.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | function foo() {} 4 | 5 | class App extends Component { 6 | render() { 7 | return
; 8 | } 9 | } 10 | 11 | export default App; 12 | -------------------------------------------------------------------------------- /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.fb.com/codeofconduct/) so that you can understand what actions will and will not be tolerated. 4 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | base = "docusaurus/website" 3 | publish = "docusaurus/website/build" 4 | command = "yarn build" 5 | 6 | 7 | # A redirect rule with all the supported properties 8 | [[redirects]] 9 | from = "/" 10 | to = "/create-react-app" 11 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/AppCss.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import './AppCss.css'; 3 | 4 | class App extends Component { 5 | render() { 6 | return
; 7 | } 8 | } 9 | 10 | export default App; 11 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/AppSass.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import './AppSass.scss'; 3 | 4 | class App extends Component { 5 | render() { 6 | return
; 7 | } 8 | } 9 | 10 | export default App; 11 | -------------------------------------------------------------------------------- /test/fixtures/typescript/index.test.js: -------------------------------------------------------------------------------- 1 | const testSetup = require('../__shared__/test-setup'); 2 | 3 | test('passes tests', async () => { 4 | const { fulfilled } = await testSetup.scripts.test({ 5 | jestEnvironment: 'node', 6 | }); 7 | expect(fulfilled).toBe(true); 8 | }); 9 | -------------------------------------------------------------------------------- /test/fixtures/typescript-advanced/src/App.test.ts: -------------------------------------------------------------------------------- 1 | import App from './App'; 2 | 3 | it('reads a typescript file with no syntax error', () => { 4 | const app = new App({}); 5 | expect(App.foo.bar).toBe(true); 6 | expect(App.foo.baz!.n).toBe(123); 7 | expect(app.n).toBe(123); 8 | }); 9 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/AppBabel.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | class App extends Component { 4 | render() { 5 | return ( 6 |
7 | 8 |
9 | ); 10 | } 11 | } 12 | 13 | export default App; 14 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/AppLintError.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | function foo() { 4 | const a = b; 5 | } 6 | 7 | class App extends Component { 8 | render() { 9 | return
; 10 | } 11 | } 12 | 13 | export default App; 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/fixtures/mjs-support/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "apollo-boost": "0.1.16", 4 | "graphql": "14.0.2", 5 | "react-apollo": "2.2.1", 6 | "apollo-client": "2.4.2", 7 | "react": "latest", 8 | "react-dom": "latest", 9 | "serve": "10.0.2" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/AppIncorrectCase.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import five from './export5'; 3 | 4 | class App extends Component { 5 | render() { 6 | return
{five}
; 7 | } 8 | } 9 | 10 | export default App; 11 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/.template.dependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "bootstrap": "4.1.1", 4 | "jest": "24.5.0", 5 | "node-sass": "4.8.3", 6 | "normalize.css": "7.0.0", 7 | "prop-types": "15.5.6", 8 | "test-integrity": "1.0.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/fixtures/issue-5176-flow-class-properties/index.test.js: -------------------------------------------------------------------------------- 1 | const testSetup = require('../__shared__/test-setup'); 2 | 3 | test('passes tests', async () => { 4 | const { fulfilled } = await testSetup.scripts.test({ 5 | jestEnvironment: 'node', 6 | }); 7 | expect(fulfilled).toBe(true); 8 | }); 9 | -------------------------------------------------------------------------------- /test/fixtures/typescript-typecheck/src/App.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | class App extends React.Component { 4 | render() { 5 | return
{format(123)}
; 6 | } 7 | } 8 | 9 | function format(value: string) { 10 | return value; 11 | } 12 | 13 | export default App; 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/AppNoDefault.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import myImport from './ExportNoDefault'; 3 | 4 | class App extends Component { 5 | render() { 6 | return
{myImport}
; 7 | } 8 | } 9 | 10 | export default App; 11 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/AppUnknownFile.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import DefaultExport from './ThisFileSouldNotExist'; 3 | 4 | class App extends Component { 5 | render() { 6 | return
; 7 | } 8 | } 9 | 10 | export default App; 11 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/AppOutOfScopeImport.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import myImport from '../OutOfScopeImport'; 3 | 4 | class App extends Component { 5 | render() { 6 | return
{myImport}
; 7 | } 8 | } 9 | 10 | export default App; 11 | -------------------------------------------------------------------------------- /packages/react-scripts/template/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/AppMissingPackage.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { bar } from 'unknown-package'; 3 | 4 | class App extends Component { 5 | componentDidMount() { 6 | bar(); 7 | } 8 | render() { 9 | return
; 10 | } 11 | } 12 | 13 | export default App; 14 | -------------------------------------------------------------------------------- /packages/react-dev-utils/chalk.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 chalk = require('chalk'); 11 | 12 | module.exports = chalk; 13 | -------------------------------------------------------------------------------- /packages/react-dev-utils/immer.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 immer = require('immer'); 11 | 12 | module.exports = immer; 13 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/AppUnknownExport.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { bar } from './AppUnknownExport'; 3 | 4 | class App extends Component { 5 | componentDidMount() { 6 | bar(); 7 | } 8 | render() { 9 | return
; 10 | } 11 | } 12 | 13 | export default App; 14 | -------------------------------------------------------------------------------- /packages/react-dev-utils/globby.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 globby = require('globby'); 11 | 12 | module.exports = globby; 13 | -------------------------------------------------------------------------------- /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/react-scripts/template-typescript/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 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/src/features/webpack/assets/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Ensure CSS inclusion doesn't regress 3 | * https://github.com/facebook/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 | -------------------------------------------------------------------------------- /test/fixtures/webpack-message-formatting/src/AppAliasUnknownExport.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { bar as bar2 } from './AppUnknownExport'; 3 | 4 | class App extends Component { 5 | componentDidMount() { 6 | bar2(); 7 | } 8 | render() { 9 | return
; 10 | } 11 | } 12 | 13 | export default App; 14 | -------------------------------------------------------------------------------- /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-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 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint:recommended", 3 | "env": { 4 | "browser": true, 5 | "commonjs": true, 6 | "node": true, 7 | "es6": true 8 | }, 9 | "parserOptions": { 10 | "ecmaVersion": 2018 11 | }, 12 | "rules": { 13 | "no-console": "off", 14 | "strict": ["error", "global"], 15 | "curly": "warn" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/SvgInCss.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import SvgInCss from './SvgInCss'; 4 | 5 | describe('svg in css', () => { 6 | it('renders without crashing', () => { 7 | const div = document.createElement('div'); 8 | ReactDOM.render(, div); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /.github/lock.yml: -------------------------------------------------------------------------------- 1 | # Configuration for lock-threads - https://github.com/dessant/lock-threads 2 | 3 | # Number of days of inactivity before a closed issue or pull request is locked 4 | daysUntilLock: 5 5 | 6 | # Issues and pull requests with these labels will not be locked. Set to `[]` to disable 7 | exemptLabels: [] 8 | 9 | # Do not comment when locking 10 | setLockReason: false 11 | lockComment: false 12 | -------------------------------------------------------------------------------- /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/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/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": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /packages/react-dev-utils/ForkTsCheckerWebpackPlugin.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 ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); 11 | 12 | module.exports = ForkTsCheckerWebpackPlugin; 13 | -------------------------------------------------------------------------------- /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-typescript/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": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /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 = function(api, opts) { 12 | return create(api, Object.assign({ helpers: false }, opts), 'test'); 13 | }; 14 | -------------------------------------------------------------------------------- /test/fixtures/builds-with-multiple-runtimes/index.test.js: -------------------------------------------------------------------------------- 1 | const testSetup = require('../__shared__/test-setup'); 2 | 3 | test('builds in development', async () => { 4 | const { fulfilled } = await testSetup.scripts.start({ smoke: true }); 5 | expect(fulfilled).toBe(true); 6 | }); 7 | test('builds in production', async () => { 8 | const { fulfilled } = await testSetup.scripts.build(); 9 | expect(fulfilled).toBe(true); 10 | }); 11 | -------------------------------------------------------------------------------- /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/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 = function(api, opts) { 12 | return create(api, Object.assign({ helpers: false }, opts), 'development'); 13 | }; 14 | -------------------------------------------------------------------------------- /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 = function(api, opts) { 12 | return create(api, Object.assign({ helpers: false }, opts), 'production'); 13 | }; 14 | -------------------------------------------------------------------------------- /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/create-react-app/README.md: -------------------------------------------------------------------------------- 1 | # create-react-app 2 | 3 | This package includes the global command for [Create React App](https://github.com/facebook/create-react-app).
4 | Please refer to its documentation: 5 | 6 | - [Getting Started](https://facebook.github.io/create-react-app/docs/getting-started) – How to create a new app. 7 | - [User Guide](https://facebook.github.io/create-react-app/) – How to develop apps bootstrapped with Create React App. 8 | -------------------------------------------------------------------------------- /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/SassInclusion.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/sass-styles.sass'; 10 | 11 | export default () =>

We love useless text.

; 12 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/ScssInclusion.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/scss-styles.scss'; 10 | 11 | export default () =>

We love useless text.

; 12 | -------------------------------------------------------------------------------- /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/template/gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /packages/react-scripts/README.md: -------------------------------------------------------------------------------- 1 | # react-scripts 2 | 3 | This package includes scripts and configuration used by [Create React App](https://github.com/facebook/create-react-app).
4 | Please refer to its documentation: 5 | 6 | - [Getting Started](https://facebook.github.io/create-react-app/docs/getting-started) – How to create a new app. 7 | - [User Guide](https://facebook.github.io/create-react-app/) – How to develop apps bootstrapped with Create React App. 8 | -------------------------------------------------------------------------------- /test/fixtures/typescript/src/App.test.ts: -------------------------------------------------------------------------------- 1 | import App from './App'; 2 | 3 | it('reads a typescript file with no syntax error', () => { 4 | const app = new App(); 5 | expect(App.foo.bar).toBe(true); 6 | expect(App.foo.baz!.n).toBe(123); 7 | expect(app.n).toBe(123); 8 | }); 9 | 10 | it('supports decorators', () => { 11 | expect((App as any).annotated).toBe(true); 12 | 13 | const app = new App(); 14 | expect(app.decorated).toBe(42); 15 | }); 16 | -------------------------------------------------------------------------------- /docusaurus/website/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "examples": "docusaurus-examples", 4 | "start": "docusaurus-start", 5 | "build": "docusaurus-build", 6 | "publish-gh-pages": "docusaurus-publish", 7 | "write-translations": "docusaurus-write-translations", 8 | "version": "docusaurus-version", 9 | "rename-version": "docusaurus-rename-version" 10 | }, 11 | "devDependencies": { 12 | "docusaurus": "^1.7.2" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/react-scripts/template-typescript/gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /test/fixtures/typescript-advanced/src/App.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | interface MyType { 4 | foo: number; 5 | bar: boolean; 6 | baz?: { n: number }; 7 | } 8 | 9 | type MyObject = Pick; 10 | 11 | class App extends React.Component { 12 | static foo: MyObject = { bar: true, baz: { n: 123 } }; 13 | n = App.foo.baz!.n; 14 | 15 | render() { 16 | return
; 17 | } 18 | } 19 | 20 | export default App; 21 | -------------------------------------------------------------------------------- /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-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( 12 | process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H' 13 | ); 14 | } 15 | 16 | module.exports = clearConsole; 17 | -------------------------------------------------------------------------------- /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/template/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 5 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 6 | sans-serif; 7 | -webkit-font-smoothing: antialiased; 8 | -moz-osx-font-smoothing: grayscale; 9 | } 10 | 11 | code { 12 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 13 | monospace; 14 | } 15 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/scss-styles.scss: -------------------------------------------------------------------------------- 1 | @import "~bootstrap/scss/functions"; 2 | @import "~bootstrap/scss/variables"; 3 | @import "~bootstrap/scss/mixins"; 4 | 5 | @import "~bootstrap/scss/reboot"; 6 | @import "~bootstrap/scss/type"; 7 | @import "~bootstrap/scss/images"; 8 | @import "~bootstrap/scss/code"; 9 | @import "~bootstrap/scss/grid"; 10 | 11 | #feature-scss-inclusion { 12 | background: ghostwhite; 13 | color: crimson; 14 | } 15 | -------------------------------------------------------------------------------- /packages/react-scripts/template-typescript/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 5 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 6 | sans-serif; 7 | -webkit-font-smoothing: antialiased; 8 | -moz-osx-font-smoothing: grayscale; 9 | } 10 | 11 | code { 12 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 13 | monospace; 14 | } 15 | -------------------------------------------------------------------------------- /test/fixtures/builds-with-multiple-runtimes/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import dva from 'dva'; 3 | import createHistory from 'history/createHashHistory'; 4 | import ky from 'ky'; 5 | 6 | const app = dva({ history: createHistory() }); 7 | app.router(() => { 8 | ky.get('https://canihazip.com/s') 9 | .then(r => r.text()) 10 | .then(console.log, console.error) 11 | .then(() => console.log('ok')); 12 | return
Test
; 13 | }); 14 | app.start('#root'); 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 | configFile: false, 16 | }); 17 | -------------------------------------------------------------------------------- /packages/react-scripts/template/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | 9 | // If you want your app to work offline and load faster, you can change 10 | // unregister() to register() below. Note this comes with some pitfalls. 11 | // Learn more about service workers: https://bit.ly/CRA-PWA 12 | serviceWorker.unregister(); 13 | -------------------------------------------------------------------------------- /packages/react-app-polyfill/jsdom.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 | // Make sure we're in a Browser-like environment before importing polyfills 10 | // This prevents `fetch()` from being imported in a Node test environment 11 | if (typeof window !== 'undefined') { 12 | // fetch() polyfill for making API calls. 13 | require('whatwg-fetch'); 14 | } 15 | -------------------------------------------------------------------------------- /packages/react-scripts/template-typescript/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | 9 | // If you want your app to work offline and load faster, you can change 10 | // unregister() to register() below. Note this comes with some pitfalls. 11 | // Learn more about service workers: https://bit.ly/CRA-PWA 12 | serviceWorker.unregister(); 13 | -------------------------------------------------------------------------------- /packages/confusing-browser-globals/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "confusing-browser-globals", 3 | "version": "1.0.6", 4 | "description": "A list of browser globals that are often used by mistake instead of local variables", 5 | "license": "MIT", 6 | "main": "index.js", 7 | "scripts": { 8 | "test": "jest" 9 | }, 10 | "repository": "facebook/create-react-app", 11 | "keywords": [ 12 | "eslint", 13 | "globals" 14 | ], 15 | "files": [ 16 | "index.js" 17 | ], 18 | "devDependencies": { 19 | "jest": "24.5.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/confusing-browser-globals/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 | /* eslint-env jest */ 9 | 10 | 'use strict'; 11 | 12 | let globals = require('./index'); 13 | 14 | it('should return an Array of globals', () => { 15 | expect(Array.isArray(globals)).toBe(true); 16 | }); 17 | 18 | it('should contain "event" variable', () => { 19 | expect(globals).toContain('event'); 20 | }); 21 | -------------------------------------------------------------------------------- /test/fixtures/boostrap-sass/index.test.js: -------------------------------------------------------------------------------- 1 | const testSetup = require('../__shared__/test-setup'); 2 | 3 | if (testSetup.isLocal) { 4 | // TODO: make this work locally 5 | test('skipped locally', () => {}); 6 | } else { 7 | test('builds in development', async () => { 8 | const { fulfilled } = await testSetup.scripts.start({ smoke: true }); 9 | expect(fulfilled).toBe(true); 10 | }); 11 | 12 | test('builds in production', async () => { 13 | const { fulfilled } = await testSetup.scripts.build(); 14 | expect(fulfilled).toBe(true); 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /docusaurus/docs/installing-a-dependency.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: installing-a-dependency 3 | title: Installing a Dependency 4 | --- 5 | 6 | The generated project includes React and ReactDOM as dependencies. It also includes a set of scripts used by Create React App as a development dependency. You may install other dependencies (for example, React Router) with `npm`: 7 | 8 | ```sh 9 | npm install --save react-router-dom 10 | ``` 11 | 12 | Alternatively you may use `yarn`: 13 | 14 | ```sh 15 | yarn add react-router-dom 16 | ``` 17 | 18 | This works for any library, not just `react-router-dom`. 19 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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-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 run 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 | -------------------------------------------------------------------------------- /test/fixtures/typescript-advanced/index.test.js: -------------------------------------------------------------------------------- 1 | const testSetup = require('../__shared__/test-setup'); 2 | 3 | test('builds in development', async () => { 4 | const { fulfilled } = await testSetup.scripts.start({ smoke: true }); 5 | expect(fulfilled).toBe(true); 6 | }); 7 | test('builds in production', async () => { 8 | const { fulfilled } = await testSetup.scripts.build(); 9 | expect(fulfilled).toBe(true); 10 | }); 11 | test('passes tests', async () => { 12 | const { fulfilled } = await testSetup.scripts.test({ 13 | jestEnvironment: 'node', 14 | }); 15 | expect(fulfilled).toBe(true); 16 | }); 17 | -------------------------------------------------------------------------------- /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/SassInclusion.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 SassInclusion from './SassInclusion'; 11 | 12 | describe('sass 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/ScssInclusion.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 ScssInclusion from './ScssInclusion'; 11 | 12 | describe('scss 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/SvgComponent.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 { ReactComponent as Logo } from './assets/logo.svg'; 10 | 11 | export default () => { 12 | return ; 13 | }; 14 | 15 | export const SvgComponentWithRef = React.forwardRef((props, ref) => ( 16 | 17 | )); 18 | -------------------------------------------------------------------------------- /test/fixtures/typescript/src/App.ts: -------------------------------------------------------------------------------- 1 | interface MyType { 2 | foo: number; 3 | bar: boolean; 4 | baz?: { n: number }; 5 | } 6 | 7 | type MyObject = Pick; 8 | 9 | @annotation 10 | class App { 11 | static foo: MyObject = { bar: true, baz: { n: 123 } }; 12 | n = App.foo.baz!.n; 13 | @propertyDecorator 14 | decorated = 5; 15 | } 16 | 17 | function annotation(target: any) { 18 | target.annotated = true; 19 | } 20 | 21 | function propertyDecorator(target: any, key: string) { 22 | arguments[2].initializer = function() { 23 | return 42; 24 | }; 25 | } 26 | 27 | export default App; 28 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /docusaurus/docs/alternatives-to-ejecting.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: alternatives-to-ejecting 3 | title: Alternatives to Ejecting 4 | --- 5 | 6 | [Ejecting](available-scripts.md#npm-run-eject) lets you customize anything, but from that point on you have to maintain the configuration and scripts yourself. This can be daunting if you have many similar projects. In such cases instead of ejecting we recommend to _fork_ `react-scripts` and any other packages you need. [This article](https://auth0.com/blog/how-to-configure-create-react-app/) dives into how to do it in depth. You can find more discussion in [this issue](https://github.com/facebook/create-react-app/issues/682). 7 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "2.6.0", 3 | "npmClient": "yarn", 4 | "useWorkspaces": true, 5 | "version": "independent", 6 | "changelog": { 7 | "repo": "facebook/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 | "tag: underlying tools": ":hammer: Underlying Tools" 16 | }, 17 | "cacheDir": ".changelog" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssModulesInclusion.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 CssModulesInclusion from './CssModulesInclusion'; 11 | 12 | describe('css modules 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.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-scripts/fixtures/kitchensink/src/features/webpack/SassModulesInclusion.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 SassModulesInclusion from './SassModulesInclusion'; 11 | 12 | describe('sass modules 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/ScssModulesInclusion.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 ScssModulesInclusion from './ScssModulesInclusion'; 11 | 12 | describe('scss modules 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/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/template/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | animation: App-logo-spin infinite 20s linear; 7 | height: 40vmin; 8 | pointer-events: none; 9 | } 10 | 11 | .App-header { 12 | background-color: #282c34; 13 | min-height: 100vh; 14 | display: flex; 15 | flex-direction: column; 16 | align-items: center; 17 | justify-content: center; 18 | font-size: calc(10px + 2vmin); 19 | color: white; 20 | } 21 | 22 | .App-link { 23 | color: #61dafb; 24 | } 25 | 26 | @keyframes App-logo-spin { 27 | from { 28 | transform: rotate(0deg); 29 | } 30 | to { 31 | transform: rotate(360deg); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /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/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/react-scripts/template-typescript/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | animation: App-logo-spin infinite 20s linear; 7 | height: 40vmin; 8 | pointer-events: none; 9 | } 10 | 11 | .App-header { 12 | background-color: #282c34; 13 | min-height: 100vh; 14 | display: flex; 15 | flex-direction: column; 16 | align-items: center; 17 | justify-content: center; 18 | font-size: calc(10px + 2vmin); 19 | color: white; 20 | } 21 | 22 | .App-link { 23 | color: #61dafb; 24 | } 25 | 26 | @keyframes App-logo-spin { 27 | from { 28 | transform: rotate(0deg); 29 | } 30 | to { 31 | transform: rotate(360deg); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/react-app-polyfill/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-app-polyfill", 3 | "version": "0.2.2", 4 | "description": "Polyfills for various browsers including commonly used language features", 5 | "repository": "facebook/create-react-app", 6 | "license": "MIT", 7 | "bugs": { 8 | "url": "https://github.com/facebook/create-react-app/issues" 9 | }, 10 | "engines": { 11 | "node": ">=6" 12 | }, 13 | "files": [ 14 | "ie9.js", 15 | "ie11.js", 16 | "jsdom.js" 17 | ], 18 | "dependencies": { 19 | "core-js": "2.6.5", 20 | "object-assign": "4.1.1", 21 | "promise": "8.0.2", 22 | "raf": "3.4.1", 23 | "whatwg-fetch": "3.0.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /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/webpack/CssModulesInclusion.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 styles from './assets/style.module.css'; 10 | import indexStyles from './assets/index.module.css'; 11 | 12 | export default () => ( 13 |
14 |

CSS Modules are working!

15 |

16 | CSS Modules with index are working! 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 | -------------------------------------------------------------------------------- /docusaurus/docs/using-global-variables.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: using-global-variables 3 | title: Using Global Variables 4 | --- 5 | 6 | When you include a script in the HTML file that defines global variables and try to use one of these variables in the code, the linter will complain because it cannot see the definition of the variable. 7 | 8 | You can avoid this by reading the global variable explicitly from the `window` object, for example: 9 | 10 | ```js 11 | const $ = window.$; 12 | ``` 13 | 14 | This makes it obvious you are using a global variable intentionally rather than because of a typo. 15 | 16 | Alternatively, you can force the linter to ignore any line by adding `// eslint-disable-line` after it. 17 | -------------------------------------------------------------------------------- /packages/babel-plugin-named-asset-import/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-plugin-named-asset-import", 3 | "version": "0.3.1", 4 | "description": "Babel plugin for named asset imports in 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 | "main": "index.js", 11 | "files": [ 12 | "index.js" 13 | ], 14 | "peerDependencies": { 15 | "@babel/core": "^7.1.0" 16 | }, 17 | "devDependencies": { 18 | "babel-plugin-tester": "^5.5.1", 19 | "jest": "^24.5.0" 20 | }, 21 | "scripts": { 22 | "test": "jest" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /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/template/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import logo from './logo.svg'; 3 | import './App.css'; 4 | 5 | function App() { 6 | return ( 7 |
8 |
9 | logo 10 |

11 | Edit src/App.js and save to reload. 12 |

13 | 19 | Learn React 20 | 21 |
22 |
23 | ); 24 | } 25 | 26 | export default App; 27 | -------------------------------------------------------------------------------- /test/fixtures/__shared__/test-setup.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const fs = require('fs-extra'); 3 | const TestSetup = require('./util/setup'); 4 | 5 | const fixturePath = path.dirname(module.parent.filename); 6 | const fixtureName = path.basename(fixturePath); 7 | const disablePnp = fs.existsSync(path.resolve(fixturePath, '.disable-pnp')); 8 | const testSetup = new TestSetup(fixtureName, fixturePath, { 9 | pnp: !disablePnp, 10 | }); 11 | 12 | beforeAll(async () => { 13 | await testSetup.setup(); 14 | }, 1000 * 60 * 5); 15 | afterAll(async () => { 16 | await testSetup.teardown(); 17 | }); 18 | 19 | beforeEach(() => jest.setTimeout(1000 * 60 * 5)); 20 | 21 | module.exports = testSetup; 22 | -------------------------------------------------------------------------------- /packages/react-dev-utils/getCacheIdentifier.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 getCacheIdentifier(environment, packages) { 11 | let cacheIdentifier = environment == null ? '' : environment.toString(); 12 | for (const packageName of packages) { 13 | cacheIdentifier += `:${packageName}@`; 14 | try { 15 | cacheIdentifier += require(`${packageName}/package.json`).version; 16 | } catch (_) { 17 | // ignored 18 | } 19 | } 20 | return cacheIdentifier; 21 | }; 22 | -------------------------------------------------------------------------------- /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-scripts/fixtures/kitchensink/src/features/webpack/SassModulesInclusion.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 styles from './assets/sass-styles.module.sass'; 10 | import indexStyles from './assets/index.module.sass'; 11 | 12 | export default () => ( 13 |
14 |

SASS Modules are working!

15 |

16 | SASS Modules with index are working! 17 |

18 |
19 | ); 20 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/ScssModulesInclusion.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 styles from './assets/scss-styles.module.scss'; 10 | import indexStyles from './assets/index.module.scss'; 11 | 12 | export default () => ( 13 |
14 |

SCSS Modules are working!

15 |

16 | SCSS Modules with index are working! 17 |

18 |
19 | ); 20 | -------------------------------------------------------------------------------- /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/template-typescript/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import logo from './logo.svg'; 3 | import './App.css'; 4 | 5 | const App: React.FC = () => { 6 | return ( 7 |
8 |
9 | logo 10 |

11 | Edit src/App.tsx and save to reload. 12 |

13 | 19 | Learn React 20 | 21 |
22 |
23 | ); 24 | } 25 | 26 | export default App; 27 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /docusaurus/docs/adding-a-router.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: adding-a-router 3 | title: Adding a Router 4 | --- 5 | 6 | Create React App doesn't prescribe a specific routing solution, but [React Router](https://reacttraining.com/react-router/web/) is the most popular one. 7 | 8 | To add it, run: 9 | 10 | ```sh 11 | npm install --save react-router-dom 12 | ``` 13 | 14 | Alternatively you may use `yarn`: 15 | 16 | ```sh 17 | yarn add react-router-dom 18 | ``` 19 | 20 | To try it, delete all the code in `src/App.js` and replace it with any of the examples on its website. The [Basic Example](https://reacttraining.com/react-router/web/example/basic) is a good place to get started. 21 | 22 | Note that [you may need to configure your production server to support client-side routing](deployment.md#serving-apps-with-client-side-routing) before deploying your app. 23 | -------------------------------------------------------------------------------- /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 | module.exports = function(api, opts) { 12 | // This is similar to how `env` works in Babel: 13 | // https://babeljs.io/docs/usage/babelrc/#env-option 14 | // We are not using `env` because it’s ignored in versions > babel-core@6.10.4: 15 | // https://github.com/babel/babel/issues/4539 16 | // https://github.com/facebook/create-react-app/issues/720 17 | // It’s also nice that we can enforce `NODE_ENV` being specified. 18 | const env = process.env.BABEL_ENV || process.env.NODE_ENV; 19 | return create(api, opts, env); 20 | }; 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/fixtures/relative-paths/index.test.js: -------------------------------------------------------------------------------- 1 | const testSetup = require('../__shared__/test-setup'); 2 | 3 | const fs = require('fs-extra'); 4 | const globby = require('globby'); 5 | const path = require('path'); 6 | 7 | test('contains a relative path in production build', async () => { 8 | await testSetup.scripts.build(); 9 | 10 | const buildDir = path.join(testSetup.testDirectory, 'build'); 11 | const cssFile = path.join( 12 | buildDir, 13 | globby.sync('**/*.css', { cwd: buildDir }).pop() 14 | ); 15 | const svgFile = path.join( 16 | buildDir, 17 | globby.sync('**/*.svg', { cwd: buildDir }).pop() 18 | ); 19 | const desiredPath = /url\((.+?)\)/ 20 | .exec(fs.readFileSync(cssFile, 'utf8')) 21 | .pop(); 22 | expect(path.resolve(path.join(path.dirname(cssFile), desiredPath))).toBe( 23 | path.resolve(svgFile) 24 | ); 25 | }); 26 | -------------------------------------------------------------------------------- /packages/eslint-config-react-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-config-react-app", 3 | "version": "3.0.8", 4 | "description": "ESLint configuration used by Create React App", 5 | "repository": "facebook/create-react-app", 6 | "license": "MIT", 7 | "bugs": { 8 | "url": "https://github.com/facebook/create-react-app/issues" 9 | }, 10 | "files": [ 11 | "index.js" 12 | ], 13 | "peerDependencies": { 14 | "@typescript-eslint/eslint-plugin": "1.x", 15 | "@typescript-eslint/parser": "1.x", 16 | "babel-eslint": "10.x", 17 | "eslint": "5.x", 18 | "eslint-plugin-flowtype": "2.x", 19 | "eslint-plugin-import": "2.x", 20 | "eslint-plugin-jsx-a11y": "6.x", 21 | "eslint-plugin-react": "7.x", 22 | "eslint-plugin-react-hooks": "1.x" 23 | }, 24 | "dependencies": { 25 | "confusing-browser-globals": "^1.0.6" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /docusaurus/website/static/css/custom.css: -------------------------------------------------------------------------------- 1 | /* your custom css */ 2 | 3 | .homeContainer { 4 | background: #282c34; 5 | color: white; 6 | padding: 80px 0; 7 | } 8 | 9 | .homeContainer .button { 10 | background: #24292e; 11 | border-color: white; 12 | } 13 | 14 | .homeContainer * { 15 | color: inherit; 16 | } 17 | 18 | .post a { 19 | text-decoration: underline; 20 | } 21 | 22 | .navigationSlider .slidingNav ul { 23 | background: #282c34; 24 | } 25 | 26 | .headerTitleWithLogo { 27 | white-space: nowrap; 28 | } 29 | 30 | @media only screen and (min-device-width: 360px) and (max-device-width: 736px) { 31 | } 32 | 33 | @media only screen and (min-width: 1024px) { 34 | .navigationSlider .slidingNav ul { 35 | background: none; 36 | } 37 | } 38 | 39 | @media only screen and (max-width: 1023px) { 40 | } 41 | 42 | @media only screen and (min-width: 1400px) { 43 | } 44 | 45 | @media only screen and (min-width: 1500px) { 46 | } 47 | -------------------------------------------------------------------------------- /packages/create-react-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "create-react-app", 3 | "version": "2.1.8", 4 | "keywords": [ 5 | "react" 6 | ], 7 | "description": "Create React apps with no build configuration.", 8 | "repository": "facebook/create-react-app", 9 | "license": "MIT", 10 | "engines": { 11 | "node": ">=8" 12 | }, 13 | "bugs": { 14 | "url": "https://github.com/facebook/create-react-app/issues" 15 | }, 16 | "files": [ 17 | "index.js", 18 | "createReactApp.js", 19 | "yarn.lock.cached" 20 | ], 21 | "bin": { 22 | "create-react-app": "./index.js" 23 | }, 24 | "dependencies": { 25 | "chalk": "2.4.2", 26 | "commander": "2.19.0", 27 | "cross-spawn": "6.0.5", 28 | "envinfo": "7.1.0", 29 | "fs-extra": "7.0.1", 30 | "hyperquest": "2.1.3", 31 | "semver": "5.6.0", 32 | "tar-pack": "3.4.1", 33 | "tmp": "0.0.33", 34 | "validate-npm-package-name": "3.0.0" 35 | } 36 | } 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 => ( 31 |
{user.name}
32 | ))} 33 |
34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/react-scripts/config/jest/fileTransform.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | 5 | // This is a custom Jest transformer turning file imports into filenames. 6 | // http://facebook.github.io/jest/docs/en/webpack.html 7 | 8 | module.exports = { 9 | process(src, filename) { 10 | const assetFilename = JSON.stringify(path.basename(filename)); 11 | 12 | if (filename.match(/\.svg$/)) { 13 | return `const React = require('react'); 14 | module.exports = { 15 | __esModule: true, 16 | default: ${assetFilename}, 17 | ReactComponent: React.forwardRef((props, ref) => ({ 18 | $$typeof: Symbol.for('react.element'), 19 | type: 'svg', 20 | ref: ref, 21 | key: null, 22 | props: Object.assign({}, props, { 23 | children: ${assetFilename} 24 | }) 25 | })), 26 | };`; 27 | } 28 | 29 | return `module.exports = ${assetFilename};`; 30 | }, 31 | }; 32 | -------------------------------------------------------------------------------- /docusaurus/docs/can-i-use-decorators.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: can-i-use-decorators 3 | title: Can I Use Decorators? 4 | --- 5 | 6 | Some popular libraries use [decorators](https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841) in their documentation.
7 | Create React App intentionally doesn’t support decorator syntax at the moment because: 8 | 9 | - It is an experimental proposal and is subject to change (in fact, it has already changed once, and will change again). 10 | - Most libraries currently support only the old version of the proposal — which will never be a standard. 11 | 12 | However in many cases you can rewrite decorator-based code without decorators just as fine.
13 | Please refer to these two threads for reference: 14 | 15 | - [#214](https://github.com/facebook/create-react-app/issues/214) 16 | - [#411](https://github.com/facebook/create-react-app/issues/411) 17 | 18 | Create React App will add decorator support when the specification advances to a stable stage. 19 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /docusaurus/docs/documentation-intro.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: documentation-intro 3 | title: About the Documentation 4 | sidebar_label: About Docs 5 | --- 6 | 7 | Welcome to the Create React App documentation! 8 | 9 | ## Navigation 10 | 11 | You can find different topics in the table of contents. On desktop, you should see it in the left sidebar. On mobile, you should see it after pressing an icon with arrows in the top left corner. 12 | 13 | ## Looking for React Docs? 14 | 15 | The documentation for React itself is located on a separate website: **[reactjs.org](https://reactjs.org/)**. 16 | 17 | This website is only about Create React App. 18 | 19 | ## Something Missing? 20 | 21 | If you have ideas for more “How To” recipes that should be on this page, [let us know](https://github.com/facebook/create-react-app/issues) or [contribute some!](https://github.com/facebook/create-react-app/tree/master/docusaurus/docs) 22 | 23 | ## Feedback 24 | 25 | We are always open to [your feedback](https://github.com/facebook/create-react-app/issues). 26 | -------------------------------------------------------------------------------- /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-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-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 => ( 35 |
{user.name}
36 | ))} 37 |
38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/react-scripts/fixtures/kitchensink/src/features/webpack/SvgComponent.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 SvgComponent, { SvgComponentWithRef } from './SvgComponent'; 11 | 12 | describe('svg component', () => { 13 | it('renders without crashing', () => { 14 | const div = document.createElement('div'); 15 | ReactDOM.render(, div); 16 | expect(div.textContent).toBe('logo.svg'); 17 | }); 18 | 19 | it('svg root element equals the passed ref', () => { 20 | const div = document.createElement('div'); 21 | const someRef = React.createRef(); 22 | ReactDOM.render(, div); 23 | const svgElement = div.getElementsByTagName('svg'); 24 | expect(svgElement).toHaveLength(1); 25 | expect(svgElement[0]).toBe(someRef.current); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /docusaurus/docs/analyzing-the-bundle-size.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: analyzing-the-bundle-size 3 | title: Analyzing the Bundle Size 4 | sidebar_label: Analyzing Bundle Size 5 | --- 6 | 7 | [Source map explorer](https://www.npmjs.com/package/source-map-explorer) analyzes 8 | JavaScript bundles using the source maps. This helps you understand where code 9 | bloat is coming from. 10 | 11 | To add Source map explorer to a Create React App project, follow these steps: 12 | 13 | ```sh 14 | npm install --save source-map-explorer 15 | ``` 16 | 17 | Alternatively you may use `yarn`: 18 | 19 | ```sh 20 | yarn add source-map-explorer 21 | ``` 22 | 23 | Then in `package.json`, add the following line to `scripts`: 24 | 25 | ```diff 26 | "scripts": { 27 | + "analyze": "source-map-explorer 'build/static/js/*.js'", 28 | "start": "react-scripts start", 29 | "build": "react-scripts build", 30 | "test": "react-scripts test", 31 | ``` 32 | 33 | Then to analyze the bundle run the production build then run the analyze 34 | script. 35 | 36 | ```sh 37 | npm run build 38 | npm run analyze 39 | ``` 40 | -------------------------------------------------------------------------------- /docusaurus/docs/adding-relay.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: adding-relay 3 | title: Adding Relay 4 | --- 5 | 6 | Relay is a framework for building data-driven React applications powered by GraphQL. The current release candidate of Relay works with Create React App projects out of the box using Babel Macros. Simply set up your project as laid out in the [Relay documentation](https://facebook.github.io/relay/), then make sure you have a version of the babel plugin providing the macro. 7 | 8 | To add it, run: 9 | 10 | ```sh 11 | npm install --save babel-plugin-relay@dev 12 | ``` 13 | 14 | Alternatively you may use `yarn`: 15 | 16 | ```sh 17 | yarn upgrade babel-plugin-relay@dev 18 | ``` 19 | 20 | Then, wherever you use the `graphql` template tag, import the macro: 21 | 22 | ```js 23 | import graphql from 'babel-plugin-relay/macro'; 24 | // instead of: 25 | // import { graphql } from "babel-plugin-relay" 26 | 27 | graphql` 28 | query UserQuery { 29 | viewer { 30 | id 31 | } 32 | } 33 | `; 34 | ``` 35 | 36 | To learn more about Relay, check out [its documentation](https://facebook.github.io/relay/). 37 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dist: trusty 3 | language: node_js 4 | node_js: 5 | - 8 6 | - 10 7 | cache: 8 | yarn: true 9 | directories: 10 | - .npm 11 | before_install: 12 | - curl -o- -L https://yarnpkg.com/install.sh | bash -s 13 | - export PATH="$HOME/.yarn/bin:$PATH" 14 | install: true 15 | script: 16 | - 'if [ $TEST_SUITE = "simple" ]; then tasks/e2e-simple.sh; fi' 17 | - 'if [ $TEST_SUITE = "installs" ]; then tasks/e2e-installs.sh; fi' 18 | - 'if [ $TEST_SUITE = "kitchensink" ]; then tasks/e2e-kitchensink.sh; fi' 19 | - 'if [ $TEST_SUITE = "kitchensink-eject" ]; then tasks/e2e-kitchensink-eject.sh; fi' 20 | - 'if [ $TEST_SUITE = "old-node" ]; then tasks/e2e-old-node.sh; fi' 21 | - 'if [ $TEST_SUITE = "behavior" ]; then tasks/e2e-behavior.sh; fi' 22 | env: 23 | matrix: 24 | - TEST_SUITE=simple 25 | - TEST_SUITE=installs 26 | - TEST_SUITE=kitchensink 27 | - TEST_SUITE=kitchensink-eject 28 | - TEST_SUITE=behavior 29 | matrix: 30 | include: 31 | - os: osx 32 | node_js: 8 33 | env: TEST_SUITE=behavior 34 | - node_js: 6 35 | env: TEST_SUITE=old-node 36 | -------------------------------------------------------------------------------- /docusaurus/docs/using-https-in-development.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: using-https-in-development 3 | title: Using HTTPS in Development 4 | sidebar_label: HTTPS in Development 5 | --- 6 | 7 | > Note: this feature is available with `react-scripts@0.4.0` and higher. 8 | 9 | You may require the dev server to serve pages over HTTPS. One particular case where this could be useful is when using [the "proxy" feature](proxying-api-requests-in-development.md) to proxy requests to an API server when that API server is itself serving HTTPS. 10 | 11 | To do this, set the `HTTPS` environment variable to `true`, then start the dev server as usual with `npm start`: 12 | 13 | ### Windows (cmd.exe) 14 | 15 | ```cmd 16 | set HTTPS=true&&npm start 17 | ``` 18 | 19 | (Note: the lack of whitespace is intentional.) 20 | 21 | ### Windows (Powershell) 22 | 23 | ```Powershell 24 | ($env:HTTPS = "true") -and (npm start) 25 | ``` 26 | 27 | ### Linux, macOS (Bash) 28 | 29 | ```sh 30 | HTTPS=true npm start 31 | ``` 32 | 33 | Note that the server will use a self-signed certificate, so your web browser will almost definitely display a warning upon accessing the page. 34 | -------------------------------------------------------------------------------- /tasks/screencast.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 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 is an end-to-end test intended to be run via screencast.js 9 | # Dependencies: asciinema, pv, core-utils 10 | # ****************************************************************************** 11 | set -e 12 | 13 | printf '\e[32m%s\e[m' "λ " 14 | echo "npx create-react-app my-app" | pv -qL $[10+(-2 + RANDOM%5)] 15 | npx create-react-app my-app 16 | 17 | printf '\e[32m%s\e[m' "λ " 18 | sleep 1 19 | echo "cd my-app" | pv -qL $[10+(-2 + RANDOM%5)] 20 | cd my-app 21 | 22 | printf '\e[32m%s\e[m' "λ " 23 | sleep 1 24 | echo "npm start" | pv -qL $[10+(-2 + RANDOM%5)] 25 | 26 | BROWSER="none" node "$(dirname $0)/screencast-start.js" \ 27 | --command "npm start" \ 28 | --pattern="Compiled successfully*" \ 29 | --pattern-count 2 \ 30 | --error-pattern="*already running on port" \ 31 | --timeout 10 32 | 33 | echo "" -------------------------------------------------------------------------------- /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-dev-utils/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/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/create-react-app/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-app-polyfill/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-error-overlay/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/babel-preset-react-app/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/confusing-browser-globals/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/eslint-config-react-app/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 | -------------------------------------------------------------------------------- /docusaurus/docs/pre-rendering-into-static-html-files.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: pre-rendering-into-static-html-files 3 | title: Pre-Rendering into Static HTML Files 4 | sidebar_label: Pre-Rendering Static HTML 5 | --- 6 | 7 | If you’re hosting your `build` with a static hosting provider you can use [react-snapshot](https://www.npmjs.com/package/react-snapshot) or [react-snap](https://github.com/stereobooster/react-snap) to generate HTML pages for each route, or relative link, in your application. These pages will then seamlessly become active, or “hydrated”, when the JavaScript bundle has loaded. 8 | 9 | There are also opportunities to use this outside of static hosting, to take the pressure off the server when generating and caching routes. 10 | 11 | The primary benefit of pre-rendering is that you get the core content of each page _with_ the HTML payload—regardless of whether or not your JavaScript bundle successfully downloads. It also increases the likelihood that each route of your application will be picked up by search engines. 12 | 13 | You can read more about [zero-configuration pre-rendering (also called snapshotting) here](https://medium.com/superhighfives/an-almost-static-stack-6df0a2791319). 14 | -------------------------------------------------------------------------------- /packages/babel-plugin-named-asset-import/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-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/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 => ( 43 |
{user.name}
44 | ))} 45 |
46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /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 => ( 44 |
{user.name}
45 | ))} 46 |
47 | ); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /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 | mode: process.env.NODE_ENV === 'production' ? 'production' : 'development', 13 | entry: './src/index.js', 14 | output: { 15 | path: path.join(__dirname, './lib'), 16 | filename: 'index.js', 17 | library: 'ReactErrorOverlay', 18 | libraryTarget: 'umd', 19 | }, 20 | module: { 21 | rules: [ 22 | { 23 | test: /iframe-bundle\.js$/, 24 | use: 'raw-loader', 25 | }, 26 | { 27 | test: /\.js$/, 28 | include: path.resolve(__dirname, './src'), 29 | use: 'babel-loader', 30 | }, 31 | ], 32 | }, 33 | resolve: { 34 | alias: { 35 | iframeScript$: path.resolve(__dirname, './lib/iframe-bundle.js'), 36 | }, 37 | }, 38 | optimization: { 39 | nodeEnv: false, 40 | }, 41 | node: { 42 | fs: 'empty', 43 | process: false, 44 | }, 45 | performance: { 46 | hints: false, 47 | }, 48 | }; 49 | -------------------------------------------------------------------------------- /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 => ( 45 |
{user.name}
46 | ))} 47 |
48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /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 => ( 43 |
{user.name}
44 | ))} 45 |
46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /docusaurus/docs/integrating-with-an-api-backend.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: integrating-with-an-api-backend 3 | title: Integrating with an API Backend 4 | sidebar_label: Integrating with an API 5 | --- 6 | 7 | These tutorials will help you to integrate your app with an API backend running on another port, 8 | using `fetch()` to access it. 9 | 10 | ## Node 11 | 12 | Check out [this tutorial](https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/). 13 | You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo). 14 | 15 | ## Ruby on Rails 16 | 17 | Check out [this tutorial](https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/). 18 | You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo-rails). 19 | 20 | ## API Platform (PHP and Symfony) 21 | 22 | [API Platform](https://api-platform.com) is a framework designed to build API-driven projects. 23 | It allows creating hypermedia and GraphQL APIs in minutes. 24 | It is shipped with an official Progressive Web App generator as well as a dynamic administration interface, both built for Create React App. 25 | Check out [this tutorial](https://api-platform.com/docs/distribution). 26 | -------------------------------------------------------------------------------- /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 => ( 43 |
{user.name}
44 | ))} 45 |
46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /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 => ( 43 |
{user.name}
44 | ))} 45 |
46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /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 => ( 43 |
{user.name}
44 | ))} 45 |
46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /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/facebook/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.hooks.emit.tap('WatchMissingNodeModulesPlugin', compilation => { 21 | var missingDeps = Array.from(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.includes(nodeModulesPath))) { 26 | // ...tell webpack to watch node_modules recursively until they appear. 27 | compilation.contextDependencies.add(nodeModulesPath); 28 | } 29 | }); 30 | } 31 | } 32 | 33 | module.exports = WatchMissingNodeModulesPlugin; 34 | -------------------------------------------------------------------------------- /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-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 => ( 45 |
{user.name}
46 | ))} 47 |
48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /docusaurus/docs/adding-flow.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: adding-flow 3 | title: Adding Flow 4 | --- 5 | 6 | Flow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept. 7 | 8 | Recent versions of [Flow](https://flow.org/) work with Create React App projects out of the box. 9 | 10 | To add Flow to a Create React App project, follow these steps: 11 | 12 | 1. Run `npm install --save flow-bin` (or `yarn add flow-bin`). 13 | 2. Add `"flow": "flow"` to the `scripts` section of your `package.json`. 14 | 3. Run `npm run flow init` (or `yarn flow init`) to create a [`.flowconfig` file](https://flow.org/en/docs/config/) in the root directory. 15 | 4. Add `// @flow` to any files you want to type check (for example, to `src/App.js`). 16 | 17 | Now you can run `npm run flow` (or `yarn flow`) to check the files for type errors. 18 | You can optionally use an IDE like [Nuclide](https://nuclide.io/docs/languages/flow/) for a better integrated experience. 19 | In the future we plan to integrate it into Create React App even more closely. 20 | 21 | To learn more about Flow, check out [its documentation](https://flow.org/). 22 | -------------------------------------------------------------------------------- /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/webpack-overrides.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 crypto = require('crypto'); 10 | 11 | const macroCheck = new RegExp('[./]macro'); 12 | 13 | module.exports = function() { 14 | return { 15 | // This function transforms the Babel configuration on a per-file basis 16 | config(config, { source }) { 17 | // Babel Macros are notoriously hard to cache, so they shouldn't be 18 | // https://github.com/babel/babel/issues/8497 19 | // We naively detect macros using their package suffix and add a random token 20 | // to the caller, a valid option accepted by Babel, to compose a one-time 21 | // cacheIdentifier for the file. We cannot tune the loader options on a per 22 | // file basis. 23 | if (macroCheck.test(source)) { 24 | return Object.assign({}, config.options, { 25 | caller: Object.assign({}, config.options.caller, { 26 | craInvalidationToken: crypto.randomBytes(32).toString('hex'), 27 | }), 28 | }); 29 | } 30 | return config.options; 31 | }, 32 | }; 33 | }; 34 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/fixtures/typescript-typecheck/index.test.js: -------------------------------------------------------------------------------- 1 | const testSetup = require('../__shared__/test-setup'); 2 | const puppeteer = require('puppeteer'); 3 | 4 | const expectedErrorMsg = `Argument of type '123' is not assignable to parameter of type 'string'`; 5 | 6 | test('shows error overlay in browser', async () => { 7 | const { port, done } = await testSetup.scripts.start(); 8 | 9 | const browser = await puppeteer.launch({ headless: true }); 10 | try { 11 | const page = await browser.newPage(); 12 | await page.goto(`http://localhost:${port}/`); 13 | await page.waitForSelector('iframe', { timeout: 5000 }); 14 | const overlayMsg = await page.evaluate(() => { 15 | const overlay = document.querySelector('iframe').contentWindow; 16 | return overlay.document.body.innerHTML; 17 | }); 18 | expect(overlayMsg).toContain(expectedErrorMsg); 19 | } finally { 20 | browser.close(); 21 | done(); 22 | } 23 | }); 24 | 25 | test('shows error in console (dev mode)', async () => { 26 | const { stderr } = await testSetup.scripts.start({ smoke: true }); 27 | expect(stderr).toContain(expectedErrorMsg); 28 | }); 29 | 30 | test('shows error in console (prod mode)', async () => { 31 | const { stderr } = await testSetup.scripts.build(); 32 | expect(stderr).toContain(expectedErrorMsg); 33 | }); 34 | -------------------------------------------------------------------------------- /packages/react-app-polyfill/ie11.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 | if (typeof Promise === 'undefined') { 10 | // Rejection tracking prevents a common issue where React gets into an 11 | // inconsistent state due to an error, but it gets swallowed by a Promise, 12 | // and the user has no idea what causes React's erratic future behavior. 13 | require('promise/lib/rejection-tracking').enable(); 14 | window.Promise = require('promise/lib/es6-extensions.js'); 15 | } 16 | 17 | // Make sure we're in a Browser-like environment before importing polyfills 18 | // This prevents `fetch()` from being imported in a Node test environment 19 | if (typeof window !== 'undefined') { 20 | // fetch() polyfill for making API calls. 21 | require('whatwg-fetch'); 22 | } 23 | 24 | // Object.assign() is commonly used with React. 25 | // It will use the native implementation if it's present and isn't buggy. 26 | Object.assign = require('object-assign'); 27 | 28 | // Support for...of (a commonly used syntax feature that requires Symbols) 29 | require('core-js/es6/symbol'); 30 | // Support iterable spread (...Set, ...Map) 31 | require('core-js/fn/array/from'); 32 | -------------------------------------------------------------------------------- /packages/react-dev-utils/getCSSModuleLocalIdent.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 loaderUtils = require('loader-utils'); 11 | 12 | module.exports = function getLocalIdent( 13 | context, 14 | localIdentName, 15 | localName, 16 | options 17 | ) { 18 | // Use the filename or folder name, based on some uses the index.js / index.module.(css|scss|sass) project style 19 | const fileNameOrFolder = context.resourcePath.match( 20 | /index\.module\.(css|scss|sass)$/ 21 | ) 22 | ? '[folder]' 23 | : '[name]'; 24 | // Create a hash based on a the file location and class name. Will be unique across a project, and close to globally unique. 25 | const hash = loaderUtils.getHashDigest( 26 | context.resourcePath + localName, 27 | 'md5', 28 | 'base64', 29 | 5 30 | ); 31 | // Use loaderUtils to find the file or folder name 32 | const className = loaderUtils.interpolateName( 33 | context, 34 | fileNameOrFolder + '_' + localName + '__' + hash, 35 | options 36 | ); 37 | // remove the .module that appears in every classname when based on the file. 38 | return className.replace('.module_', '_'); 39 | }; 40 | -------------------------------------------------------------------------------- /docusaurus/docs/folder-structure.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: folder-structure 3 | title: Folder Structure 4 | --- 5 | 6 | After creation, your project should look like this: 7 | 8 | ``` 9 | my-app/ 10 | README.md 11 | node_modules/ 12 | package.json 13 | public/ 14 | index.html 15 | favicon.ico 16 | src/ 17 | App.css 18 | App.js 19 | App.test.js 20 | index.css 21 | index.js 22 | logo.svg 23 | ``` 24 | 25 | For the project to build, **these files must exist with exact filenames**: 26 | 27 | - `public/index.html` is the page template; 28 | - `src/index.js` is the JavaScript entry point. 29 | 30 | You can delete or rename the other files. 31 | 32 | You may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack. You need to **put any JS and CSS files inside `src`**, otherwise Webpack won’t see them. 33 | 34 | Only files inside `public` can be used from `public/index.html`. Read instructions below for using assets from JavaScript and HTML. 35 | 36 | You can, however, create more top-level directories. They will not be included in the production build so you can use them for things like documentation. 37 | 38 | If you have Git installed and your project is not part of a larger repository, then a new repository will be initialized resulting in an additional top-level `.git` directory. 39 | -------------------------------------------------------------------------------- /packages/confusing-browser-globals/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 | 'use strict'; 9 | 10 | module.exports = [ 11 | 'addEventListener', 12 | 'blur', 13 | 'close', 14 | 'closed', 15 | 'confirm', 16 | 'defaultStatus', 17 | 'defaultstatus', 18 | 'event', 19 | 'external', 20 | 'find', 21 | 'focus', 22 | 'frameElement', 23 | 'frames', 24 | 'history', 25 | 'innerHeight', 26 | 'innerWidth', 27 | 'length', 28 | 'location', 29 | 'locationbar', 30 | 'menubar', 31 | 'moveBy', 32 | 'moveTo', 33 | 'name', 34 | 'onblur', 35 | 'onerror', 36 | 'onfocus', 37 | 'onload', 38 | 'onresize', 39 | 'onunload', 40 | 'open', 41 | 'opener', 42 | 'opera', 43 | 'outerHeight', 44 | 'outerWidth', 45 | 'pageXOffset', 46 | 'pageYOffset', 47 | 'parent', 48 | 'print', 49 | 'removeEventListener', 50 | 'resizeBy', 51 | 'resizeTo', 52 | 'screen', 53 | 'screenLeft', 54 | 'screenTop', 55 | 'screenX', 56 | 'screenY', 57 | 'scroll', 58 | 'scrollbars', 59 | 'scrollBy', 60 | 'scrollTo', 61 | 'scrollX', 62 | 'scrollY', 63 | 'self', 64 | 'status', 65 | 'statusbar', 66 | 'stop', 67 | 'toolbar', 68 | 'top', 69 | ]; 70 | -------------------------------------------------------------------------------- /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/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 | position: 'relative', 14 | display: 'block', 15 | padding: '0.5em', 16 | marginTop: '0.5em', 17 | marginBottom: '0.5em', 18 | overflowX: 'auto', 19 | whiteSpace: 'pre-wrap', 20 | borderRadius: '0.25rem', 21 | }; 22 | 23 | const primaryPreStyle = { 24 | ..._preStyle, 25 | backgroundColor: redTransparent, 26 | }; 27 | 28 | const secondaryPreStyle = { 29 | ..._preStyle, 30 | backgroundColor: yellowTransparent, 31 | }; 32 | 33 | const codeStyle = { 34 | fontFamily: 'Consolas, Menlo, monospace', 35 | }; 36 | 37 | type CodeBlockPropsType = {| 38 | main: boolean, 39 | codeHTML: string, 40 | |}; 41 | 42 | function CodeBlock(props: CodeBlockPropsType) { 43 | const preStyle = props.main ? primaryPreStyle : secondaryPreStyle; 44 | const codeBlock = { __html: props.codeHTML }; 45 | 46 | return ( 47 |
48 |       
49 |     
50 | ); 51 | } 52 | 53 | export default CodeBlock; 54 | -------------------------------------------------------------------------------- /packages/confusing-browser-globals/README.md: -------------------------------------------------------------------------------- 1 | # confusing-browser-globals 2 | 3 | A curated list of browser globals that commonly cause confusion and are not recommended to use without an explicit `window.` qualifier. 4 | 5 | ## Motivation 6 | 7 | Some global variables in browser are likely to be used by people without the intent of using them as globals, such as `status`, `name`, `event`, etc. 8 | 9 | For example: 10 | 11 | ```js 12 | handleClick() { // missing `event` argument 13 | this.setState({ 14 | text: event.target.value // uses the `event` global: oops! 15 | }); 16 | } 17 | ``` 18 | 19 | This package exports a list of globals that are often used by mistake. You can feed this list to a static analysis tool like ESLint to prevent their usage without an explicit `window.` qualifier. 20 | 21 | ## Installation 22 | 23 | ```sh 24 | npm install --save confusing-browser-globals 25 | ``` 26 | 27 | ## Usage 28 | 29 | If you use Create React App, you don't need to configure anything, as this rule is already included in the default `eslint-config-react-app` preset. 30 | 31 | If you maintain your own ESLint configuration, you can do this: 32 | 33 | ```js 34 | var restrictedGlobals = require('confusing-browser-globals'); 35 | 36 | module.exports = { 37 | rules: { 38 | 'no-restricted-globals': ['error'].concat(restrictedGlobals), 39 | }, 40 | }; 41 | ``` 42 | 43 | ## License 44 | 45 | MIT 46 | -------------------------------------------------------------------------------- /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-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 | -------------------------------------------------------------------------------- /test/fixtures/issue-5947-not-typescript/index.test.js: -------------------------------------------------------------------------------- 1 | const testSetup = require('../__shared__/test-setup'); 2 | const path = require('path'); 3 | const fs = require('fs'); 4 | 5 | test('Ignores node_modules when detecting TypeScript', async () => { 6 | // CRA build will check for TypeScript files by 7 | // globbing for src/**/*.ts however this shouldn't 8 | // include any node_modules directories within src. 9 | // See https://github.com/facebook/create-react-app/issues/5947 10 | 11 | const tsConfigPath = path.join(testSetup.testDirectory, 'tsconfig.json'); 12 | const tsPackagePath = [ 13 | testSetup.testDirectory, 14 | 'src', 15 | 'node_modules', 16 | 'package', 17 | 'index.ts', 18 | ]; 19 | const tsSrcPath = path.join(testSetup.testDirectory, 'src', 'index.ts'); 20 | 21 | // Step 1. 22 | // See if src/node_modules/package/index.ts is treated 23 | // as a JS project 24 | fs.mkdirSync(path.join(...tsPackagePath.slice(0, 2))); 25 | fs.mkdirSync(path.join(...tsPackagePath.slice(0, 3))); 26 | fs.mkdirSync(path.join(...tsPackagePath.slice(0, 4))); 27 | fs.writeFileSync(path.join(...tsPackagePath)); 28 | await testSetup.scripts.build(); 29 | expect(fs.existsSync(tsConfigPath)).toBe(false); 30 | 31 | // Step 2. 32 | // Add TS and ensure tsconfig.json is generated 33 | fs.writeFileSync(tsSrcPath); 34 | await testSetup.scripts.build(); 35 | expect(fs.existsSync(tsConfigPath)).toBe(true); 36 | }); 37 | -------------------------------------------------------------------------------- /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 Terser error 17 | if ( 18 | stack && 19 | typeof message === 'string' && 20 | message.indexOf('from Terser') !== -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: https://bit.ly/CRA-build-minify'); 41 | } else { 42 | console.log((message || err) + '\n'); 43 | } 44 | console.log(); 45 | }; 46 | -------------------------------------------------------------------------------- /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 | /* eslint-disable */ 21 | // Regression test for https://github.com/facebook/create-react-app/issues/3055 22 | const x = async ( 23 | /* prettier-ignore */ 24 | y: void 25 | ) => { 26 | const z = await y; 27 | }; 28 | /* eslint-enable */ 29 | 30 | export default class extends Component { 31 | static propTypes = { 32 | onReady: PropTypes.func.isRequired, 33 | }; 34 | 35 | constructor(props) { 36 | super(props); 37 | this.state = { users: [] }; 38 | } 39 | 40 | async componentDidMount() { 41 | const users = await load(); 42 | this.setState({ users }); 43 | } 44 | 45 | componentDidUpdate() { 46 | this.props.onReady(); 47 | } 48 | 49 | render() { 50 | return ( 51 |
52 | {this.state.users.map(user => ( 53 |
{user.name}
54 | ))} 55 |
56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /packages/react-scripts/lib/react-app.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | 5 | declare namespace NodeJS { 6 | interface ProcessEnv { 7 | NODE_ENV: 'development' | 'production' | 'test'; 8 | PUBLIC_URL: string; 9 | } 10 | } 11 | 12 | declare module '*.bmp' { 13 | const src: string; 14 | export default src; 15 | } 16 | 17 | declare module '*.gif' { 18 | const src: string; 19 | export default src; 20 | } 21 | 22 | declare module '*.jpg' { 23 | const src: string; 24 | export default src; 25 | } 26 | 27 | declare module '*.jpeg' { 28 | const src: string; 29 | export default src; 30 | } 31 | 32 | declare module '*.png' { 33 | const src: string; 34 | export default src; 35 | } 36 | 37 | declare module '*.webp' { 38 | const src: string; 39 | export default src; 40 | } 41 | 42 | declare module '*.svg' { 43 | import * as React from 'react'; 44 | 45 | export const ReactComponent: React.SFC>; 46 | 47 | const src: string; 48 | export default src; 49 | } 50 | 51 | declare module '*.module.css' { 52 | const classes: { [key: string]: string }; 53 | export default classes; 54 | } 55 | 56 | declare module '*.module.scss' { 57 | const classes: { [key: string]: string }; 58 | export default classes; 59 | } 60 | 61 | declare module '*.module.sass' { 62 | const classes: { [key: string]: string }; 63 | export default classes; 64 | } 65 | -------------------------------------------------------------------------------- /tasks/screencast-start.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Copyright (c) 2015-present, Facebook, Inc. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | */ 9 | 10 | 'use strict'; 11 | 12 | const execa = require('execa'); 13 | const meow = require('meow'); 14 | const multimatch = require('multimatch'); 15 | 16 | main(meow()); 17 | 18 | function main(cli) { 19 | let count = 0; 20 | 21 | const start = Date.now(); 22 | const duration = parseInt(cli.flags.timeout, 10) * 1000; 23 | const cp = execa.shell(cli.flags.command); 24 | 25 | const target = parseInt(cli.flags.patternCount || '1', 10); 26 | 27 | cp.stdout.on('data', data => { 28 | process.stdout.write(data); 29 | const matches = multimatch([String(data)], cli.flags.pattern); 30 | const errMatches = multimatch([String(data)], cli.flags.errorPattern); 31 | 32 | if (matches.length > 0) { 33 | count++; 34 | } 35 | 36 | if (errMatches.length > 0) { 37 | process.exit(1); 38 | } 39 | 40 | if (count >= target) { 41 | setTimeout(() => { 42 | process.exit(0); 43 | }, duration); 44 | } 45 | }); 46 | 47 | cp.on('exit', e => { 48 | const elapsed = Date.now() - start; 49 | 50 | if (elapsed >= duration) { 51 | return; 52 | } 53 | 54 | setTimeout(() => { 55 | process.exit(e.code); 56 | }, duration - elapsed); 57 | }); 58 | } 59 | -------------------------------------------------------------------------------- /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/facebook/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-app-polyfill/ie9.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 | if (typeof Promise === 'undefined') { 10 | // Rejection tracking prevents a common issue where React gets into an 11 | // inconsistent state due to an error, but it gets swallowed by a Promise, 12 | // and the user has no idea what causes React's erratic future behavior. 13 | require('promise/lib/rejection-tracking').enable(); 14 | window.Promise = require('promise/lib/es6-extensions.js'); 15 | } 16 | 17 | // Make sure we're in a Browser-like environment before importing polyfills 18 | // This prevents `fetch()` from being imported in a Node test environment 19 | if (typeof window !== 'undefined') { 20 | // fetch() polyfill for making API calls. 21 | require('whatwg-fetch'); 22 | } 23 | 24 | // Object.assign() is commonly used with React. 25 | // It will use the native implementation if it's present and isn't buggy. 26 | Object.assign = require('object-assign'); 27 | 28 | // Support for...of (a commonly used syntax feature that requires Symbols) 29 | require('core-js/es6/symbol'); 30 | // Support iterable spread (...Set, ...Map) 31 | require('core-js/fn/array/from'); 32 | 33 | // React 16+ relies on Map, Set, and requestAnimationFrame 34 | require('core-js/es6/map'); 35 | require('core-js/es6/set'); 36 | require('raf').polyfill(window); 37 | -------------------------------------------------------------------------------- /tasks/verdaccio.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # This is based on verdaccio's default config file. It allows all users 3 | # to do anything, so don't use it on production systems. 4 | # 5 | # Look here for more config file examples: 6 | # https://github.com/verdaccio/verdaccio/tree/master/conf 7 | # 8 | 9 | # path to a directory with all packages 10 | storage: ./storage 11 | 12 | auth: 13 | htpasswd: 14 | file: ./htpasswd 15 | # Maximum amount of users allowed to register, defaults to "+inf". 16 | # You can set this to -1 to disable registration. 17 | #max_users: 1000 18 | 19 | # a list of other known repositories we can talk to 20 | uplinks: 21 | npmjs: 22 | url: https://registry.npmjs.org/ 23 | 24 | packages: 25 | '@*/*': 26 | # scoped packages 27 | access: $all 28 | publish: $all 29 | proxy: npmjs 30 | 31 | '**': 32 | # allow all users (including non-authenticated users) to read and 33 | # publish all packages 34 | # 35 | # you can specify usernames/groupnames (depending on your auth plugin) 36 | # and three keywords: "$all", "$anonymous", "$authenticated" 37 | access: $all 38 | 39 | # allow all known users to publish packages 40 | # (anyone can register by default, remember?) 41 | publish: $all 42 | 43 | # if package is not available locally, proxy requests to 'npmjs' registry 44 | proxy: npmjs 45 | 46 | # log settings 47 | logs: 48 | - {type: stdout, format: pretty, level: http} 49 | #- {type: file, path: verdaccio.log, level: info} 50 | -------------------------------------------------------------------------------- /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/babel-preset-react-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-preset-react-app", 3 | "version": "7.0.2", 4 | "description": "Babel preset used by Create React App", 5 | "repository": "facebook/create-react-app", 6 | "license": "MIT", 7 | "bugs": { 8 | "url": "https://github.com/facebook/create-react-app/issues" 9 | }, 10 | "files": [ 11 | "create.js", 12 | "dependencies.js", 13 | "dev.js", 14 | "index.js", 15 | "webpack-overrides.js", 16 | "prod.js", 17 | "test.js" 18 | ], 19 | "dependencies": { 20 | "@babel/core": "7.3.4", 21 | "@babel/plugin-proposal-class-properties": "7.3.4", 22 | "@babel/plugin-proposal-decorators": "7.3.0", 23 | "@babel/plugin-proposal-object-rest-spread": "7.3.4", 24 | "@babel/plugin-syntax-dynamic-import": "7.2.0", 25 | "@babel/plugin-transform-classes": "7.3.4", 26 | "@babel/plugin-transform-destructuring": "7.3.2", 27 | "@babel/plugin-transform-flow-strip-types": "7.3.4", 28 | "@babel/plugin-transform-react-constant-elements": "7.2.0", 29 | "@babel/plugin-transform-react-display-name": "7.2.0", 30 | "@babel/plugin-transform-runtime": "7.3.4", 31 | "@babel/preset-env": "7.3.4", 32 | "@babel/preset-react": "7.0.0", 33 | "@babel/preset-typescript": "7.3.3", 34 | "@babel/runtime": "7.3.4", 35 | "babel-loader": "8.0.5", 36 | "babel-plugin-dynamic-import-node": "2.2.0", 37 | "babel-plugin-macros": "2.5.0", 38 | "babel-plugin-transform-react-remove-prop-types": "0.4.24" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/react-app-polyfill/README.md: -------------------------------------------------------------------------------- 1 | # react-app-polyfill 2 | 3 | This package includes polyfills for various browsers. 4 | It includes minimum requirements and commonly used language features used by [Create React App](https://github.com/facebook/create-react-app) projects. 5 | 6 | ### Features 7 | 8 | Each polyfill ensures the following language features are present: 9 | 10 | 1. `Promise` (for `async` / `await` support) 11 | 1. `window.fetch` (a Promise-based way to make web requests in the browser) 12 | 1. `Object.assign` (a helper required for Object Spread, i.e. `{ ...a, ...b }`) 13 | 1. `Symbol` (a built-in object used by `for...of` syntax and friends) 14 | 1. `Array.from` (a built-in static method used by array spread, i.e. `[...arr]`) 15 | 16 | *If you need more features, you must include them manually.* 17 | 18 | ### Usage 19 | 20 | First, install the package using Yarn or npm: 21 | 22 | ```sh 23 | npm install react-app-polyfill 24 | ``` 25 | 26 | or 27 | 28 | ```sh 29 | yarn add react-app-polyfill 30 | ``` 31 | 32 | Now, you can import the entry point for the minimal version you intend to support. For example, if you import the IE9 entry point, this will include IE10 and IE11 support. 33 | 34 | #### Internet Explorer 9 35 | 36 | ```js 37 | // This must be the first line in src/index.js 38 | import 'react-app-polyfill/ie9'; 39 | 40 | // ... 41 | ``` 42 | 43 | #### Internet Explorer 11 44 | 45 | ```js 46 | // This must be the first line in src/index.js 47 | import 'react-app-polyfill/ie11'; 48 | 49 | // ... 50 | ``` 51 | -------------------------------------------------------------------------------- /test/fixtures/mjs-support/index.test.js: -------------------------------------------------------------------------------- 1 | const testSetup = require('../__shared__/test-setup'); 2 | 3 | const puppeteer = require('puppeteer'); 4 | 5 | test('can use mjs library in development', async () => { 6 | const { port, done } = await testSetup.scripts.start(); 7 | 8 | const browser = await puppeteer.launch({ headless: true }); 9 | try { 10 | const page = await browser.newPage(); 11 | await page.goto(`http://localhost:${port}/`); 12 | await page.waitForSelector('.Pokemon-Name-Data', { timeout: 0 }); 13 | const output = await page.evaluate(() => { 14 | return Array.from( 15 | document.getElementsByClassName('Pokemon-Name-Data') 16 | ).pop().innerHTML; 17 | }); 18 | expect(output).toMatchSnapshot(); 19 | } finally { 20 | browser.close(); 21 | done(); 22 | } 23 | }); 24 | test('can use mjs library in production', async () => { 25 | await testSetup.scripts.build(); 26 | const { port, done } = await testSetup.scripts.serve(); 27 | 28 | const browser = await puppeteer.launch({ headless: true }); 29 | try { 30 | const page = await browser.newPage(); 31 | await page.goto(`http://localhost:${port}/`); 32 | await page.waitForSelector('.Pokemon-Name-Data', { timeout: 0 }); 33 | const output = await page.evaluate(() => { 34 | return Array.from( 35 | document.getElementsByClassName('Pokemon-Name-Data') 36 | ).pop().innerHTML; 37 | }); 38 | expect(output).toMatchSnapshot(); 39 | } finally { 40 | browser.close(); 41 | done(); 42 | } 43 | }); 44 | -------------------------------------------------------------------------------- /docusaurus/docs/updating-to-new-releases.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: updating-to-new-releases 3 | title: Updating to New Releases 4 | --- 5 | 6 | Create React App is divided into two packages: 7 | 8 | - `create-react-app` is a global command-line utility that you use to create new projects. 9 | - `react-scripts` is a development dependency in the generated projects (including this one). 10 | 11 | When you run `npx create-react-app my-app` it automatically installs the latest version of Create React App. 12 | > If you've previously installed `create-react-app` globally via `npm install -g create-react-app`, please visit [Getting Started](getting-started.md) to learn about current installation steps. 13 | 14 | Create React App creates the project with the latest version of `react-scripts` so you’ll get all the new features and improvements in newly created apps automatically. 15 | 16 | To update an existing project to a new version of `react-scripts`, [open the changelog](https://github.com/facebook/create-react-app/blob/master/CHANGELOG.md), find the version you’re currently on (check `package.json` in this folder if you’re not sure), and apply the migration instructions for the newer versions. 17 | 18 | In most cases bumping the `react-scripts` version in `package.json` and running `npm install` (or `yarn install`) in this folder should be enough, but it’s good to consult the [changelog](https://github.com/facebook/create-react-app/blob/master/CHANGELOG.md) for potential breaking changes. 19 | 20 | We commit to keeping the breaking changes minimal so you can upgrade `react-scripts` painlessly. 21 | -------------------------------------------------------------------------------- /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/facebook/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 [ -z $CI ]; then 30 | yarn compile:lockfile 31 | fi 32 | 33 | if [ -n "$(git status --porcelain)" ]; then 34 | echo "Your git status is not clean. Aborting."; 35 | exit 1; 36 | fi 37 | 38 | # Compile 39 | cd packages/react-error-overlay/ 40 | npm run build:prod 41 | cd ../.. 42 | 43 | # Get 2FA when not CI 44 | otp="" 45 | if [ -z $CI ]; then 46 | echo "Please enter npm two-factor auth code: " 47 | read otp 48 | fi 49 | 50 | # Go! 51 | NPM_CONFIG_OTP="$otp" ./node_modules/.bin/lerna publish --independent --npm-client=npm "$@" 52 | -------------------------------------------------------------------------------- /tasks/compile-lockfile.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 | 9 | 'use strict'; 10 | 11 | const cprocess = require('child_process'); 12 | const fse = require('fs-extra'); 13 | const os = require('os'); 14 | const path = require('path'); 15 | 16 | const temp = path.join(os.tmpdir(), `cra-compile-lockfile`); 17 | 18 | try { 19 | // Ensures that we start from a clean state 20 | fse.removeSync(temp); 21 | fse.mkdirSync(temp); 22 | 23 | // Create an empty package.json that we'll populate 24 | fse.writeFileSync(path.join(temp, 'package.json'), '{}'); 25 | 26 | // Extract the dependencies from react-scripts (which is a workspace) 27 | const dependencies = require('react-scripts/package.json').dependencies; 28 | const descriptors = Object.keys(dependencies).map( 29 | dep => `${dep}@${dependencies[dep]}` 30 | ); 31 | 32 | // Run "yarn add" with all the dependencies of react-scripts 33 | cprocess.execFileSync('yarn', ['add', ...descriptors], { cwd: temp }); 34 | 35 | // Store the generated lockfile in create-react-app 36 | // We can't store it inside react-scripts, because we need it even before react-scripts is installed 37 | fse.copySync( 38 | path.join(temp, 'yarn.lock'), 39 | path.join( 40 | __dirname, 41 | '..', 42 | 'packages', 43 | 'create-react-app', 44 | 'yarn.lock.cached' 45 | ) 46 | ); 47 | } finally { 48 | fse.removeSync(temp); 49 | } 50 | -------------------------------------------------------------------------------- /test/fixtures/mjs-support/src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import ApolloClient, { gql } from 'apollo-boost'; 3 | import { ApolloProvider, Query } from 'react-apollo'; 4 | 5 | const GET_PIKA = gql` 6 | { 7 | pokemon(name: "Pikachu") { 8 | name 9 | } 10 | } 11 | `; 12 | 13 | const client = new ApolloClient({ 14 | uri: 'https://graphql-pokemon.now.sh/graphql', 15 | }); 16 | 17 | class Pokemon extends Component { 18 | render() { 19 | const { name } = this.props.pokemon; 20 | return ( 21 |

22 | Pokemon name: {name} 23 |

24 | ); 25 | } 26 | } 27 | 28 | class Data extends Component { 29 | state = {}; 30 | componentDidCatch() { 31 | this.setState({ hasError: true }); 32 | } 33 | render() { 34 | const { hasError } = this.state; 35 | return hasError ? ( 36 |
Error :(
37 | ) : ( 38 | 39 | {({ loading, error, data }) => { 40 | if (loading) { 41 | return
Loading...
; 42 | } 43 | if (error) { 44 | return
Error :(
; 45 | } 46 | return ; 47 | }} 48 |
49 | ); 50 | } 51 | } 52 | 53 | class App extends Component { 54 | render() { 55 | return ( 56 | 57 | 58 | 59 | ); 60 | } 61 | } 62 | 63 | export default App; 64 | --------------------------------------------------------------------------------