{"componentChunkName":"component---src-templates-blog-js","path":"/blog/2018/10/01/create-react-app-v2.html","result":{"data":{"markdownRemark":{"html":"<p>Create React App 2.0 has been released today, and it brings a year’s worth of improvements in a single dependency update.</p>\n<p>While React itself <a href=\"/docs/create-a-new-react-app.html\">doesn’t require any build dependencies</a>, it can be challenging to write a complex app without a fast test runner, a production minifier, and a modular codebase. Since the very first release, the goal of <a href=\"https://github.com/facebook/create-react-app\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Create React App</a> has been to help you focus on what matters the most — your application code — and to handle build and testing setup for you.</p>\n<p>Many of the tools it relies on have since released new versions containing new features and performance improvements: <a href=\"https://babeljs.io/blog/2018/08/27/7.0.0\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Babel 7</a>, <a href=\"https://medium.com/webpack/webpack-4-released-today-6cdb994702d4\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">webpack 4</a>, and <a href=\"https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Jest 23</a>. However, updating them manually and making them work well together takes a lot of effort. And this is exactly what <a href=\"https://github.com/facebook/create-react-app/graphs/contributors\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Create React App 2.0 contributors</a> have been busy with for the past few months: <strong>migrating the configuration and dependencies so that you don’t need to do it yourself.</strong></p>\n<p>Now that Create React App 2.0 is out of beta, let’s see what’s new and how you can try it!</p>\n<blockquote>\n<p>Note</p>\n<p>Don’t feel pressured to upgrade anything. If you’re satisfied with the current feature set, its performance, and reliability, you can keep using the version you’re currently at! It might also be a good idea to let the 2.0 release stabilize a little bit before switching to it in production.</p>\n</blockquote>\n<h2 id=\"whats-new\"><a href=\"#whats-new\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What’s New </h2>\n<p>Here’s a short summary of what’s new in this release:</p>\n<ul>\n<li>🎉 More styling options: you can use <a href=\"https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-sass-stylesheet\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Sass</a> and <a href=\"https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-css-modules-stylesheet\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">CSS Modules</a> out of the box.</li>\n<li>🐠 We updated to <a href=\"https://babeljs.io/blog/2018/08/27/7.0.0\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Babel 7</a>, including support for the <a href=\"/docs/fragments.html#short-syntax\">React fragment syntax</a> and many bugfixes.</li>\n<li>📦 We updated to <a href=\"https://medium.com/webpack/webpack-4-released-today-6cdb994702d4\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">webpack 4</a>, which automatically splits JS bundles more intelligently.</li>\n<li>🃏 We updated to <a href=\"https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Jest 23</a>, which includes an <a href=\"https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing#interactive-snapshot-mode\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">interactive mode</a> for reviewing snapshots.</li>\n<li>💄 We added <a href=\"https://preset-env.cssdb.org/features#stage-3\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">PostCSS</a> so you can use new CSS features in old browsers.</li>\n<li>💎 You can use <a href=\"https://github.com/leoasis/graphql-tag.macro#usage\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Apollo</a>, <a href=\"https://github.com/facebook/relay/pull/2171#issuecomment-411459604\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Relay Modern</a>, <a href=\"https://github.com/facebook/create-react-app/issues/5149#issuecomment-425396995\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">MDX</a>, and other third-party <a href=\"https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Babel Macros</a> transforms.</li>\n<li>🌠 You can now <a href=\"https://facebook.github.io/create-react-app/docs/adding-images-fonts-and-files#adding-svgs\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">import an SVG as a React component</a>, and use it in JSX.</li>\n<li>🐈 You can try the experimental <a href=\"https://github.com/yarnpkg/rfcs/pull/101\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Yarn Plug’n’Play mode</a> that removes <code class=\"gatsby-code-text\">node_modules</code>.</li>\n<li>🕸 You can now <a href=\"https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#configuring-the-proxy-manually\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">plug your own proxy implementation</a> in development to match your backend API.</li>\n<li>🚀 You can now use <a href=\"https://github.com/sindresorhus/ama/issues/446#issuecomment-281014491\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">packages written for latest Node versions</a> without breaking the build.</li>\n<li>✂️ You can now optionally get a smaller CSS bundle if you only plan to target modern browsers.</li>\n<li>👷‍♀️ Service workers are now opt-in and are built using Google’s <a href=\"https://developers.google.com/web/tools/workbox/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Workbox</a>.</li>\n</ul>\n<p><strong>All of these features work out of the box</strong> — to enable them, follow the below instructions.</p>\n<h2 id=\"starting-a-project-with-create-react-app-20\"><a href=\"#starting-a-project-with-create-react-app-20\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Starting a Project with Create React App 2.0 </h2>\n<p>You don’t need to update anything special. Starting from today, when you run <code class=\"gatsby-code-text\">create-react-app</code> it will use the 2.0 version of the template by default. Have fun!</p>\n<p>If you want to <strong>use the old 1.x template</strong> for some reason, you can do that by passing <code class=\"gatsby-code-text\">--scripts-version=react-scripts@1.x</code> as an argument to <code class=\"gatsby-code-text\">create-react-app</code>.</p>\n<h2 id=\"updating-a-project-to-create-react-app-20\"><a href=\"#updating-a-project-to-create-react-app-20\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Updating a Project to Create React App 2.0 </h2>\n<p>Upgrading a non-ejected project to Create React App 2.0 should usually be straightforward. Open <code class=\"gatsby-code-text\">package.json</code> in the root of your project and find <code class=\"gatsby-code-text\">react-scripts</code> there.</p>\n<p>Then change its version to <code class=\"gatsby-code-text\">2.0.3</code>:</p>\n<div class=\"gatsby-highlight has-highlighted-lines\" data-language=\"jsx\"><pre class=\"gatsby-code-jsx\"><code class=\"gatsby-code-jsx\">  <span class=\"token comment\">// ... other dependencies ...</span>\n<span class=\"gatsby-highlight-code-line\">  <span class=\"token string\">\"react-scripts\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"2.0.3\"</span></span></code></pre></div>\n<p>Run <code class=\"gatsby-code-text\">npm install</code> (or <code class=\"gatsby-code-text\">yarn</code>, if you use it). <strong>For many projects, this one-line change is sufficient to upgrade!</strong></p>\n<blockquote class=\"twitter-tweet\" data-conversation=\"none\" data-dnt=\"true\"><p lang=\"en\" dir=\"ltr\">working here... thanks for all the new functionality 👍</p>&mdash; Stephen Haney (@sdothaney) <a href=\"https://twitter.com/sdothaney/status/1046822703116607490?ref_src=twsrc%5Etfw\">October 1, 2018</a></blockquote>\n<p>Here are a few more tips to get you started.</p>\n<p><strong>When you run <code class=\"gatsby-code-text\">npm start</code> for the first time after the upgrade,</strong> you’ll get a prompt asking about which browsers you’d like to support. Press <code class=\"gatsby-code-text\">y</code> to accept the default ones. They’ll be written to your <code class=\"gatsby-code-text\">package.json</code> and you can edit them any time. Create React App will use this information to produce smaller or polyfilled CSS bundles depending on whether you target modern browsers or older browsers.</p>\n<p><strong>If <code class=\"gatsby-code-text\">npm start</code> still doesn’t quite work for you after the upgrade,</strong> <a href=\"https://github.com/facebook/create-react-app/releases/tag/v2.0.3\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">check out the more detailed migration instructions in the release notes</a>. There <em>are</em> a few breaking changes in this release but the scope of them is limited, so they shouldn’t take more than a few hours to sort out. Note that <strong><a href=\"https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">support for older browsers</a> is now opt-in</strong> to reduce the polyfill size.</p>\n<p><strong>If you previously ejected but now want to upgrade,</strong> one common solution is to find the commits where you ejected (and any subsequent commits changing the configuration), revert them, upgrade, and later optionally eject again. It’s also possible that the feature you ejected for (maybe Sass or CSS Modules?) is now supported out of the box.</p>\n<blockquote>\n<p>Note</p>\n<p>Due to a possible bug in npm, you might see warnings about unsatisfied peer dependencies. You should be able to ignore them. As far as we’re aware, this issue isn’t present with Yarn.</p>\n</blockquote>\n<h2 id=\"breaking-changes\"><a href=\"#breaking-changes\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Breaking Changes </h2>\n<p>Here’s a short list of breaking changes in this release:</p>\n<ul>\n<li>Node 6 is no longer supported.</li>\n<li>Support for older browsers (such as IE 9 to IE 11) is now opt-in with a <a href=\"https://github.com/facebook/create-react-app/tree/master/packages/react-app-polyfill\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">separate package</a>.</li>\n<li>Code-splitting with <code class=\"gatsby-code-text\">import()</code> now behaves closer to specification, while <code class=\"gatsby-code-text\">require.ensure()</code> is disabled.</li>\n<li>The default Jest environment now includes jsdom.</li>\n<li>Support for specifying an object as <code class=\"gatsby-code-text\">proxy</code> setting was replaced with support for a custom proxy module.</li>\n<li>Support for <code class=\"gatsby-code-text\">.mjs</code> extension was removed until the ecosystem around it stabilizes.</li>\n<li>PropTypes definitions are automatically stripped out of the production builds.</li>\n</ul>\n<p>If either of these points affects you, <a href=\"https://github.com/facebook/create-react-app/releases/tag/v2.0.3\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">2.0.3 release notes</a> contain more detailed instructions.</p>\n<h2 id=\"learn-more\"><a href=\"#learn-more\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Learn More </h2>\n<p>You can find the full changelog in the <a href=\"https://github.com/facebook/create-react-app/releases/tag/v2.0.3\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">release notes</a>. This was a large release, and we may have missed something. Please report any problems to our <a href=\"https://github.com/facebook/create-react-app/issues/new\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">issue tracker</a> and we’ll try to help.</p>\n<blockquote>\n<p>Note</p>\n<p>If you’ve been using 2.x alpha versions, we provide <a href=\"https://gist.github.com/gaearon/8650d1c70e436e5eff01f396dffc4114\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">separate migration instructions</a> for them.</p>\n</blockquote>\n<h2 id=\"thanks\"><a href=\"#thanks\" aria-hidden class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Thanks </h2>\n<p>This release wouldn’t be possible without our wonderful community of contributors. We’d like to thank <a href=\"https://github.com/andriijas\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Andreas Cederström</a>, <a href=\"https://github.com/clemmy\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Clement Hoang</a>, <a href=\"https://github.com/existentialism\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Brian Ng</a>, <a href=\"https://github.com/kentcdodds\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Kent C. Dodds</a>, <a href=\"https://github.com/viankakrisna\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Ade Viankakrisna Fadlil</a>, <a href=\"https://github.com/ai\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Andrey Sitnik</a>, <a href=\"https://github.com/ro-savage\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Ro Savage</a>, <a href=\"https://github.com/Fabianopb\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Fabiano Brito</a>, <a href=\"https://github.com/iansu\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Ian Sutherland</a>, <a href=\"https://github.com/petetnt\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Pete Nykänen</a>, <a href=\"https://github.com/jeffposnick\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Jeffrey Posnick</a>, <a href=\"https://github.com/bugzpodder\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Jack Zhao</a>, <a href=\"https://github.com/sokra\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Tobias Koppers</a>, <a href=\"https://github.com/hzoo\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Henry Zhu</a>, <a href=\"https://github.com/arcanis\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Maël Nison</a>, <a href=\"https://github.com/lixiaoyan\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">XiaoYan Li</a>, <a href=\"https://github.com/themre\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Marko Trebizan</a>, <a href=\"https://github.com/mareksuscak\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Marek Suscak</a>, <a href=\"https://github.com/miraage\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Mikhail Osher</a>, and many others who provided feedback and testing for this release.</p>","excerpt":"Create React App 2.0 has been released today, and it brings a year’s worth of improvements in a single dependency update. While React itself doesn’t require any build dependencies, it can be challenging to write a complex app without a fast test runner, a production minifier, and a modular codebase. Since the very first release, the goal of Create React App has been to help you focus on what matters the most — your application code — and to handle build and testing setup for you. Many of the…","frontmatter":{"title":"Create React App 2.0: Babel 7, Sass, and More","next":null,"prev":null,"author":[{"frontmatter":{"name":"Joe Haddad","url":"https://twitter.com/timer150"}},{"frontmatter":{"name":"Dan Abramov","url":"https://twitter.com/dan_abramov"}}]},"fields":{"date":"October 01, 2018","path":"content/blog/2018-10-01-create-react-app-v2.md","slug":"/blog/2018/10/01/create-react-app-v2.html"}},"allMarkdownRemark":{"edges":[{"node":{"frontmatter":{"title":"Introducing the New JSX Transform"},"fields":{"slug":"/blog/2020/09/22/introducing-the-new-jsx-transform.html"}}},{"node":{"frontmatter":{"title":"React v17.0 Release Candidate: No New Features"},"fields":{"slug":"/blog/2020/08/10/react-v17-rc.html"}}},{"node":{"frontmatter":{"title":"React v16.13.0"},"fields":{"slug":"/blog/2020/02/26/react-v16.13.0.html"}}},{"node":{"frontmatter":{"title":"Building Great User Experiences with Concurrent Mode and Suspense"},"fields":{"slug":"/blog/2019/11/06/building-great-user-experiences-with-concurrent-mode-and-suspense.html"}}},{"node":{"frontmatter":{"title":"Preparing for the Future with React Prereleases"},"fields":{"slug":"/blog/2019/10/22/react-release-channels.html"}}},{"node":{"frontmatter":{"title":"Introducing the New React DevTools"},"fields":{"slug":"/blog/2019/08/15/new-react-devtools.html"}}},{"node":{"frontmatter":{"title":"React v16.9.0 and the Roadmap Update"},"fields":{"slug":"/blog/2019/08/08/react-v16.9.0.html"}}},{"node":{"frontmatter":{"title":"Is React Translated Yet? ¡Sí! Sim! はい！"},"fields":{"slug":"/blog/2019/02/23/is-react-translated-yet.html"}}},{"node":{"frontmatter":{"title":"React v16.8: The One With Hooks"},"fields":{"slug":"/blog/2019/02/06/react-v16.8.0.html"}}},{"node":{"frontmatter":{"title":"React v16.7: No, This Is Not the One With Hooks"},"fields":{"slug":"/blog/2018/12/19/react-v-16-7.html"}}}]}},"pageContext":{"slug":"/blog/2018/10/01/create-react-app-v2.html"}},"staticQueryHashes":[]}