Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new yarn workspaces config format #4001

Merged
merged 1 commit into from
Feb 11, 2018

Conversation

detrohutt
Copy link
Contributor

@detrohutt detrohutt commented Feb 9, 2018

With the addition of the nohoist feature, yarn has enabled a new optional format for the workspaces key in package.json:

"workspaces": {
   "packages": ["packages/*"],
    "nohoist": ["**"]
}

This feature is already available in the current yarn nightly build and I'm successfully using it with the following setup:

yarn@1.4.1-20180208.2355 (nightly)
react-scripts@2.0.0-next.47d2d941 (with my patch)
lerna@2.8.0 (with a similar patch)

With these patches applied, everything worked out-of-the-box*, aside from needing to make use of the nohoist option.
*(obviously, I also needed to configure lerna to use yarn and workspaces)

With the nightly build of yarn installed all enabling nohoist required was:

  1. Adding the settings shown above to my package.json
  2. Adding the following to my .yarnrc:
--workspaces-experimental true
--workspaces-nohoist-experimental true

I could put together a demo lerna repo with my patches applied if needed, but I'm pretty busy with my current project, so if it's not necessary I won't bother.

Similarly, I'd be willing to add a new test to prove it gets the values from workspaces.packages when present. But I'm wondering if that's overkill for such a simple change.

Let me know if you have any questions or concerns! :)

@detrohutt
Copy link
Contributor Author

detrohutt commented Feb 9, 2018

The build error I'm seeing:

TypeError: Cannot read property 'loose' of undefined (While processing preset: "/tmp/tmp.uBrV9CToKQ/yarn-ws/node_modules/babel-preset-react-app/index.js")

This doesn't seem related to my change..

@iansu
Copy link
Contributor

iansu commented Feb 9, 2018

@bradfordlemley how does this fit with the monorepo work you're doing?

@bradfordlemley
Copy link
Contributor

Cool!
It's not necessary to use nohoist for any CRA-related stuff, but definitely want to support this workspace definition format.

Note: #3997 fixes the "'loose' of undefined" error and also moves the code that this PR is modifying.

@detrohutt
Copy link
Contributor Author

Thanks for the heads up! I'll be glad to update my PR as soon as #3997 is merged.

@detrohutt
Copy link
Contributor Author

@bradfordlemley I see the PR was merged. I'm updating mine now. It's still going to be a one-liner. Should I add a test? If so, is there a similar test I could base it off of? I'm not at all familiar with CRA's test suites since this is my first code commit.

@bradfordlemley
Copy link
Contributor

bradfordlemley commented Feb 10, 2018

Tests are in e2e-monorepos.sh. In my opinion, an additional test isn't necessary.

@detrohutt
Copy link
Contributor Author

detrohutt commented Feb 10, 2018

Alright, I've updated it. I manually tested by doing this:

  • ran yarn create-react-app test-app
  • copied test-app into the /packages/test-app of a lerna repo of mine with nohoist enabled
  • copied test-app to ~/git/test-app (not a monorepo)
  • ran yarn start from within each of the 3 copies:
    • monorepo without nohoist
    • monorepo with nohoist
    • standard repo

All worked fine. Let me know if I need to do anything else!

Copy link
Contributor

@bradfordlemley bradfordlemley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@gaearon gaearon added this to the 2.0.0 milestone Feb 11, 2018
@gaearon gaearon merged commit 9690bc8 into facebook:next Feb 11, 2018
tvalentius added a commit to tvalentius/create-react-app that referenced this pull request Feb 11, 2018
Add support for new yarn workspaces config format (facebook#4001)
akstuhl pushed a commit to akstuhl/create-react-app that referenced this pull request Mar 15, 2018
Timer added a commit to Timer/create-react-app that referenced this pull request Sep 18, 2018
@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants