Skip to content

Commit

Permalink
feat: implement MetroConfigHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
flisboac committed Nov 18, 2018
0 parents commit 31f80cd
Show file tree
Hide file tree
Showing 15 changed files with 10,031 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

root = true

[*]
end_of_line = crlf
charset = utf-8

[{src,scripts}/**.{ts,json,js,tsx}]
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
3 changes: 3 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Example Contributing Guidelines

This is an example of GitHub's contributing guidelines file. Check out GitHub's [CONTRIBUTING.md help center article](https://help.github.com/articles/setting-guidelines-for-repository-contributors/) for more information.
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* **I'm submitting a ...**
[ ] bug report
[ ] feature request
[ ] question about the decisions made in the repository
[ ] question about how to use this project

* **Summary**



* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
* **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...)



* **What is the current behavior?** (You can also link to an open issue here)



* **What is the new behavior (if this is a feature change)?**



* **Other information**:
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node_modules
build
test
src/**.js
.idea/*

coverage
.nyc_output
*.log

yarn.lock

.vscode/
14 changes: 14 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
src
test
tsconfig.json
tsconfig.module.json
tslint.json
.travis.yml
.github
.prettierignore
.vscode
build/docs
**/*.spec.*
coverage
.nyc_output
*.log
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# package.json is formatted by package managers, so we ignore it here
package.json
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Flávio Lisbôa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
84 changes: 84 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# react-native-monorepo-helper

A helper library that makes React Native development in monorepo projects easier.

If you're having problems with Metro/Haste not finding your files and/or
dependencies, or that your `nohoist` config is becoming a bit unwieldly,
this tool can help you out! It'll provide a `CustomResolver` and setup
project roots and watch folders for your `rn-cli.config.js`. TypeScript
configuration automation is also optionally provided.

P.S.: The tool itself is developed in TypeScript, so no need for a `@types`
package, fellow TypeScript programmers! :)


## Installation

For NPM users:

```sh
npm install --save-dev react-native-monorepo-helper
```

For Yarn users:

```sh
yarn add --dev react-native-monorepo-helper
```

## Usage

Considering a project with a structure similar to the following:

```
myproj/
├── package.json
├── node_modules/
└── packages/
   ├── myproj-react-native-app/
├── node_modules/
   │   ├── android/
   │   ├── ios/
   │   ├── index.js
   │   ├── package.json
   │   └── rn-cli.config.js
   └── myproj-lib
      ├── index.js
      └── package.json
```

First, be sure to `nohoist` React Native and any dependency that needs to be
`react-native link`ed. You can either use Lerna or Yarn Workspaces to configure
your monorepo project.

In your `rn-cli.config.js`:

```js
const projectRoot = __dirname;
const metroConfig = require('react-native-monorepo-helper').default;

module.exports = metroConfig(projectRoot);
```

Optionally, you can use a configuration helper, and tweak the options for your
needs, e.g. setting up TypeScript:

```js
const projectRoot = __dirname;
const metroConfigHelper = require('react-native-monorepo-helper')
.metroConfigHelper;

module.exports = metroConfigHelper(projectRoot)
.typeScript(true)
.watchFolder("external/folder/a", "external/folder/b")
.defaultConfig({
// Documentation: https://facebook.github.io/metro/docs/en/configuration
port: 9091
})
.generate();
```


## License

MIT.
Loading

0 comments on commit 31f80cd

Please sign in to comment.