-
Notifications
You must be signed in to change notification settings - Fork 24.9k
docs: add README file for packages #41789
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
Closed
okwasniewski
wants to merge
1
commit into
facebook:main
from
okwasniewski:okwasniewski/packages-docs
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Packages | ||
|
||
## Creating new package | ||
|
||
1. Create a new folder inside `packages/<your-package>`. | ||
2. Add `package.json` file: | ||
```json | ||
{ | ||
"name": "@react-native/<your-package>", | ||
"version": "1000.0.0", | ||
"description": "Package description", | ||
"keywords": [ | ||
"react-native" | ||
], | ||
"homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/<your-package>#readme", | ||
"bugs": "https://github.com/facebook/react-native/issues", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/facebook/react-native.git", | ||
"directory": "packages/<your-package>" | ||
}, | ||
"license": "MIT", | ||
} | ||
``` | ||
2. Add `README.md` and an `index.js` file | ||
|
||
### Setting up build step for packages containing `flow` types (Optional) | ||
|
||
1. Make sure the package implementation is placed inside of `src` directory (this is what the `build.js` script expects). | ||
2. Add `.gitignore` file containing: | ||
|
||
``` | ||
# Dependencies | ||
/node_modules | ||
|
||
# Build output | ||
/dist | ||
``` | ||
|
||
3. Add following properties to `package.json`: | ||
|
||
```json | ||
{ | ||
//... | ||
"exports": { | ||
".": "./src/index.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"engines": { | ||
"node": ">=18" | ||
} | ||
} | ||
``` | ||
|
||
- Next, in `scripts/build/config.js` add `<your-package>` inside of `buildConfig` object, like so: | ||
```js | ||
const buildConfig = { | ||
packages: { | ||
'<your-package>': { | ||
target: 'node' | ||
} | ||
}, | ||
}; | ||
``` | ||
|
||
- Optionally you can specify `buildOptions` for example: whether to emit TypeScript definition files (`.d.ts`). | ||
|
||
In order to verify if new package was configured properly run `yarn build` in the root directory and check if `packages/<your-package>/dist` folder contains newly created files. | ||
|
||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As things stand today, the root
yarn build
setup applies only for packages written in Flow and targeting Node.js. In other cases, packages written in plain JS or Flow (or TypeScript, outside this repo) are consumed via@react-native/babel-preset
and require no build.