Skip to content

Instantly share code, notes, and snippets.

Last active January 11, 2019 15:13
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save gaearon/8650d1c70e436e5eff01f396dffc4114 to your computer and use it in GitHub Desktop.

Migrating from

IMPORTANT: Do NOT do this if you didn't use 2.x alphas of react-scripts.

Inside any created project that has not been ejected, run:

$ npm install --save --save-exact react-scripts@2.0.3
$ # or
$ yarn add --exact react-scripts@2.0.3

After running this command, follow the instructions for migrating from 1.1.15 to 2.0.3. Then proceed to the migration steps below.

Monorepo support (from 2.x alphas) was removed in final 2.0

Monorepo support was half-baked and didn't account for many cases, so we decided to remove it. We know this is frustrating for people relying on it, but it was blocking the release and we didn't really have a solution that would work well in longer term. This is something we still want to do in the future, but we don't have a comprehensive proposal for this yet.

We're sorry that there's no easy way to migrate this, but it can be done:

For Application Logic

Importing application code should just work, provided it does not contain any JSX.

For Components

Importing uncompiled components (any file that contains JSX) will not work. You will need to compile these packages using something like nwb. Be sure your package.json main and module keys point to the compiled code and not the source code.

.graphql support was removed

We removed explicit support for importing .graphql files in favor of a Babel Macro.

Install graphql.macro and migrate your existing .graphql imports to look like this:

import { loader as gqlLoader } from 'graphql.macro';
const query = gqlLoader('./query.graphql');

New suggested browser defaults

Remove the browserslist key from package.json and you will be prompted to accept the new defaults next time you run the development server or a build.

Anything missing?

This was a large release, and we might have missed something.

Please file an issue and we will try to help.

Copy link

I am so happy you decided to remove support for monorepos. We are using monorepos with react app in one of the workspaces and we were following all releases where we had to fork and continuously change one line in react-scripts that was specifically disabling treating other monorepo dependencies as source dependencies (and as a result react-scripts were doing linting on already transpiled modules). I realised that version 2.0.0-next.2150693d was the first that removed that functionality and I was really uncertain if it will make it to the official release... I am so glad it did.

Copy link

thanks a lot! you have migration guide even from alpha!

Copy link

JacopKane commented Sep 27, 2018

one thing I noticed is I didn't see .mjs extension in jest config (and maybe webpack either couldn't check that yet) but I guess it was there for a while ago?

Copy link

patroza commented Oct 1, 2018

@marcinzenko just because it had some rough edges which you seemed to bump into, it's not so cool to see this awesome feature go, especially when relying big projects on it. An improvement to resolve your issue would've been a lot better.

Copy link

gaearon commented Oct 2, 2018

@patroza You're welcome to discuss how it should work in facebook/create-react-app#5161. We are very open to proposals, but this one just wasn't working well. We've made a decision not to ship it because fixing it without drastically rethinking it didn't appear possible. Again, if you know about a simple solution, you're welcome to propose it.

Copy link

kirill-konshin commented Oct 4, 2018

So sad you guys removed support for Monorepo. Basically this and SASS were the only desirable features of the 2.0 release.

The question now is if there is any 3.x alpha to switch on to have the previously implemented support?

Copy link

So sad you guys removed support for Monorepo. Basically this and SASS were the only desirable features of the 2.0 release.

The question now is if there is any 3.x alpha to switch on to have the previously implemented support?

Same here as @kirill-konshin, our project development multi-team workflow and tools are based on yarn workspaces, we've already implemented this workflow in our customer and cannot go back now.

Are there any plans to include this in a future stable version? Will this take long?


Copy link

bebbi commented Jan 11, 2019

For people interested in graphql:
graphql.macro seems to be unmaintained, graphql support for only basic use-cases and lots of open PRs.
Maybe there's another 'official' recommendation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment