nx/packages/react-native
Craigory Coppola 79cf69b4e4
feat(core): consolidate nx.json and workspace.json (#6642)
* feat(core): consolidate settings between workspace.json + nx.json

workspace.json (and linked project.json files) now contain all project specific settings.
nx.json now contains all settings that affect the whole workspace.

* chore(core): fix angular unit tests w/ new config

* chore(core): fix failing tests

* chore(core): fix formatting

* chore(core): fix more tests

* chore(core): normalize-nx-json feedback

* chore(core): Fix more unit tests

* chore(core): fix remaining tests in workspace

* chore(linter): fix remaining linter tests

* chore(core): fix remaining spec + build issues

* chore(core): formatting fixes

* feat(core): migration script to move config options to new locations

* chore(core): fix e2e tests

* chore(core): run format

* chore(react-native): fix failing tests

Signed-off-by: AgentEnder <craigorycoppola@gmail.com>

* feat(core): move properties to new location during format step

Signed-off-by: AgentEnder <craigorycoppola@gmail.com>

* feat(core): initial pass on ngcli-adapter for property consolidation

Signed-off-by: AgentEnder <craigorycoppola@gmail.com>

* chore(misc): fix tests

Signed-off-by: AgentEnder <craigorycoppola@gmail.com>

* docs(core): update docs with changes

* chore(misc): fix tests

* chore(core): code review changes

updateWorkspaceJson -> updateWorkspace, no longer uses updater function

Signed-off-by: AgentEnder <craigorycoppola@gmail.com>

* chore(core): fix bug in ngcli impl

* fix(core): fix bug in ngcli-adapter

Signed-off-by: AgentEnder <craigorycoppola@gmail.com>

* fix(core): fix ngcli-adapter

Signed-off-by: AgentEnder <craigorycoppola@gmail.com>

* chore(core): fix workspace e2e

* chore(core): fix nx-plugin e2e

* fix(core): move defaultProject to nx.json

* chore(core): fix broken workspace test

* chore(core): formatting

* chore(core): fix workspace format

* chore(core): add nxJson to ExecutorContext

Signed-off-by: AgentEnder <craigorycoppola@gmail.com>

* chore(core): remove all references ot `NxProjectConfiguration` from our code

* chore(core): Review Changes

* fix(core): update new config locations v13 migration
2021-10-14 10:42:47 -04:00
..
2021-09-20 16:39:13 -04:00
2021-09-20 16:39:13 -04:00

Nx - Smart, Extensible Build Framework

{{links}}


React Native Plugin for Nx

{{what-is-nx}}

{{getting-started}}

Table of Contents

Getting started

Create a new Nx workspace:

npx create-nx-workspace --cli=nx --preset=empty

Install React Native plugin

# Using npm
npm install --save-dev @nrwl/react-native

# Using yarn
yarn add -D @nrwl/react-native

Create an app

npx nx g @nrwl/react-native:app <app-name>

When using Nx, you can create multiple applications and themes in the same workspace. If you don't want to prefix your commands with npx, install @nrwl/cli globally.

Start the JavaScript bundler

npx nx start <app-name>

This will start the bundler at http://localhost:8081.

Run on devices

Make sure the bundler server is running.

Android:

npx nx run-android <app-name>

iOS: (Mac only)

npx nx run-ios <app-name> --install

Note: The --install flag installs Xcode dependencies before building the iOS app. This option keeps dependencies up to date.

Release build

Android:

npx nx build-android <app-name>

iOS: (Mac only)

No CLI support yet. Run in the Xcode project. See: https://reactnative.dev/docs/running-on-device

Test/lint the app

npx nx test <app-name>
npx nx lint <app-name>

Using components from React library

You can use a component from React library generated using Nx package for React. Once you run:

npx nx g @nrwl/react-native:lib ui-button

This will generate the UiButton component, which you can use in your app.

import { UiButton } from '@myorg/ui-button';

CLI Commands and Options

Usage:

npx nx [command] [app] [...options]

start

Starts the JS bundler that communicates with connected devices.

--port [number]

The port to listen on.

run-ios

Builds your app and starts it on iOS simulator.

--port [number]

The port of the JS bundler.

--install

Install dependencies for the Xcode project before building iOS app.

--sync

Sync app dependencies to its package.json. On by default, use --no-sync to turn it off.

run-android

Builds your app and starts it on iOS simulator.

--port [number]

The port of the JS bundler.

--sync

Sync app dependencies to its package.json. On by default, use --no-sync to turn it off.

sync-deps

Sync app dependencies to its package.json.

--include [string]

A comma-separate list of additional packages to include.

e.g. nx sync-deps [app] --include react-native-gesture,react-native-safe-area-context

Learn more

Visit the Nx Documentation to learn more.