Git Product home page Git Product logo

yarn-nohoist-examples's Introduction

yarn-nohoist-examples

demonstrate how to to use "nohoist" in yarn workspaces environment

Introduction

This repository contains examples of using nohoist in react/react-native workspaces. To get a more comprehensive introduction, please see nohoist in yarn workspaces.

workspaces-examples:

  1. react-native: step-by-step guide on how to set up a basic react-native monorepo project following react-native's getting started guide.
  2. universal-cipher: a more complex example including react, react-native, and node.js modules, to explore a few common challenges a monorepo project frequently face in the real world.

Environment:

Instructions in this repository are conducted using on the following:

  • os: MacOS 10.13.3
  • yarn: 1.4.1-20180211.22367 (1.4.2 pre-release)
  • node: 8.9.1
  • npm: 4.6.1
  • react-native: 0.52.x
  • react: 16.2
  • react-scripts: 1.1.0

Feedbacks

  • do let us know if the examples don't work for you
  • ideas for other examples? feel free to ask or better yet, submit PR.
  • if you believe it is a yarn error, please submit the issue in yarn.

yarn-nohoist-examples's People

Contributors

amcvitty avatar connectdotz avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

yarn-nohoist-examples's Issues

Monorepo with create-react-native-app

Maybe I'm missing something about how this should work, but I'm trying to set up a monorepo with my own project (so that I can share code between my mobile/web apps and my api). The mobile app already is partially written so I'm copying it into this monorepo as a package.

But when I follow the nohoist directions then run yarn start in the mobile-app package, I get a bunch of errors as below. Do I need to make sure all dependencies of my mobile app are not hoisted or something?

***ERROR STARTING PACKAGER***
Warning: 'es6-symbol' dependency is not installed.
Warning: 'immutable' dependency is not installed.
Warning: 'react-native-camera' dependency is not installed.
Warning: 'react-native-elements' dependency is not installed.
Warning: 'react-redux' dependency is not installed.
Warning: 'redux' dependency is not installed.
Warning: 'redux-persist' dependency is not installed.
Warning: 'redux-persist-transform-immutable' dependency is not installed.
Warning: 'redux-thunk' dependency is not installed.

This is what my monorepo package.json looks like (I use react-native-scripts-ts for typescript support):

{
  "private": true,
  "workspaces": {
    "packages": [
      "packages/*"
    ],
    "nohoist": [
      "**/react-native/**",
      "**/react-native",
      "**/react-native-scripts-ts",
      "**/react-native-scripts-ts/**",
      "**/expo",
      "**/expo/**"
    ]
  }
}

Would love a hint, it'd be pretty cool if I could make this work!

example where some dependencies get hoisted

Hey, thanks a lot for this, it has been really helpful!

I am looking for an example where some dependencies do get hoisted.

The trouble I am having is that when I call out react-native, expo, etc... to be hoisted, react native is having trouble finding the rest of my dependencies.

Fails with other dependencies in React Native

I've been struggling to get workspaces running with React Native and stumbled across this repo. I replicated the setup in my own project but kept running into errors, until I realized the same problem would occur here.

Adding any dependency that gets hoisted to the top node_modules fails - for example, react-redux which is pure JS so doesn't need to be in the RN repo.

I get the following error:

Looking for JS files in
   /Users/cmcewen/code/yarn-nohoist-examples/workspaces-examples/universal-cipher/packages/RNCipher
   /Users/cmcewen/code/yarn-nohoist-examples/workspaces-examples/universal-cipher/packages/cipher-core 


Metro Bundler ready.

Loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module `react-redux` from `/Users/cmcewen/code/yarn-nohoist-examples/workspaces-examples/universal-cipher/packages/RNCipher/App.js`: Module does not exist in the module map or in these directories:
  /Users/cmcewen/code/yarn-nohoist-examples/workspaces-examples/universal-cipher/node_modules

You can replicate it using this repo: https://github.com/cmcewen/yarn-nohoist-examples/tree/react-redux

Example using multi-stage builds

Hi! ๐Ÿ‘‹

Thank you for this fantastic repo, it has been helpful with a few projects i am working on. In an effort to have even smaller docker images, have you considered an example (or converting the publishing/webpack-docker project) to use multi-stage builds?

Thanks!

yarn test not running in CRNA example

If I build this project with a straight yarn install, then run yarn ios it runs correctly as described.

https://github.com/connectdotz/yarn-nohoist-examples/tree/master/workspaces-examples/react-native/rn-expo

However, running yarn test doesn't do anything because the "test" target in the sub-package is still

"test": "node node_modules/jest/bin/jest.js"

and the jest package has not been included in nohoist.

I managed to fix it by adding

      "**/jest-expo",
      "**/jest-expo/**"

to the package.json at the top. Reporting as an issue rather than a PR because I'm not sure this is the right thing to do here.

Attempting to develop react native package, but can't resolve module

Hey there,

So basically I'm developing two different scoped npm packages (one depends on the other) for React Native. I'd like to have a yarn workspace with: react native example app, package 1, package 2

What I pretty much want is how react-navigation has their project setup

I got React Native running the sample app in the workspace, so that's working, but when I try to import package 1, it says it can't resolve it.

If I'm using nohoist, and I import from within the example RN app, does it not check the root level node_modules? That is where package 1 is located, and I confirmed it's in there.

Folder setup:

  • example
    • node_modules (has react-native stuff)
    • index.js (import package from 'package-1')
  • node_modules (has package-1)
  • packages
    • package-1
    • package-2 (depends on package-1)

Symlinks

Does multiple packages also works?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.