Skip to content

Commit

Permalink
Feat/cra update (#204)
Browse files Browse the repository at this point in the history
* Publish

 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]

* Update runtime chunk name separator in docs (facebook#7705)

* Remove 'shortcut' link type before 'icon' (facebook#7707)

* Guard polyfills against window possibly being undefined (facebook#7205)

* Enable .eslintignore with extend flag (facebook#7562)

* Add "entrypoints" key to asset manifest (facebook#7721)

* Update adding flow documentation (facebook#7731)

* set output.globalObject to 'this' (facebook#7742)

Closes facebook#7741

* Update logic and log errors for EXTEND_ESLINT (facebook#7530)

* update list of supported jest config overrides (facebook#7601)

* Upgrade Webpack version (facebook#7740)

* Close br tags in template README files (facebook#7668)

* Fix variable name casing in fileTransform (facebook#7752)

* Documentation typo fix (facebook#7757)

* Fix linting error when using rest props (facebook#7754)

* Add TSC_COMPILE_ON_ERROR setting (facebook#6931)

* Remove switch case (facebook#7729)

* docs: note that v2 to v3 migration may require deletion of node_modules (facebook#7302)

* Stop hiding the column number of ESLint errors (facebook#6980)

* Support setting baseUrl to root directory (facebook#7755)

* Use installing package manager in README (facebook#7687)

* Support production profiling with React Developer Tools (facebook#7737)

* Added the alias for profiling and output change to keep the classNames and functionNames for human readbility

* defined isEnvProductionProfile with other isEnv checks

* moved the keep_classnames and keep_fnames to terserOptions scope

* resolve merge conflict for yarn.lock.cache

* revert yarn.lock.cache to master yarn.lock.cache
- git checkout origin/master -- packages/create-react-app/yarn.lock.cached

* Comment and Boolean Check
- I clarified the comment and specified the use case
- Changed the environment check to check for the specific true rather than
the assumed primitive value as before.

* Replaced env with flag
- Per suggestion --profile flag used instead of env variable PROFILE_APP

* documentation in available scripts section with suggested information

* resolved a local git issue. Fixed documentation error.

* moved documentation to suggested file
- Added a brief summary of profiling in available scripts section.
The summary references the production-build document. Which is the
file I moved the new documentation into under a new Header for production support.

* Update production-build.md


Co-authored-by: Ian Sutherland <[email protected]>

* Prepare 3.2.0 release

* Publish

 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]

* Temporarily disable Windows in CI (facebook#7773)

* Add babel runtime version to transform-runtime plugin to reduce… (facebook#7726)

* Add Babel sourcemap to resolve VSCode debugging issues (facebook#7022)

* Fix process type in TypeScript template (facebook#7796)

* Account for browserslist environment variables (facebook#7764)

* Clarify dynamic import stage in docs (facebook#7813)

* Update adding-typescript.md (facebook#7815)

* Document how to use the .env file to enforce HTTPS (facebook#7821)

* Fix absolute paths issue in Jest (facebook#7822)

* Document correct default behavior for HOST var (facebook#7823)

* Fix grammar error in troubleshooting.md (facebook#7824)

* Upgrade to docusaurus 2 (facebook#7785)

* chore: upgrade to docusaurus 2

* address review

* Update doc publishing instructions

* Revert logo in templates (facebook#7830)

* feat: add additional Jest keys to whitelist (facebook#7832)

* Link to React documentation for code splitting (facebook#7686)

The official documentation offers a simpler way of achieving route based code splitting.

* Add a note about .eslingignore files being respected (facebook#7809)

* added check for typescript template and unsupported node version (facebook#7839)

* added check for typescript template and unsupported node version

* addressed code review feedback regarding syntax and spelling mistakes

* Update getting-started.md (facebook#7841)

Update the initial project structure generated by create-react-app.

* Link to ASP.NET Core docs (facebook#7840)

* Update readme gif links (facebook#7849)

* Update adding-bootstrap.md (facebook#7853)

typo fix

* Move unused eslint webpack import into @remove-on-eject block (facebook#7856)

* 📖 DOC: Improvement (facebook#7819)

* Upgrade terser & enable parallel minification in wsl (facebook#7857)

* Add a GitHub Action that runs the build script (facebook#7861)

* Edit InterpolateHtmlPlugin hook (facebook#6448) (facebook#6449)

* Fix notations of loopback addresses (facebook#7474)

* Add Service-Worker header to checkValidServiceWorker (facebook#6753)

* Add header to checkValidServiceWorker (ts)

* Add header to checkValidServiceWorker

* Add additional information for postcss errors (facebook#6282) (facebook#6352)

* Add additional information for postcss errors

* Add additional information for postcss errors (simplify)

* Remove chunkname from postCSS compile error

* Remove line number from postCSS compile error

* Fix eslint complaints in build.js (facebook#7870)

* Add Alex to lint documentation (facebook#7852)

* Add Alex to lint documentation

* Attempt to trigger GitHub Action

* Configure Alex and update docs

* More docs updates

* Bump docusaurus 🦖 (facebook#7874)

* Dark scheme overlay (facebook#7052)

* Bump react (facebook#7875)

* Bump styling related loaders (facebook#7876)

* Remove alex precommit check (facebook#7878)

* Add template support (facebook#7716)

* Add template support

* Update templates version check

* Update TypeScript template README

* Prepare 3.3.0 beta

* If template name already starts with cra-template leave it alone (facebook#7880)

* Update prerelease publishing instructions

* Upgrade packages and tweak config to adapt to new config format (facebook#7814)

Rebased again now with smaller changes in this one which will make it easier to revert in case of eventual regressions.

* refactor: remove double coerce (facebook#7882)

* Add yarn.lock to .gitignore (facebook#7789)

* chore: Fix broken link for CRA deployment (facebook#7897)

* chore: Fix broken link for e2e README (facebook#7896)

* Add @testing-library to the default templates (facebook#7881)

* Add numeric separator support (facebook#7817)

* Update open (facebook#7910)

* Mark TypeScript as an optional peer dependency (facebook#7860)

* Add restoreMocks to supported jest config keys (facebook#7921)

* fix seperators typo (facebook#7932)

Its the little things that makes the big difference!  😁

Thanks

* No spinning React logo if `prefers-reduced-motion` (facebook#7931)

* Made PRs welcome badge point to contributors guide (facebook#7792)

* Make JavaScript and TypeScript templates consistent (facebook#7944)

* Fix CI (facebook#7951)

* Add optional chaining and nullish coalescing operators support (facebook#7438)

* Add tests for optional chaining and null coalescing (facebook#7952)

* Upgrade jest-watch-typeahead (facebook#7956)

* Fix light background in docusaurus night mode (facebook#7936)

* Fix light background in docusaurus night mode

Closes facebook#7930

* Rename lightBackground to gettingStartedSection

* Add placeholders where old template READMEs used to be (facebook#7972)

* Temporarily disable GitHub Actions (facebook#7978)

* Prepare 3.3.0 beta

* Bump dependencies (facebook#7986)

* Support scoped templates (facebook#7991)

* Add contributors section to readme (facebook#7995)

* added e2e test for checking typescript template with unsupported node (facebook#7844)

* Unpin dependencies in react-app-polyfill (facebook#7999)

* Add scripts support to templates (facebook#7989)

* Override no-unused-expressions with the typescript-eslint version (facebook#8003)

Fixes issues with optional chaining

* Prefix apple-touch-icon links with PUBLIC_URL. (facebook#8005)

* Bump webpack-dev-server (facebook#7988)

* Bump dependencies (facebook#8024)

* Re-enable GitHub Actions (facebook#8029)

* Update CHANGELOG

* Update CODEOWNERS

* Remove no-unexpected-multiline rule (facebook#8039)

* Add TypeScript peer dependency to react-scripts (facebook#8038)

* Update template docs (facebook#8050)

* Update template docs

* Update custom-templates.md

* Update custom-templates.md


Co-authored-by: Ian Sutherland <[email protected]>

* Prepare 3.3.0 release

* Update CHANGELOG

* Publish

 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]

* webpackHotDev now uses wss when https is used (facebook#8079)

* Add custom-templates to docs sidebar (facebook#8077)

* Fix typo in CHANGELOG.md (facebook#8080)

* Remove error for @typescript-eslint/no-namespace (facebook#7803)

Declare namespaces are supported by babel now, and babel will throw with a nice error message for non-declare namespaces, so this rule is unnecessary. Closes facebook#7651.

* Fix CI build (facebook#8122)

* Fix CSS font-face minification (facebook#8106)

* Add slashes to WebSocket protocol URL (facebook#8116)

* Fix typo in comment: `?.` is right, not `.?` (facebook#8124)

This is just a comment fix.

Actual optional chaining operator syntax is `?.`, not `.?`.

* chore: update docusaurus & tweak site (facebook#8111)

* [Security] Update terser webpack plugin (facebook#8102)

* security: update terser webpack plugin

* Add current version and bin location to --info output (facebook#8168)

Make the --info subcommand outuput the current version information and the location of the file being run. Our issue template tells users to provide the output of --info, so having the current version is incredibly helpful, especially since it doesn't necessarily match the globally installed version that envinfo outputs. Knowing the location helps us determine whether the running bin is globally installed or in the local node_modules.

* Bump pkgUp (facebook#8163)

* Bump chalk (facebook#8164)

* Add link to Netlify in README

* Bump internal dependencies (facebook#8176)

* Bump dependencies in react-dev-utils

* Bump dependencies in react-app-polyfill

* Bump dependencies in create-react-app

* Bump dependencies in react-error-overlay

* Bump dependencies in react-scripts

* Bump react

* Add package-runner note to readme (facebook#8132)

* Add package-runner note to readme

* Add link to `yarn create`

* Update PWA docs links to point to template package (facebook#8147)

* Minor refactors in create-react-app (facebook#8178)

- Remove templates version minimum stopgap.
- Replace indexOf with more idiomatic alternatives.
- Inline errorLogFilePatterns.
- Alphabetize validFiles.
- Simplify log file removal code.
- Move unconditional console.log() call outside of isSafe.
- Differentiate conflicting directories from files.
- Document yarn version special case.
- Inline printValidationResults.
- Standardize checkAppName output on failure.
- Add link for checkThatNpmCanReadCwd.

Functionally the code should be exactly the same.

* fix: proactively append to .gitignore during init (facebook#8028)

* Bump babel-plugin-tester and fix breaking changes (facebook#8171)

* Little typo (facebook#8212)

* Replace favicon in templates (facebook#8194)

The old favicon was the same as the official react documentation, which is a minor annoyance during development when trying to find the tab you want. The new favicon is just the old with inverted colors.

Closes facebook#7957

* Support shorthand scoped templates (facebook#8298)

* Allow additional package keys and add blacklist (facebook#8082) (facebook#8219)

* Minor grammatical edit (facebook#8293)

* Update Dependencies (facebook#8324)

* Remove React.FC from Typescript template (facebook#8177)

This removes `React.FC` from the base template for a Typescript project.

Long explanation for a small change: 

`React.FC` is unnecessary: it provides next to no benefits and has a few downsides.  (See below.)  I see a lot of beginners to TS+React using it, however, and I think that it's usage in this template is a contributing factor to that, as the prominence of this template makes it a de facto source of "best practice".  

### Downsides to React.FC/React.FunctionComponent

##### Provides an implicit definition of `children`

Defining a component with `React.FC` causes it to implicitly take `children` (of type `ReactNode`).  It means that all components accept children, even if they're not supposed to, allowing code like:

```ts
const App: React.FC = () => { /*... */ };
const Example = () => {
	<App><div>Unwanted children</div></App>
}
```

This isn't a run-time error, but it is a mistake and one that would be caught by Typescript if not for `React.FC`. 

##### Doesn't support generics.
I can define a generic component like:
```ts
type GenericComponentProps<T> = {
   prop: T
   callback: (t: T) => void
}
const GenericComponent = <T>(props: GenericComponentProps<T>) => {/*...*/}
```

But it's not possible when using `React.FC` - there's no way to preserve the unresolved generic `T` in the type returned by `React.FC`.

```ts
const GenericComponent: React.FC</* ??? */> = <T>(props: GenericComponentProps<T>) => {/*...*/}
```

##### Makes "component as namespace pattern" more awkward.
It's a somewhat popular pattern to use a component as a namespace for related components (usually children):

```jsx
<Select>
	<Select.Item />
</Select>
```

This is possible, but awkward, with `React.FC`:

```tsx
const  Select: React.FC<SelectProps> & { Item: React.FC<ItemProps> } = (props) => {/* ... */ }
Select.Item = (props) => { /*...*/ }
```

but "just works" without `React.FC`:

```tsx
const Select = (props: SelectProps) => {/* ... */}
Select.Item = (props) => { /*...*/ }
```

##### Doesn't work correctly with defaultProps

This is a fairly moot point as in both cases it's probably better to use ES6 default arguments, but...

```tsx
type  ComponentProps = { name: string; }

const  Component = ({ name }: ComponentProps) => (<div>
	{name.toUpperCase()} /* Safe since name is required */
</div>);
Component.defaultProps = { name: "John" };

const  Example = () => (<Component />) /* Safe to omit since name has a default value */
```
This compiles correctly.  Any approach with `React.FC` will be slightly wrong: either `React.FC<{name: string}>` will make the prop required by consumers, when it should be optional, or `React.FC<{name?: string}>` will cause `name.toUpperCase()` to be a type error.  There's no way to replicate the "internally required, externally optional" behavior which is desired.

##### It's as long, or longer than the alternative: (especially longer if you use `FunctionalComponent`):
Not a huge point, but it isn't even shorter to use `React.FC` 
```ts
const C1: React.FC<CProps> = (props) => { }
const C2 = (props: CProps) => {};
```

### Benefits of React.FC

##### Provides an explicit return type

The only benefit I really see to `React.FC` (unless you think that implicit `children` is a good thing) is that it specifies the return type, which catches mistakes like:

```ts
const Component = () => {
   return undefined; // components aren't allowed to return undefined, just `null`
}
```

In practice, I think this is fine, as it'll be caught as soon as you try to use it:

```ts
const Example = () => <Component />; // Error here, due to Component returning the wrong thing
```

But even with explicit type annotations, `React.FC` still isn't saving very much boilerplate:

```ts
const Component1 = (props: ComponentProps): ReactNode => { /*...*/ }
const Component2: FC<ComponentProps> = (props) => { /*...*/ }
```

* Downgrade open from 7.0.0 to 6.4.0 (facebook#8364)

* Remove outdated babel plugins (facebook#8353)

Updates dependencies and removes babel plugins that are now covered by `@babel/preset-env`.

Co-authored-by: hdineen <[email protected]>

* Add titleProp to SVGR ReactComponent type definition (facebook#8099)

* Sync dependencies babel config (facebook#8120)

* Update custom template docs with instructions for testing custom template locally (facebook#8092)

Co-authored-by: Ian Schmitz <[email protected]>

* Update setting-up-your-editor.md (facebook#8247)

`Auto Fix is enabled by default. Use the single string form.` warning is shown in `.vscode/settings.json` due to changes in vscode-eslint. 
As autoFix is set to default, object format in `eslint.validate` is deprecated.

* Remove outdated docs regarding vscode eslint extension and type… (facebook#8307)

Co-authored-by: Ian Schmitz <[email protected]>

* Fix sass importLoaders (facebook#8281)

* Add "Disallow:" to robots.txt (facebook#8255)

* Add helpful message to the footer (facebook#6548)

* Update docs according to lint-staged v10 (facebook#8394)

* docs: Add troubleshooting documentation on ENOSPC (facebook#8380)

Co-authored-by: Ian Schmitz <[email protected]>

* Prepare 3.3.1 release

* Publish

 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]

* Make the PWA link point to the right place (facebook#8379)

* Update commit message to use imperative mood (facebook#8377)

Why:

* As per best practice:
  https://git.kernel.org/pub/scm/git/git.git/tree/Documentation/SubmittingPatches#n135

  See also:
  https://chris.beams.io/posts/git-commit/#imperative

* Wider Chromium support for openBrowser (facebook#8367)

* Expands scope of openBrowser tab control

Adjust openChrome.applescript to allow manipulation of
other Chromium-based browsers (defaulting to Chrome).
Requires list of compatible browsers to try in openBrowser.js

* Fix typo

* Remove Safari

* fix(test): force install npm in e2e-behaviour (facebook#8402)

This will fix e2e-behaviour on macos

Related: npm/cli#611 (comment)

* setupTestFrameworkScriptFile is deprecated (facebook#8390)

* setupTestFrameworkScriptFile is deprecated

__Note:_ `_setupTestFrameworkScriptFile_` _is deprecated in favor of_ `_setupFilesAfterEnv_`_.__

ref: https://jestjs.io/docs/en/configuration#setupfilesafterenv-array

* Update docusaurus/docs/running-tests.md

Co-Authored-By: Simen Bekkhus <[email protected]>

Co-authored-by: Simen Bekkhus <[email protected]>

* Fix robots.txt for TS (facebook#8403)

* Update public folder usage docs to clarify globals (facebook#8299)

Added the relevant topic linked directly, instead of saying it's just in the next section.
Adjusted the text so it sounds more like a recommendation rather than a requirement.
The topic linked is basically explainer to how you'd reference it using the global window object and ways to avoid linter errors. Thus I used 'reference' to give users a hint of what it the linked page would be for.

* Run git init before template dependencies are installed (facebook#8282)

* Support JetBrains Rider IDE as an editor (facebook#7948)

Rider is JetBrains .NET IDE, which supports the React plugin identically to other JetBrains IDEs such as Idea and WebStorm.

* Enable custom sockjs pathname for hot reloading server. (facebook#7750)

* Enable custom sockjs pathname for hot reloading server.

* Update docusaurus/docs/advanced-configuration.md

Co-Authored-By: Brody McKee <[email protected]>

* let WDS_SOCKET_PATH be undefined

* adding env variables for sockHost and sockPort options

Co-authored-by: Brody McKee <[email protected]>

* Add option to provide custom ssl certificates during development (facebook#5845)

* Add option to provide custom SSL certificates when using HTTPS

* Update documentation with custom HTTPS certs

* Improve certificate validation and move to its own file

* Update https in development docs

Co-Authored-By: Brody McKee <[email protected]>

* Add custom cert example to docs

* Rename https file and update error message

* Include original error message when custom ssl cert is invalid

* Add chalk to react-scripts dependencies

* Bump docs version to say that the new config will be available in 3.2.0

* Remove chalk dependency

* Update custom ssl version to 3.4.0 in docs

* Remove version from custom ssl certificate docs

Co-authored-by: Brody McKee <[email protected]>

* Handle service worker error in Firefox (facebook#8272)

* Handle service worker error in Firefox

See https://bugzilla.mozilla.org/show_bug.cgi?id=1429714 for more details.

* Update serviceWorker.js

* feat(react-scripts): allow PUBLIC_URL in develoment mode (facebook#7259)

Co-authored-by: Eric Clemmons <[email protected]>
Co-authored-by: Alex Guerra <[email protected]>
Co-authored-by: Kelly <[email protected]>

Co-authored-by: Eric Clemmons <[email protected]>
Co-authored-by: Alex Guerra <[email protected]>
Co-authored-by: Kelly <[email protected]>

* Change arrow functions to function declarations (facebook#8412)

- The JavaScript template uses a function declaration to define the component, the TypeScript template and a page of the documentation used arrow functions. Changed it to use function declarations for consistency and readability.

* Fix navbar line break in header (facebook#8437)

* Fixes unchecked access to 'deploy' script on build (facebook#8292)

* Downgrade chalk for ie 11 support (facebook#8439)

* Downgrade chalk for ie 11 support

* Update lockfile

* fix(react-scripts): do not redirect served path if request may proxy (facebook#8442)

Moved redirect middleware and noopSW middleware in WDS after hook
So proxy, and before proxy will take precedence before redirect

Closes facebook#8417

* fix(typescriptFormatter): use chalk@2 constructor (facebook#8450)

Related facebook#8164
Related facebook#8439

* update open to v7.0.2 (facebook#8459)

* Correct webpack name casing (facebook#8475)

webpack should always be written in lower-case, according to webpack's branding guidelines https://webpack.js.org/branding

* Downgrade style-loader to v0.23.1 due to CSS modules hot reload… (facebook#8378)

* Prepare 3.4.0 release

* Publish

 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]

* fix missing packages in react-scripts

Co-authored-by: Ian Sutherland <[email protected]>
Co-authored-by: Samuel Meuli <[email protected]>
Co-authored-by: Lewis Llobera <[email protected]>
Co-authored-by: Jake Moxey <[email protected]>
Co-authored-by: Iguchi Tomokatsu <[email protected]>
Co-authored-by: Federico Zivolo <[email protected]>
Co-authored-by: Kent C. Dodds <[email protected]>
Co-authored-by: Laurin Quast <[email protected]>
Co-authored-by: neilbryson <[email protected]>
Co-authored-by: Reece Dunham <[email protected]>
Co-authored-by: Rakan Nimer <[email protected]>
Co-authored-by: Tomer Cohen <[email protected]>
Co-authored-by: Alexandr Tovmach <[email protected]>
Co-authored-by: Kyle Bebak <[email protected]>
Co-authored-by: André Lins <[email protected]>
Co-authored-by: Kim Persson <[email protected]>
Co-authored-by: Justin Grant <[email protected]>
Co-authored-by: Robert van Steen <[email protected]>
Co-authored-by: Ashrith Reddy <[email protected]>
Co-authored-by: Jacob M-G Evans <[email protected]>
Co-authored-by: Ian Schmitz <[email protected]>
Co-authored-by: Damian Senn <[email protected]>
Co-authored-by: Róbert FUSZENECKER <[email protected]>
Co-authored-by: May <[email protected]>
Co-authored-by: Orta <[email protected]>
Co-authored-by: Tomáš Hübelbauer <[email protected]>
Co-authored-by: Jesse Jackson <[email protected]>
Co-authored-by: Jake Boone <[email protected]>
Co-authored-by: Endi <[email protected]>
Co-authored-by: Brody McKee <[email protected]>
Co-authored-by: Hugo David-Boyet <[email protected]>
Co-authored-by: Sean Lafferty <[email protected]>
Co-authored-by: Ali Waseem <[email protected]>
Co-authored-by: reactjser <[email protected]>
Co-authored-by: Daniel Lo Nigro <[email protected]>
Co-authored-by: Chun <[email protected]>
Co-authored-by: Xuhao <[email protected]>
Co-authored-by: Sean Baines <[email protected]>
Co-authored-by: Abdul Wahab ⚡️ <[email protected]>
Co-authored-by: Guillaume Hertault <[email protected]>
Co-authored-by: Wataru Ashihara <[email protected]>
Co-authored-by: darthmaim <[email protected]>
Co-authored-by: Joshua Robinson <[email protected]>
Co-authored-by: Andreas Cederström <[email protected]>
Co-authored-by: Fabiano Brito <[email protected]>
Co-authored-by: Kanitkorn Sujautra <[email protected]>
Co-authored-by: Havit Rovik <[email protected]>
Co-authored-by: Tharun Rajendran <[email protected]>
Co-authored-by: Dylan Staley <[email protected]>
Co-authored-by: Donavon West <[email protected]>
Co-authored-by: James George <[email protected]>
Co-authored-by: RJ <[email protected]>
Co-authored-by: Renato Augusto Gama dos Santos <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Alex Guerra <[email protected]>
Co-authored-by: Klas Björkqvist <[email protected]>
Co-authored-by: Max Davidson <[email protected]>
Co-authored-by: Ben Blank <[email protected]>
Co-authored-by: Mike Caulley <[email protected]>
Co-authored-by: Trontor <[email protected]>
Co-authored-by: Sean Zhu <[email protected]>
Co-authored-by: Simon Donaldson <[email protected]>
Co-authored-by: Wojciech Zieliński <[email protected]>
Co-authored-by: Vadzim <[email protected]>
Co-authored-by: Jerome De Leon <[email protected]>
Co-authored-by: Peet Goddard <[email protected]>
Co-authored-by: Brian Muenzenmeyer <[email protected]>
Co-authored-by: Sony AK <[email protected]>
Co-authored-by: Kai Hao <[email protected]>
Co-authored-by: Tom Valorsa <[email protected]>
Co-authored-by: Evan Grim <[email protected]>
Co-authored-by: Retsam <[email protected]>
Co-authored-by: Vincent Semrau <[email protected]>
Co-authored-by: Henry Q. Dineen <[email protected]>
Co-authored-by: Rasmus Nørskov <[email protected]>
Co-authored-by: Kevin Old <[email protected]>
Co-authored-by: Boyuan Xu <[email protected]>
Co-authored-by: Alex James Vukovity <[email protected]>
Co-authored-by: Marius Craciunoiu <[email protected]>
Co-authored-by: Tomoya Fujita <[email protected]>
Co-authored-by: Joshua Pollak <[email protected]>
Co-authored-by: Hu Chen <[email protected]>
Co-authored-by: Cassidy Williams <[email protected]>
Co-authored-by: Christopher Button <[email protected]>
Co-authored-by: Matthew Curtis <[email protected]>
Co-authored-by: Andrew Luca <[email protected]>
Co-authored-by: 吕立青 <[email protected]>
Co-authored-by: Simen Bekkhus <[email protected]>
Co-authored-by: Martin Litvaj <[email protected]>
Co-authored-by: Kevin Pham <[email protected]>
Co-authored-by: Łukasz Fiszer <[email protected]>
Co-authored-by: David Powell <[email protected]>
Co-authored-by: Grady Kuhnline <[email protected]>
Co-authored-by: Alex Brazier <[email protected]>
Co-authored-by: Rohit Singhal <[email protected]>
Co-authored-by: Eric Clemmons <[email protected]>
Co-authored-by: Kelly <[email protected]>
Co-authored-by: Eugene Sviridov <[email protected]>
Co-authored-by: Renato Böhler <[email protected]>
Co-authored-by: Eugene Chybisov <[email protected]>
  • Loading branch information
Show file tree
Hide file tree
Showing 77 changed files with 3,931 additions and 3,158 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG-1.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ yarn add --exact [email protected]
- [#3757](https://github.com/facebook/create-react-app/pull/3757) Try updating Flow. ([@gaearon](https://github.com/gaearon))
- [#3414](https://github.com/facebook/create-react-app/pull/3414) Export `dismissRuntimeErrors` function. ([@skidding](https://github.com/skidding))
- [#3036](https://github.com/facebook/create-react-app/pull/3036) Cleaning up `printHostingInstructions` a bit. ([@GreenGremlin](https://github.com/GreenGremlin))
- [#3514](https://github.com/facebook/create-react-app/pull/3514) Fix `FileSizeReporter` for multi build Webpack setups. ([@iiska](https://github.com/iiska))
- [#3514](https://github.com/facebook/create-react-app/pull/3514) Fix `FileSizeReporter` for multi build webpack setups. ([@iiska](https://github.com/iiska))
- [#3362](https://github.com/facebook/create-react-app/pull/3362) Refactor extra watch options regex to `react-dev-utils`. ([@xjlim](https://github.com/xjlim))

#### Committers: 47
Expand Down Expand Up @@ -1104,7 +1104,7 @@ or
yarn add --dev --exact [email protected]
```

**If you previously used `HTTPS=true` environment variable in development**, make sure you aren't affected by a now-fixed vulnerability in Webpack by [visiting this page](http://badcert.mike.works/). You can read more about the vulnerability [here](https://medium.com/@mikenorth/webpack-preact-cli-vulnerability-961572624c54).
**If you previously used `HTTPS=true` environment variable in development**, make sure you aren't affected by a now-fixed vulnerability in webpack by [visiting this page](http://badcert.mike.works/). You can read more about the vulnerability [here](https://medium.com/@mikenorth/webpack-preact-cli-vulnerability-961572624c54).

You may optionally then move `react-scripts` from `devDependencies` to `dependencies` since that’s how we’ll structure newly created projects. It is not necessary though.

Expand Down Expand Up @@ -1724,7 +1724,7 @@ Please [file an issue](https://github.com/facebook/create-react-app/issues/new)
- `react-dev-utils`
- [#2125](https://github.com/facebook/create-react-app/pull/2125) Only show the first compilation error. ([@gaearon](https://github.com/gaearon))
- [#2120](https://github.com/facebook/create-react-app/pull/2120) Omit ESLint warnings when there are ESLint errors. ([@gaearon](https://github.com/gaearon))
- [#2113](https://github.com/facebook/create-react-app/pull/2113) Prettify errors and warnings for Webpack 2. ([@gaearon](https://github.com/gaearon))
- [#2113](https://github.com/facebook/create-react-app/pull/2113) Prettify errors and warnings for webpack 2. ([@gaearon](https://github.com/gaearon))
- [#1842](https://github.com/facebook/create-react-app/pull/1842) Modularize and extract crash overlay to iframe. ([@Timer](https://github.com/Timer))
- `create-react-app`
- [#1811](https://github.com/facebook/create-react-app/pull/1811) Allow creation of apps in empty Mercurial repos. ([@GreenGremlin](https://github.com/GreenGremlin))
Expand Down Expand Up @@ -1770,7 +1770,7 @@ Please [file an issue](https://github.com/facebook/create-react-app/issues/new)
- [#1736](https://github.com/facebook/create-react-app/pull/1736) Fix eject for linked react-scripts. ([@tuchk4](https://github.com/tuchk4))
- [#1741](https://github.com/facebook/create-react-app/pull/1741) Fix internal linting setup. ([@gaearon](https://github.com/gaearon))
- [#1730](https://github.com/facebook/create-react-app/pull/1730) Fix Node 4 e2e tests. ([@Timer](https://github.com/Timer))
- [#1715](https://github.com/facebook/create-react-app/pull/1715) Remove unused `url` import in Webpack config. ([@pd4d10](https://github.com/pd4d10))
- [#1715](https://github.com/facebook/create-react-app/pull/1715) Remove unused `url` import in webpack config. ([@pd4d10](https://github.com/pd4d10))
- [#1700](https://github.com/facebook/create-react-app/pull/1700) Update extract-text-webpack-plugin to stable. ([@SimenB](https://github.com/SimenB))
- `react-dev-utils`, `react-scripts`
- [#2209](https://github.com/facebook/create-react-app/pull/2209) Move more logic from react-scripts to react-dev-utils. ([@gaearon](https://github.com/gaearon))
Expand Down
8 changes: 4 additions & 4 deletions CHANGELOG-2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ You can read more about [these polyfills here](https://github.com/facebook/creat

### Dynamic `import()` of a CommonJS module now has a `.default` property

[Webpack 4 changed the behavior of `import()`](https://medium.com/webpack/webpack-4-import-and-commonjs-d619d626b655) to be closer in line with the specification.
[webpack 4 changed the behavior of `import()`](https://medium.com/webpack/webpack-4-import-and-commonjs-d619d626b655) to be closer in line with the specification.

Previously, importing a CommonJS module did not require you specify the default export. In most cases, this is now required.
If you see errors in your application about `... is not a function`, you likely need to update your dynamic import, e.g.:
Expand Down Expand Up @@ -973,7 +973,7 @@ If you used 2.x alphas, please [follow these instructions](https://gist.github.c
- `react-scripts`
- [#5218](https://github.com/facebook/create-react-app/pull/5218) Support globalSetup and globalTeardown Jest options ([@gaearon](https://github.com/gaearon))
- [#5073](https://github.com/facebook/create-react-app/pull/5073) Add user defined proxy via middleware ([@Timer](https://github.com/Timer))
- [#3945](https://github.com/facebook/create-react-app/pull/3945) Allow bundles to be analyzed with Webpack-specific tools ([@joshwcomeau](https://github.com/joshwcomeau))
- [#3945](https://github.com/facebook/create-react-app/pull/3945) Allow bundles to be analyzed with webpack-specific tools ([@joshwcomeau](https://github.com/joshwcomeau))
- [#4195](https://github.com/facebook/create-react-app/pull/4195) Sass loader ([@Fabianopb](https://github.com/Fabianopb))
- [#3909](https://github.com/facebook/create-react-app/pull/3909) Add loader for .graphql files ([@petetnt](https://github.com/petetnt))
- [#1288](https://github.com/facebook/create-react-app/pull/1288) Create git repository with initial commit ([@mauricedb](https://github.com/mauricedb))
Expand All @@ -988,7 +988,7 @@ If you used 2.x alphas, please [follow these instructions](https://gist.github.c
- [#3865](https://github.com/facebook/create-react-app/pull/3865) Add opt-out for preset-flow to work with @babel/preset-typescript ([@oieduardorabelo](https://github.com/oieduardorabelo))
- [#3675](https://github.com/facebook/create-react-app/pull/3675) add experimental babel-plugin-macros support ([@kentcdodds](https://github.com/kentcdodds))
- `babel-preset-react-app`, `confusing-browser-globals`, `eslint-config-react-app`, `react-dev-utils`, `react-error-overlay`, `react-scripts`
- [#4077](https://github.com/facebook/create-react-app/pull/4077) Webpack 4 ([@andriijas](https://github.com/andriijas))
- [#4077](https://github.com/facebook/create-react-app/pull/4077) webpack 4 ([@andriijas](https://github.com/andriijas))
- `create-react-app`
- [#4350](https://github.com/facebook/create-react-app/pull/4350) Support package distribution tags ([@miraage](https://github.com/miraage))
- `babel-preset-react-app`, `react-scripts`
Expand Down Expand Up @@ -1125,7 +1125,7 @@ If you used 2.x alphas, please [follow these instructions](https://gist.github.c
- [#4846](https://github.com/facebook/create-react-app/pull/4846) Update jest version ([@skoging](https://github.com/skoging))
- [#4362](https://github.com/facebook/create-react-app/pull/4362) Bumped jest version to 22.4.1 ([@CGreenburg](https://github.com/CGreenburg))
- `babel-preset-react-app`, `confusing-browser-globals`, `eslint-config-react-app`, `react-dev-utils`, `react-error-overlay`, `react-scripts`
- [#4077](https://github.com/facebook/create-react-app/pull/4077) Webpack 4 ([@andriijas](https://github.com/andriijas))
- [#4077](https://github.com/facebook/create-react-app/pull/4077) webpack 4 ([@andriijas](https://github.com/andriijas))
- `babel-preset-react-app`
- [#4432](https://github.com/facebook/create-react-app/pull/4432) Update babel-plugin-macros to fix a bug ([@stereobooster](https://github.com/stereobooster))
- [#3818](https://github.com/facebook/create-react-app/pull/3818) Remove PropTypes from production build (#209) ([@iansu](https://github.com/iansu))
Expand Down
8 changes: 4 additions & 4 deletions docusaurus/docs/adding-a-stylesheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Adding a Stylesheet
sidebar_label: Adding Stylesheets
---

This project setup uses [Webpack](https://webpack.js.org/) for handling all assets. Webpack offers a custom way of “extending” the concept of `import` beyond JavaScript. To express that a JavaScript file depends on a CSS file, you need to **import the CSS from the JavaScript file**:
This project setup uses [webpack](https://webpack.js.org/) for handling all assets. webpack offers a custom way of “extending” the concept of `import` beyond JavaScript. To express that a JavaScript file depends on a CSS file, you need to **import the CSS from the JavaScript file**:

## `Button.css`

Expand All @@ -18,7 +18,7 @@ This project setup uses [Webpack](https://webpack.js.org/) for handling all asse

```js
import React, { Component } from 'react';
import './Button.css'; // Tell Webpack that Button.js uses these styles
import './Button.css'; // Tell webpack that Button.js uses these styles

class Button extends Component {
render() {
Expand All @@ -28,8 +28,8 @@ class Button extends Component {
}
```

**This is not required for React** but many people find this feature convenient. You can read about the benefits of this approach [here](https://medium.com/seek-blog/block-element-modifying-your-javascript-components-d7f99fcab52b). However you should be aware that this makes your code less portable to other build tools and environments than Webpack.
**This is not required for React** but many people find this feature convenient. You can read about the benefits of this approach [here](https://medium.com/seek-blog/block-element-modifying-your-javascript-components-d7f99fcab52b). However you should be aware that this makes your code less portable to other build tools and environments than webpack.

In development, expressing dependencies this way allows your styles to be reloaded on the fly as you edit them. In production, all CSS files will be concatenated into a single minified `.css` file in the build output.

If you are concerned about using Webpack-specific semantics, you can put all your CSS right into `src/index.css`. It would still be imported from `src/index.js`, but you could always remove that import if you later migrate to a different build tool.
If you are concerned about using webpack-specific semantics, you can put all your CSS right into `src/index.css`. It would still be imported from `src/index.js`, but you could always remove that import if you later migrate to a different build tool.
27 changes: 15 additions & 12 deletions docusaurus/docs/adding-images-fonts-and-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ id: adding-images-fonts-and-files
title: Adding Images, Fonts, and Files
---

With Webpack, using static assets like images and fonts works similarly to CSS.
With webpack, using static assets like images and fonts works similarly to CSS.

You can **`import` a file right in a JavaScript module**. This tells Webpack to include that file in the bundle. Unlike CSS imports, importing a file gives you a string value. This value is the final path you can reference in your code, e.g. as the `src` attribute of an image or the `href` of a link to a PDF.
You can **`import` a file right in a JavaScript module**. This tells webpack to include that file in the bundle. Unlike CSS imports, importing a file gives you a string value. This value is the final path you can reference in your code, e.g. as the `src` attribute of an image or the `href` of a link to a PDF.

To reduce the number of requests to the server, importing images that are less than 10,000 bytes returns a [data URI](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) instead of a path. This applies to the following file extensions: bmp, gif, jpg, jpeg, and png. SVG files are excluded due to [#1153](https://github.com/facebook/create-react-app/issues/1153). You can control the 10,000 byte threshold by setting the `IMAGE_INLINE_SIZE_LIMIT` environment variable as documented in our [advanced configuration](advanced-configuration.md).

Here is an example:

```js
import React from 'react';
import logo from './logo.png'; // Tell Webpack this JS file uses this image
import logo from './logo.png'; // Tell webpack this JS file uses this image

console.log(logo); // /logo.84287d09.png

Expand All @@ -25,7 +25,7 @@ function Header() {
export default Header;
```

This ensures that when the project is built, Webpack will correctly move the images into the build folder, and provide us with correct paths.
This ensures that when the project is built, webpack will correctly move the images into the build folder, and provide us with correct paths.

This works in CSS too:

Expand All @@ -35,9 +35,9 @@ This works in CSS too:
}
```

Webpack finds all relative module references in CSS (they start with `./`) and replaces them with the final paths from the compiled bundle. If you make a typo or accidentally delete an important file, you will see a compilation error, like when you import a non-existent JavaScript module. The final filenames in the compiled bundle are generated by Webpack from content hashes. If the file content changes in the future, Webpack will give it a different name in production so you don’t need to worry about long-term caching of assets.
webpack finds all relative module references in CSS (they start with `./`) and replaces them with the final paths from the compiled bundle. If you make a typo or accidentally delete an important file, you will see a compilation error, like when you import a non-existent JavaScript module. The final filenames in the compiled bundle are generated by webpack from content hashes. If the file content changes in the future, webpack will give it a different name in production so you don’t need to worry about long-term caching of assets.

Please be advised that this is also a custom feature of Webpack.
Please be advised that this is also a custom feature of webpack.

**It is not required for React** but many people enjoy it (and React Native uses a similar mechanism for images).

Expand All @@ -51,12 +51,15 @@ One way to add SVG files was described in the section above. You can also import

```js
import { ReactComponent as Logo } from './logo.svg';
const App = () => (
<div>
{/* Logo is an actual React component */}
<Logo />
</div>
);

function App() {
return (
<div>
{/* Logo is an actual React component */}
<Logo />
</div>
);
}
```

This is handy if you don't want to load SVG as a separate file. Don't forget the curly braces in the import! The `ReactComponent` import name is significant and tells Create React App that you want a React component that renders an SVG, rather than its filename.
Expand Down
Loading

0 comments on commit 102411c

Please sign in to comment.