Maybe.
I know monorepos are not fully supported, however i would expect this to work.
Yes
Node v8.11.3
yarn 1.10.1
npx 6.4.1
(Write your steps here:)
create-react-app@next --scripts-version=@next cra-appIt should create a new create react app.
When running create-react-app@next --scripts-version=@next cra-app, I am getting the following error:
Unexpected error. Please report it as a bug:
{ Error: Cannot find module '/Users/felixkuehl/cra-monorepo/packages/cra-app/node_modules/react-scripts/package.json'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at checkNodeVersion (/Users/felixkuehl/.npm/_npx/66044/lib/node_modules/create-react-app/createReactApp.js:543:23)
at getPackageName.then.then.then.packageName (/Users/felixkuehl/.npm/_npx/66044/lib/node_modules/create-react-app/createReactApp.js:344:7)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7) code: 'MODULE_NOT_FOUND' }
This could maybe due to yarn workspaces package hoisting.
Workaround is to just run create-react-app@next --scripts-version=@next cra-app outside the monorepo, then delete the node_modules folder and copy the new app into the monorepo.
Anyways, keep up the great work! ;)
Yeah, we can probably fix this. For now, just use your workaround. Thanks for the report!
May I ask how you created the mono repo? I have been trying to share some ui components between two projects using a mono repo. Only I haven't been able to get it working: https://github.com/weyert/monorepo
Does anyone know a good example of CRA2 with code sharing? I can find a bunch of repos on Github but they seem to depend on the now dropped monorepo support in CRA2
@weyert Check out my example repo https://github.com/FelixKuehl/cra-monorepo
In this setup I am using a Create React App 2.x together with a library to share components. I build a package in this monorepo called library-utils, that provides a custom babel watcher and handles basic setup to compile every package in your monorepo, if needed. So every create react app can be used as a library by simply adding 'build:watch': 'library-utils build:watch' to it's scripts (Do not forget to specify main and module as well).
The library is compiled and watched by babel. This works pretty well for me and basically behaves just as well as the original monorepo support in CRA 2. At least for my use case.
If you need more details, take a look at the readme in my repo and checkout my original Issue regarding dropped monorepo support in CRA 2 stable: https://github.com/facebook/create-react-app/issues/5100
Hope that helps!
Thanks @FelixKuehl I am going to have a closer look at your repo :)
Most helpful comment
@weyert Check out my example repo https://github.com/FelixKuehl/cra-monorepo
In this setup I am using a Create React App 2.x together with a library to share components. I build a package in this monorepo called library-utils, that provides a custom babel watcher and handles basic setup to compile every package in your monorepo, if needed. So every create react app can be used as a library by simply adding
'build:watch': 'library-utils build:watch'to it's scripts (Do not forget to specify main and module as well).The library is compiled and watched by babel. This works pretty well for me and basically behaves just as well as the original monorepo support in CRA 2. At least for my use case.
If you need more details, take a look at the readme in my repo and checkout my original Issue regarding dropped monorepo support in CRA 2 stable: https://github.com/facebook/create-react-app/issues/5100
Hope that helps!