react-native/package.json

109 lines
4.1 KiB
JSON
Raw Normal View History

{
"name": "@react-native/monorepo",
"private": true,
"version": "1000.0.0",
"license": "MIT",
"packageManager": "yarn@1.22.22",
"scripts": {
"android": "cd packages/rn-tester && npm run android",
"build-android": "./gradlew :packages:react-native:ReactAndroid:build",
"build": "node ./scripts/build/build.js",
"clang-format": "clang-format -i --glob=*/**/*.{h,cpp,m,mm}",
Add shared monorepo build setup (#38718) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38718 > NOTE: Replaces https://github.com/facebook/react-native/pull/38240 ## Context RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641 ## Changes To support incoming new React Native packages around debugging (including migrating over [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro)) — which target Node.js and require a build step, this PR adds a minimal shared build setup across the `react-native` monorepo. The setup is closely inspired/based on the build scripts in Jest, Metro, and React Native CLI — and is a simple set of script wrappers around Babel. These are available as build commands at the root of the repo: - `yarn build` — Builds all configured packages. Functionally, this: - Outputs a `dist/` directory with built files. - Rewrites package.json `"exports"` to update every `./src/*` reference to `./dist/*` (source of truth). - `scripts/build/babel-register.js` — Allows running all Node.js entry points from source, similar to the current setup in [facebook/metro](https://github.com/facebook/metro). (Example entry point file in this PR: `packages/dev-middleware/src/index.js`) Build configuration (i.e. Babel config) is shared as a set standard across the monorepo, and **packages are opted-in to requiring a build**, configured in `scripts/build.config.js`. ``` const buildConfig /*: BuildConfig */ = { // The packages to include for build and their build options packages: { 'dev-middleware': {target: 'node'}, }, }; ``` For now, there is a single `target: 'node'` option — this is necessary as `react-native`, unlike the above other projects, is a repository with packages targeting several runtimes. We may, in future, introduce a build step for other, non-Node, packages — which may be useful for things such as auto-generated TypeScript definitions. {F1043312771} **Differences from the Metro setup** - References (and compiles out) repo-local `scripts/build/babel-register.js` — removing need for an npm-published dependency. ## Current integration points - **CircleCI** — `yarn build` is added to the `build_npm_package` and `find_and_publish_bumped_packages` jobs. **New Node.js package(s) are not load bearing quite yet**: There are not yet any built packages added to the dependencies of `packages/react-native/`, so this will be further tested in a later PR (and is actively being done in an internal commit stack). ### Alternative designs **Per-package config file** Replace `scripts/build/config.js` with a package-defined key in in `package.json`, similar to Jest's [`publishConfig`](https://github.com/jestjs/jest/blob/1f019afdcdfc54a6664908bb45f343db4e3d0848/packages/jest-cli/package.json#L87C3-L89C4). ``` "buildConfig": { "type": "node" }, ``` This would be the only customisation required, with a single Babel config still standardised. Another option this might receive in future is `enableTypeScriptCodgeen`. **Rollup** More sophisticated build tool for Node.js, used by the React codebase (albeit within a custom script setup as well). **Lerna and Nx** - Most sophisticated setup enabling caching and optimised cloud runs. - Probably the most likely thing we'll move towards at a later stage. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D47760330 fbshipit-source-id: 38ec94708ce3d9946a197d80885781e9707c5841
2023-08-03 11:42:30 +00:00
"clean": "node ./scripts/build/clean.js",
"flow-check": "flow check",
"flow": "flow",
"format-check": "prettier --list-different \"./**/*.{js,md,yml,ts,tsx}\"",
"format": "npm run prettier && npm run clang-format",
"featureflags": "cd packages/react-native && yarn featureflags",
Bots cleanup, avoid leaving inline reviews when N>5 (#24923) Summary: This PR cleans up some of our GitHub bots. The overall goal is to make the contribution process just a tad nicer. ### analysis-bot * The bot will continue leaving GitHub Reviews when it finds lint issues, but will abstain from leaving inline comments if they would exceed 5 in number. * The review comment left by the bot has instructions on how to reproduce the lint issues locally. This will educate PR authors on how to run lint and fix the issues without unnecessarily spamming the PR with 50+ comments, while still providing useful reviews to authors when only a handful of lint issues slip by. * Code moved to `bots/` directory for ease of discovery and co-location with pull-bot. * Added `yarn lint-ci` command. This seems like the right choice: it's running `yarn lint` and other linters, and it is only intended to run on CI. * It's still possible to run `yarn lint-ci` locally, though the script will stop short of posting a review to GitHub unless the necessary envvars are provided. * Added `yarn shellcheck` command. This can be run locally, though it requires `shellcheck` to be installed. * Outside of this PR, I added instructions on using shellcheck to https://github.com/facebook/react-native/wiki/Development-Dependencies * Updated Circle CI config to use these new commands, and streamlined the `analyze_pr` step. * Documented analysis-bot in `bots/README.md`. ### pull-bot * Bumped `danger-js` dependency. No breaking changes found in this minor bump from what I can tell. * Documented pull-bot in `bots/README.md`. ### misc * PR template: don't use jargon. ## Changelog [Internal] [Changed] - GitHub Bots cleanup Pull Request resolved: https://github.com/facebook/react-native/pull/24923 Differential Revision: D15399744 Pulled By: hramos fbshipit-source-id: 32632e775f8554424072270e3f98542de84bfb8c
2019-05-22 02:35:40 +00:00
"lint-ci": "./scripts/circleci/analyze_code.sh && yarn shellcheck",
"lint-java": "node ./scripts/lint-java.js",
"lint": "eslint .",
Move TypeScript declarations into react-native (#34614) Summary: ## Changelog [General] [Added] - Add `types` folder to house TypeScript types. Release TypesScript types with react-native and eventually deprecate [types/react-native](https://www.npmjs.com/package/types/react-native). The current plan is to release types/react-native for 0.70 and 0.71 while also maintaining types here. This will result in some double maintenance until 0.72 but will give community time to move off of types/react-native. After this lands, there have been changes on `main` of types that we need to update. Then, when we release 0.71 from DefinitelyTyped, we can simply copy over the `types` folder from this repo. Pull Request resolved: https://github.com/facebook/react-native/pull/34614 Test Plan: `yarn run test-typescript` for linting types * Created a new project using the TS template and my local clone of `react-native` on this branch. `npx react-native init MyTSApp --version <path-to-my-local-rn-repo> --template react-native-template-typescript` * Updated the `package.json` to remove `types/react-native` * Deleted my node_modules and re-ran yarn * Opened MyTSApp in VSCode and verified the type suggestions appeared and cmd+click to defnitions took me to the node_module dependency `react-native/types` ## Danger is failing on this PR and it's expected as it runs off the changes on `main`. [This is expected](https://docs.github.com/en/github-ae@latest/actions/using-workflows/events-that-trigger-workflows?fbclid=IwAR2_AE0Jwndt8Gu-iTQnxGxLJq7nakbi7sz8jwZ6U62JWLSdcZuvjcQ6WvE#pull_request_target). However testing it locally passes. Once merged, and these changes are on `main`, danger will pass again. ``` $ react-native/packages/react-native-bots ❯ yarn danger pr https://github.com/facebook/react-native/pull/34614 yarn run v1.22.19 $ ..react-native/node_modules/.bin/danger pr https://github.com/facebook/react-native/pull/34614 Starting Danger PR on facebook/react-native#34614 Danger: ✓ found only warnings, not failing the build ## Warnings :lock: package.json - <i>Changes were made to package.json. This will require a manual import by a Facebook employee.</i> ✨ Done in 13.24s. ``` Reviewed By: mdvacca Differential Revision: D39479137 Pulled By: lunaleaps fbshipit-source-id: 1d506f812d566b783b6e79104cd6339b077a42a7
2022-09-19 19:26:00 +00:00
"prettier": "prettier --write \"./**/*.{js,md,yml,ts,tsx}\"",
Add print-packages as a command (#41959) Summary: Working on releases, I'm often looking for the name of our monorepo packages (as sometimes the name doesn't align with the directory) and also getting a list of the versions of everything, as well as if its private/public -- which I've interpreted to mean that we publish it or we don't. I thought this might be convenient to add. ## Changelog: [Internal] - Add `print-packages` as a command to print our monorepo packages (including react-native) Pull Request resolved: https://github.com/facebook/react-native/pull/41959 Test Plan: ``` ❯ yarn print-packages yarn run v1.22.19 $ node ./scripts/monorepo/print ┌─────────┬─────────┬─────────────────────────────────────────┬────────────────┐ │ (index) │ Public? │ Name │ Version (main) │ ├─────────┼─────────┼─────────────────────────────────────────┼────────────────┤ │ 0 │ '✅' │ 'react-native/assets-registry' │ '0.74.0' │ │ 1 │ '✅' │ 'react-native/babel-plugin-codegen' │ '0.74.0' │ │ 2 │ '✅' │ 'react-native/community-cli-plugin' │ '0.74.0' │ │ 3 │ '✅' │ 'react-native/debugger-frontend' │ '0.74.0' │ │ 4 │ '✅' │ 'react-native/dev-middleware' │ '0.74.0' │ │ 5 │ '✅' │ 'react-native/eslint-config' │ '0.74.0' │ │ 6 │ '✅' │ 'react-native/eslint-plugin' │ '0.74.0' │ │ 7 │ '✅' │ 'react-native/eslint-plugin-specs' │ '0.74.0' │ │ 8 │ '❌' │ 'react-native/hermes-inspector-msggen' │ '0.72.0' │ │ 9 │ '✅' │ 'react-native/metro-config' │ '0.74.0' │ │ 10 │ '✅' │ 'react-native/normalize-colors' │ '0.74.1' │ │ 11 │ '✅' │ 'react-native/js-polyfills' │ '0.74.0' │ │ 12 │ '✅' │ 'react-native' │ '1000.0.0' │ │ 13 │ '✅' │ 'react-native/babel-preset' │ '0.74.0' │ │ 14 │ '✅' │ 'react-native/metro-babel-transformer' │ '0.74.0' │ │ 15 │ '❌' │ 'react-native/bots' │ '0.0.0' │ │ 16 │ '✅' │ 'react-native/codegen' │ '0.74.0' │ │ 17 │ '❌' │ 'react-native/codegen-typescript-test' │ '0.0.1' │ │ 18 │ '✅' │ 'react-native/gradle-plugin' │ '0.74.0' │ │ 19 │ '❌' │ 'react-native/tester' │ '0.0.1' │ │ 20 │ '❌' │ 'react-native/tester-e2e' │ '0.0.1' │ │ 21 │ '✅' │ 'react-native/typescript-config' │ '0.74.0' │ │ 22 │ '✅' │ 'react-native/virtualized-lists' │ '0.74.0' │ └─────────┴─────────┴─────────────────────────────────────────┴────────────────┘ ✨ Done in 0.55s. ``` Also added filter flag for private/public ``` ❯ yarn print-packages --type private yarn run v1.22.19 $ node ./scripts/monorepo/print --type private ┌─────────┬─────────┬─────────────────────────────────────────┬────────────────┐ │ (index) │ Public? │ Name │ Version (main) │ ├─────────┼─────────┼─────────────────────────────────────────┼────────────────┤ │ 0 │ '❌' │ 'react-native/hermes-inspector-msggen' │ '0.72.0' │ │ 1 │ '❌' │ 'react-native/bots' │ '0.0.0' │ │ 2 │ '❌' │ 'react-native/codegen-typescript-test' │ '0.0.1' │ │ 3 │ '❌' │ 'react-native/tester' │ '0.0.1' │ │ 4 │ '❌' │ 'react-native/tester-e2e' │ '0.0.1' │ └─────────┴─────────┴─────────────────────────────────────────┴────────────────┘ ✨ Done in 0.16s. ``` Also added a npm query where you can see the latest published version of a minor ``` ❯ yarn print-packages --type public --minor 72 yarn run v1.22.19 $ node ./scripts/monorepo/print --type public --minor 72 ┌─────────┬─────────┬─────────────────────────────────────────┬────────────────┬──────────────────────────────────────┐ │ (index) │ Public? │ Name │ Version (main) │ Version (72) │ ├─────────┼─────────┼─────────────────────────────────────────┼────────────────┼──────────────────────────────────────┤ │ 0 │ '✅' │ 'react-native/assets-registry' │ '0.74.0' │ '0.72.0' │ │ 1 │ '✅' │ 'react-native/babel-plugin-codegen' │ '0.74.0' │ '0.72.3' │ │ 2 │ '✅' │ 'react-native/community-cli-plugin' │ '0.74.0' │ 'No match found for version ^0.72.0' │ │ 3 │ '✅' │ 'react-native/debugger-frontend' │ '0.74.0' │ 'No match found for version ^0.72.0' │ │ 4 │ '✅' │ 'react-native/dev-middleware' │ '0.74.0' │ 'No match found for version ^0.72.0' │ │ 5 │ '✅' │ 'react-native/eslint-config' │ '0.74.0' │ '0.72.2' │ │ 6 │ '✅' │ 'react-native/eslint-plugin' │ '0.74.0' │ '0.72.0' │ │ 7 │ '✅' │ 'react-native/eslint-plugin-specs' │ '0.74.0' │ '0.72.4' │ │ 8 │ '✅' │ 'react-native/metro-config' │ '0.74.0' │ '0.72.11' │ │ 9 │ '✅' │ 'react-native/normalize-colors' │ '0.74.1' │ '0.72.0' │ │ 10 │ '✅' │ 'react-native/js-polyfills' │ '0.74.0' │ '0.72.1' │ │ 11 │ '✅' │ 'react-native' │ '1000.0.0' │ '0.72.8' │ │ 12 │ '✅' │ 'react-native/babel-preset' │ '0.74.0' │ 'No match found for version ^0.72.0' │ │ 13 │ '✅' │ 'react-native/metro-babel-transformer' │ '0.74.0' │ 'No match found for version ^0.72.0' │ │ 14 │ '✅' │ 'react-native/codegen' │ '0.74.0' │ '0.72.8' │ │ 15 │ '✅' │ 'react-native/gradle-plugin' │ '0.74.0' │ '0.72.11' │ │ 16 │ '✅' │ 'react-native/typescript-config' │ '0.74.0' │ 'No match found for version ^0.72.0' │ │ 17 │ '✅' │ 'react-native/virtualized-lists' │ '0.74.0' │ '0.72.8' │ └─────────┴─────────┴─────────────────────────────────────────┴────────────────┴──────────────────────────────────────┘ ``` Reviewed By: cortinico Differential Revision: D52347140 Pulled By: lunaleaps fbshipit-source-id: 75811730e1afd5aae2d9fba4e437cd0d3d424a90
2024-01-02 19:46:03 +00:00
"print-packages": "node ./scripts/monorepo/print",
"shellcheck": "./scripts/circleci/analyze_scripts.sh",
"start": "cd packages/rn-tester && npm run start",
"set-version": "node ./scripts/releases/set-version.js",
"test-android": "./gradlew :packages:react-native:ReactAndroid:test",
"test-ci": "jest --maxWorkers=2 --ci --reporters=\"default\" --reporters=\"jest-junit\"",
"test-e2e-local-clean": "node ./scripts/release-testing/test-e2e-local-clean.js",
"test-e2e-local": "node ./scripts/release-testing/test-e2e-local.js",
Move TypeScript declarations into react-native (#34614) Summary: ## Changelog [General] [Added] - Add `types` folder to house TypeScript types. Release TypesScript types with react-native and eventually deprecate [types/react-native](https://www.npmjs.com/package/types/react-native). The current plan is to release types/react-native for 0.70 and 0.71 while also maintaining types here. This will result in some double maintenance until 0.72 but will give community time to move off of types/react-native. After this lands, there have been changes on `main` of types that we need to update. Then, when we release 0.71 from DefinitelyTyped, we can simply copy over the `types` folder from this repo. Pull Request resolved: https://github.com/facebook/react-native/pull/34614 Test Plan: `yarn run test-typescript` for linting types * Created a new project using the TS template and my local clone of `react-native` on this branch. `npx react-native init MyTSApp --version <path-to-my-local-rn-repo> --template react-native-template-typescript` * Updated the `package.json` to remove `types/react-native` * Deleted my node_modules and re-ran yarn * Opened MyTSApp in VSCode and verified the type suggestions appeared and cmd+click to defnitions took me to the node_module dependency `react-native/types` ## Danger is failing on this PR and it's expected as it runs off the changes on `main`. [This is expected](https://docs.github.com/en/github-ae@latest/actions/using-workflows/events-that-trigger-workflows?fbclid=IwAR2_AE0Jwndt8Gu-iTQnxGxLJq7nakbi7sz8jwZ6U62JWLSdcZuvjcQ6WvE#pull_request_target). However testing it locally passes. Once merged, and these changes are on `main`, danger will pass again. ``` $ react-native/packages/react-native-bots ❯ yarn danger pr https://github.com/facebook/react-native/pull/34614 yarn run v1.22.19 $ ..react-native/node_modules/.bin/danger pr https://github.com/facebook/react-native/pull/34614 Starting Danger PR on facebook/react-native#34614 Danger: ✓ found only warnings, not failing the build ## Warnings :lock: package.json - <i>Changes were made to package.json. This will require a manual import by a Facebook employee.</i> ✨ Done in 13.24s. ``` Reviewed By: mdvacca Differential Revision: D39479137 Pulled By: lunaleaps fbshipit-source-id: 1d506f812d566b783b6e79104cd6339b077a42a7
2022-09-19 19:26:00 +00:00
"test-ios": "./scripts/objc-test.sh test",
"test-typescript-offline": "dtslint --localTs node_modules/typescript/lib packages/react-native/types",
"test-typescript": "dtslint packages/react-native/types",
"test": "jest",
"trigger-react-native-release": "node ./scripts/releases-local/trigger-react-native-release.js",
Revert "feat: build codegen on postinstall (#46227)" (#46420) Summary: This reverts commit 0cb97f02614ea565c3207f5fb3cbe05987e381c1. Revert this commit that adds a `post install` script for a couple of reasons: 1. (EDIT: This turns out to be unrelated) The `postinstall` script causes `yarn install` to fail on React Native macOS, where we use Yarn 4. I'm not entirely sure why, but I probably won't debug it for the rest of the reasons. 2. `postinstall` scripts (at least inside Microsoft) are viewed as a security risk. Any package in your dependency tree can get compromised, add the phase, and run arbitrary code. This has happened in the past with React Native past if I recall correctly. As such, we disable `postinstall` scripts in many of our repos (including `rnx-kit` and `react-native-test-app`). 3. The issue this is trying to solve is to help newcomers avoid a stale cache when they switch branches in the React Native monorepo and only run `yarn install`. I think it would be sufficient to add some documentation somewhere that it is expected one runs `yarn && yarn build` to use this repo locally? That's a fairly common practice in monorepos, at least ones inside Microsoft. ## Changelog: [INTERNAL] [SECURITY] - Remove post install script phase in the React Native monorepo Pull Request resolved: https://github.com/facebook/react-native/pull/46420 Test Plan: CI should pass Reviewed By: christophpurrer, robhogan, cortinico, rshest Differential Revision: D62755022 Pulled By: huntie fbshipit-source-id: bf94ed33e3e451ea337ef7a6984f7ba964d0b212
2024-09-16 16:14:54 +00:00
"update-lock": "npx yarn-deduplicate"
},
"workspaces": [
"packages/*",
"tools/*",
"!packages/helloworld"
],
"devDependencies": {
update babel and fix tests accordingly (#46295) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46295 X-link: https://github.com/facebook/metro/pull/1343 Updated all **babel** packages in all `package.json` across the repo and ran `npx yarn-deduplicate yarn.lock --scopes babel`. Afterwards, fixed the following issues appearing as a result of that (squashed the following initially separate diffs to make this packages update work atomically): ### (D61336392) updated jest snapshot tests failing ### (D61336393) updated babel types and corrected typings accordingly The latest babel 7 introduces the following features we need to adjust our types to: * `JSXNamespacedName` is removed from valid `CallExpression` args ([PR](https://github.com/babel/babel/pull/16421)) * `JSXNamespacedName` is used for namespaced XML properties in things like `<div namespace:name="value">`, but `fn(namespace:name)` doesn't make any sense. * Dynamic imports are enabled behind a new flag `createImportExpressions` ([PR](https://github.com/babel/babel/pull/15682)), introducing calls such as `import(foo, options)`. These complicate the expected values passed to `import` to be more than just strings. * Since these are behind a flag that is not expected to be enabled, we can throw an error for now and whoever uses it can add a support to it if needed later. ### Added a new metro ENV ignore `BROWSERSLIST_ROOT_PATH` is set to `""` explicitly in `xplat/js/BUCK` and then ignored in `js/tools/metro-buck-transform-worker/src/EnvVarAllowList.js` Reviewed By: robhogan Differential Revision: D61543660 fbshipit-source-id: abbcab72642cf6dc03eed5142eb78dbcc7f63a86
2024-09-05 14:11:17 +00:00
"@babel/core": "^7.25.2",
"@babel/eslint-parser": "^7.25.1",
"@babel/generator": "^7.25.0",
"@babel/plugin-transform-regenerator": "^7.24.7",
"@babel/preset-env": "^7.25.3",
"@babel/preset-flow": "^7.24.7",
"@definitelytyped/dtslint": "^0.0.127",
"@jest/create-cache-key-function": "^29.6.3",
Add shared monorepo build setup (#38718) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38718 > NOTE: Replaces https://github.com/facebook/react-native/pull/38240 ## Context RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641 ## Changes To support incoming new React Native packages around debugging (including migrating over [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro)) — which target Node.js and require a build step, this PR adds a minimal shared build setup across the `react-native` monorepo. The setup is closely inspired/based on the build scripts in Jest, Metro, and React Native CLI — and is a simple set of script wrappers around Babel. These are available as build commands at the root of the repo: - `yarn build` — Builds all configured packages. Functionally, this: - Outputs a `dist/` directory with built files. - Rewrites package.json `"exports"` to update every `./src/*` reference to `./dist/*` (source of truth). - `scripts/build/babel-register.js` — Allows running all Node.js entry points from source, similar to the current setup in [facebook/metro](https://github.com/facebook/metro). (Example entry point file in this PR: `packages/dev-middleware/src/index.js`) Build configuration (i.e. Babel config) is shared as a set standard across the monorepo, and **packages are opted-in to requiring a build**, configured in `scripts/build.config.js`. ``` const buildConfig /*: BuildConfig */ = { // The packages to include for build and their build options packages: { 'dev-middleware': {target: 'node'}, }, }; ``` For now, there is a single `target: 'node'` option — this is necessary as `react-native`, unlike the above other projects, is a repository with packages targeting several runtimes. We may, in future, introduce a build step for other, non-Node, packages — which may be useful for things such as auto-generated TypeScript definitions. {F1043312771} **Differences from the Metro setup** - References (and compiles out) repo-local `scripts/build/babel-register.js` — removing need for an npm-published dependency. ## Current integration points - **CircleCI** — `yarn build` is added to the `build_npm_package` and `find_and_publish_bumped_packages` jobs. **New Node.js package(s) are not load bearing quite yet**: There are not yet any built packages added to the dependencies of `packages/react-native/`, so this will be further tested in a later PR (and is actively being done in an internal commit stack). ### Alternative designs **Per-package config file** Replace `scripts/build/config.js` with a package-defined key in in `package.json`, similar to Jest's [`publishConfig`](https://github.com/jestjs/jest/blob/1f019afdcdfc54a6664908bb45f343db4e3d0848/packages/jest-cli/package.json#L87C3-L89C4). ``` "buildConfig": { "type": "node" }, ``` This would be the only customisation required, with a single Babel config still standardised. Another option this might receive in future is `enableTypeScriptCodgeen`. **Rollup** More sophisticated build tool for Node.js, used by the React codebase (albeit within a custom script setup as well). **Lerna and Nx** - Most sophisticated setup enabling caching and optimised cloud runs. - Probably the most likely thing we'll move towards at a later stage. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D47760330 fbshipit-source-id: 38ec94708ce3d9946a197d80885781e9707c5841
2023-08-03 11:42:30 +00:00
"@pkgjs/parseargs": "^0.11.0",
"@react-native/metro-babel-transformer": "0.77.0-main",
"@react-native/metro-config": "0.77.0-main",
Add auto-generation of TypeScript definitions on build (#38990) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38990 This PR adds auto-generation of Typescript definitions from Flow source code for packages using the shared monorepo build setup (https://github.com/facebook/react-native/pull/38718). Today, these are the following Node.js packages: - `packages/community-cli-plugin` - `packages/dev-middleware` (⬅️ `emitTypeScriptDefs` enabled) This also improves emitted Flow definitions (`.js.flow`), by using [`flow-api-translator`](https://www.npmjs.com/package/flow-api-translator) to strip implementations. **All changes** - Include `flow-api-translator` and configure this to emit type definitions as part of `yarn build`. - Add translation from Flow source to TypeScript definitions (`.d.ts`) adjacent to each built file. - Improve emitted Flow definitions (`.js.flow`), by using `flow-api-translator` to strip implementations (previously, source files were copied). The Flow and TS defs now mirror each other. - Add `emitFlowDefs` and `emitTypeScriptDefs` options to build config to configure the above. - Integrate TypeScript compiler to perform program validation on emitted `.d.ts` files. - This is based on this guide: https://github.com/microsoft/TypeScript-wiki/blob/main/Using-the-Compiler-API.md#a-minimal-compiler. - Throw an exception on the `rewritePackageExports` step if a package does not define an `"exports"` field. - Add minimal `flow-typed` definitions for `typescript` 😄. **Notes on [`flow-api-translator`](https://www.npmjs.com/package/flow-api-translator)** This project is experimental but is in a more mature state than when we evaluated it earlier in 2023. - It's now possible to run this tool on our new Node.js packages, since they are exclusively authored using `import`/`export` syntax (a requirement of the tool). - As a safety net, we run the TypeScript compiler against the generated program, which will fail the build. Changelog: [Internal] Reviewed By: robhogan Differential Revision: D48312463 fbshipit-source-id: 817edb35f911f52fa987946f2d8fc1a319078c9d
2023-08-14 19:12:10 +00:00
"@tsconfig/node18": "1.0.1",
"@types/react": "^18.2.6",
"@typescript-eslint/parser": "^7.1.1",
"ansi-styles": "^4.2.1",
Add shared monorepo build setup (#38718) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38718 > NOTE: Replaces https://github.com/facebook/react-native/pull/38240 ## Context RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641 ## Changes To support incoming new React Native packages around debugging (including migrating over [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro)) — which target Node.js and require a build step, this PR adds a minimal shared build setup across the `react-native` monorepo. The setup is closely inspired/based on the build scripts in Jest, Metro, and React Native CLI — and is a simple set of script wrappers around Babel. These are available as build commands at the root of the repo: - `yarn build` — Builds all configured packages. Functionally, this: - Outputs a `dist/` directory with built files. - Rewrites package.json `"exports"` to update every `./src/*` reference to `./dist/*` (source of truth). - `scripts/build/babel-register.js` — Allows running all Node.js entry points from source, similar to the current setup in [facebook/metro](https://github.com/facebook/metro). (Example entry point file in this PR: `packages/dev-middleware/src/index.js`) Build configuration (i.e. Babel config) is shared as a set standard across the monorepo, and **packages are opted-in to requiring a build**, configured in `scripts/build.config.js`. ``` const buildConfig /*: BuildConfig */ = { // The packages to include for build and their build options packages: { 'dev-middleware': {target: 'node'}, }, }; ``` For now, there is a single `target: 'node'` option — this is necessary as `react-native`, unlike the above other projects, is a repository with packages targeting several runtimes. We may, in future, introduce a build step for other, non-Node, packages — which may be useful for things such as auto-generated TypeScript definitions. {F1043312771} **Differences from the Metro setup** - References (and compiles out) repo-local `scripts/build/babel-register.js` — removing need for an npm-published dependency. ## Current integration points - **CircleCI** — `yarn build` is added to the `build_npm_package` and `find_and_publish_bumped_packages` jobs. **New Node.js package(s) are not load bearing quite yet**: There are not yet any built packages added to the dependencies of `packages/react-native/`, so this will be further tested in a later PR (and is actively being done in an internal commit stack). ### Alternative designs **Per-package config file** Replace `scripts/build/config.js` with a package-defined key in in `package.json`, similar to Jest's [`publishConfig`](https://github.com/jestjs/jest/blob/1f019afdcdfc54a6664908bb45f343db4e3d0848/packages/jest-cli/package.json#L87C3-L89C4). ``` "buildConfig": { "type": "node" }, ``` This would be the only customisation required, with a single Babel config still standardised. Another option this might receive in future is `enableTypeScriptCodgeen`. **Rollup** More sophisticated build tool for Node.js, used by the React codebase (albeit within a custom script setup as well). **Lerna and Nx** - Most sophisticated setup enabling caching and optimised cloud runs. - Probably the most likely thing we'll move towards at a later stage. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D47760330 fbshipit-source-id: 38ec94708ce3d9946a197d80885781e9707c5841
2023-08-03 11:42:30 +00:00
"babel-plugin-minify-dead-code-elimination": "^0.5.2",
"babel-plugin-syntax-hermes-parser": "0.24.0",
update babel and fix tests accordingly (#46295) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46295 X-link: https://github.com/facebook/metro/pull/1343 Updated all **babel** packages in all `package.json` across the repo and ran `npx yarn-deduplicate yarn.lock --scopes babel`. Afterwards, fixed the following issues appearing as a result of that (squashed the following initially separate diffs to make this packages update work atomically): ### (D61336392) updated jest snapshot tests failing ### (D61336393) updated babel types and corrected typings accordingly The latest babel 7 introduces the following features we need to adjust our types to: * `JSXNamespacedName` is removed from valid `CallExpression` args ([PR](https://github.com/babel/babel/pull/16421)) * `JSXNamespacedName` is used for namespaced XML properties in things like `<div namespace:name="value">`, but `fn(namespace:name)` doesn't make any sense. * Dynamic imports are enabled behind a new flag `createImportExpressions` ([PR](https://github.com/babel/babel/pull/15682)), introducing calls such as `import(foo, options)`. These complicate the expected values passed to `import` to be more than just strings. * Since these are behind a flag that is not expected to be enabled, we can throw an error for now and whoever uses it can add a support to it if needed later. ### Added a new metro ENV ignore `BROWSERSLIST_ROOT_PATH` is set to `""` explicitly in `xplat/js/BUCK` and then ignored in `js/tools/metro-buck-transform-worker/src/EnvVarAllowList.js` Reviewed By: robhogan Differential Revision: D61543660 fbshipit-source-id: abbcab72642cf6dc03eed5142eb78dbcc7f63a86
2024-09-05 14:11:17 +00:00
"babel-plugin-transform-define": "^2.1.4",
"babel-plugin-transform-flow-enums": "^0.0.2",
Add shared monorepo build setup (#38718) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38718 > NOTE: Replaces https://github.com/facebook/react-native/pull/38240 ## Context RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641 ## Changes To support incoming new React Native packages around debugging (including migrating over [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro)) — which target Node.js and require a build step, this PR adds a minimal shared build setup across the `react-native` monorepo. The setup is closely inspired/based on the build scripts in Jest, Metro, and React Native CLI — and is a simple set of script wrappers around Babel. These are available as build commands at the root of the repo: - `yarn build` — Builds all configured packages. Functionally, this: - Outputs a `dist/` directory with built files. - Rewrites package.json `"exports"` to update every `./src/*` reference to `./dist/*` (source of truth). - `scripts/build/babel-register.js` — Allows running all Node.js entry points from source, similar to the current setup in [facebook/metro](https://github.com/facebook/metro). (Example entry point file in this PR: `packages/dev-middleware/src/index.js`) Build configuration (i.e. Babel config) is shared as a set standard across the monorepo, and **packages are opted-in to requiring a build**, configured in `scripts/build.config.js`. ``` const buildConfig /*: BuildConfig */ = { // The packages to include for build and their build options packages: { 'dev-middleware': {target: 'node'}, }, }; ``` For now, there is a single `target: 'node'` option — this is necessary as `react-native`, unlike the above other projects, is a repository with packages targeting several runtimes. We may, in future, introduce a build step for other, non-Node, packages — which may be useful for things such as auto-generated TypeScript definitions. {F1043312771} **Differences from the Metro setup** - References (and compiles out) repo-local `scripts/build/babel-register.js` — removing need for an npm-published dependency. ## Current integration points - **CircleCI** — `yarn build` is added to the `build_npm_package` and `find_and_publish_bumped_packages` jobs. **New Node.js package(s) are not load bearing quite yet**: There are not yet any built packages added to the dependencies of `packages/react-native/`, so this will be further tested in a later PR (and is actively being done in an internal commit stack). ### Alternative designs **Per-package config file** Replace `scripts/build/config.js` with a package-defined key in in `package.json`, similar to Jest's [`publishConfig`](https://github.com/jestjs/jest/blob/1f019afdcdfc54a6664908bb45f343db4e3d0848/packages/jest-cli/package.json#L87C3-L89C4). ``` "buildConfig": { "type": "node" }, ``` This would be the only customisation required, with a single Babel config still standardised. Another option this might receive in future is `enableTypeScriptCodgeen`. **Rollup** More sophisticated build tool for Node.js, used by the React codebase (albeit within a custom script setup as well). **Lerna and Nx** - Most sophisticated setup enabling caching and optimised cloud runs. - Probably the most likely thing we'll move towards at a later stage. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D47760330 fbshipit-source-id: 38ec94708ce3d9946a197d80885781e9707c5841
2023-08-03 11:42:30 +00:00
"chalk": "^4.0.0",
"clang-format": "^1.8.0",
"connect": "^3.6.5",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-ft-flow": "^2.0.1",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-lint": "^1.0.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-native": "^4.0.0",
"eslint-plugin-redundant-undefined": "^0.4.0",
"eslint-plugin-relay": "^1.8.3",
"flow-api-translator": "0.24.0",
"flow-bin": "^0.253.0",
Add shared monorepo build setup (#38718) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38718 > NOTE: Replaces https://github.com/facebook/react-native/pull/38240 ## Context RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641 ## Changes To support incoming new React Native packages around debugging (including migrating over [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro)) — which target Node.js and require a build step, this PR adds a minimal shared build setup across the `react-native` monorepo. The setup is closely inspired/based on the build scripts in Jest, Metro, and React Native CLI — and is a simple set of script wrappers around Babel. These are available as build commands at the root of the repo: - `yarn build` — Builds all configured packages. Functionally, this: - Outputs a `dist/` directory with built files. - Rewrites package.json `"exports"` to update every `./src/*` reference to `./dist/*` (source of truth). - `scripts/build/babel-register.js` — Allows running all Node.js entry points from source, similar to the current setup in [facebook/metro](https://github.com/facebook/metro). (Example entry point file in this PR: `packages/dev-middleware/src/index.js`) Build configuration (i.e. Babel config) is shared as a set standard across the monorepo, and **packages are opted-in to requiring a build**, configured in `scripts/build.config.js`. ``` const buildConfig /*: BuildConfig */ = { // The packages to include for build and their build options packages: { 'dev-middleware': {target: 'node'}, }, }; ``` For now, there is a single `target: 'node'` option — this is necessary as `react-native`, unlike the above other projects, is a repository with packages targeting several runtimes. We may, in future, introduce a build step for other, non-Node, packages — which may be useful for things such as auto-generated TypeScript definitions. {F1043312771} **Differences from the Metro setup** - References (and compiles out) repo-local `scripts/build/babel-register.js` — removing need for an npm-published dependency. ## Current integration points - **CircleCI** — `yarn build` is added to the `build_npm_package` and `find_and_publish_bumped_packages` jobs. **New Node.js package(s) are not load bearing quite yet**: There are not yet any built packages added to the dependencies of `packages/react-native/`, so this will be further tested in a later PR (and is actively being done in an internal commit stack). ### Alternative designs **Per-package config file** Replace `scripts/build/config.js` with a package-defined key in in `package.json`, similar to Jest's [`publishConfig`](https://github.com/jestjs/jest/blob/1f019afdcdfc54a6664908bb45f343db4e3d0848/packages/jest-cli/package.json#L87C3-L89C4). ``` "buildConfig": { "type": "node" }, ``` This would be the only customisation required, with a single Babel config still standardised. Another option this might receive in future is `enableTypeScriptCodgeen`. **Rollup** More sophisticated build tool for Node.js, used by the React codebase (albeit within a custom script setup as well). **Lerna and Nx** - Most sophisticated setup enabling caching and optimised cloud runs. - Probably the most likely thing we'll move towards at a later stage. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D47760330 fbshipit-source-id: 38ec94708ce3d9946a197d80885781e9707c5841
2023-08-03 11:42:30 +00:00
"glob": "^7.1.1",
"hermes-eslint": "0.24.0",
"hermes-transform": "0.24.0",
"inquirer": "^7.1.0",
"jest": "^29.6.3",
"jest-junit": "^10.0.0",
"jscodeshift": "^0.14.0",
"metro-babel-register": "^0.81.0",
"metro-memory-fs": "^0.81.0",
"metro-transform-plugins": "^0.81.0",
Add shared monorepo build setup (#38718) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38718 > NOTE: Replaces https://github.com/facebook/react-native/pull/38240 ## Context RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641 ## Changes To support incoming new React Native packages around debugging (including migrating over [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro)) — which target Node.js and require a build step, this PR adds a minimal shared build setup across the `react-native` monorepo. The setup is closely inspired/based on the build scripts in Jest, Metro, and React Native CLI — and is a simple set of script wrappers around Babel. These are available as build commands at the root of the repo: - `yarn build` — Builds all configured packages. Functionally, this: - Outputs a `dist/` directory with built files. - Rewrites package.json `"exports"` to update every `./src/*` reference to `./dist/*` (source of truth). - `scripts/build/babel-register.js` — Allows running all Node.js entry points from source, similar to the current setup in [facebook/metro](https://github.com/facebook/metro). (Example entry point file in this PR: `packages/dev-middleware/src/index.js`) Build configuration (i.e. Babel config) is shared as a set standard across the monorepo, and **packages are opted-in to requiring a build**, configured in `scripts/build.config.js`. ``` const buildConfig /*: BuildConfig */ = { // The packages to include for build and their build options packages: { 'dev-middleware': {target: 'node'}, }, }; ``` For now, there is a single `target: 'node'` option — this is necessary as `react-native`, unlike the above other projects, is a repository with packages targeting several runtimes. We may, in future, introduce a build step for other, non-Node, packages — which may be useful for things such as auto-generated TypeScript definitions. {F1043312771} **Differences from the Metro setup** - References (and compiles out) repo-local `scripts/build/babel-register.js` — removing need for an npm-published dependency. ## Current integration points - **CircleCI** — `yarn build` is added to the `build_npm_package` and `find_and_publish_bumped_packages` jobs. **New Node.js package(s) are not load bearing quite yet**: There are not yet any built packages added to the dependencies of `packages/react-native/`, so this will be further tested in a later PR (and is actively being done in an internal commit stack). ### Alternative designs **Per-package config file** Replace `scripts/build/config.js` with a package-defined key in in `package.json`, similar to Jest's [`publishConfig`](https://github.com/jestjs/jest/blob/1f019afdcdfc54a6664908bb45f343db4e3d0848/packages/jest-cli/package.json#L87C3-L89C4). ``` "buildConfig": { "type": "node" }, ``` This would be the only customisation required, with a single Babel config still standardised. Another option this might receive in future is `enableTypeScriptCodgeen`. **Rollup** More sophisticated build tool for Node.js, used by the React codebase (albeit within a custom script setup as well). **Lerna and Nx** - Most sophisticated setup enabling caching and optimised cloud runs. - Probably the most likely thing we'll move towards at a later stage. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D47760330 fbshipit-source-id: 38ec94708ce3d9946a197d80885781e9707c5841
2023-08-03 11:42:30 +00:00
"micromatch": "^4.0.4",
"node-fetch": "^2.2.0",
"nullthrows": "^1.1.1",
"prettier": "2.8.8",
"prettier-plugin-hermes-parser": "0.24.0",
"react": "18.3.1",
"react-test-renderer": "18.3.1",
"rimraf": "^3.0.2",
"shelljs": "^0.8.5",
"signedsource": "^1.0.0",
"supports-color": "^7.1.0",
"typescript": "5.0.4",
"ws": "^6.2.3"
},
"resolutions": {
"react-is": "18.3.1"
}
}