From dbe6fab06343281e4d96c073bf1a69f73024b810 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Wed, 15 Jun 2022 13:12:14 -0700 Subject: [PATCH] Switch module codegen to use yarn_workspace_binary. (#34015) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/34015 I noticed this was a very slow part of my build because each instance of the binary would run its own yarn install. Instead use the yarn_workspace approach to share a single yarn setup. Changelog: [Internal] Reviewed By: IanChilds Differential Revision: D37178005 fbshipit-source-id: cba51e168c5a2f2ee6468acb8c144db4ad352d95 --- packages/react-native-codegen/DEFS.bzl | 15 +++++---------- .../src/cli/generators/generate-all.sh | 19 ------------------- 2 files changed, 5 insertions(+), 29 deletions(-) delete mode 100755 packages/react-native-codegen/src/cli/generators/generate-all.sh diff --git a/packages/react-native-codegen/DEFS.bzl b/packages/react-native-codegen/DEFS.bzl index 38c34bc9943..2e32ac7adfa 100644 --- a/packages/react-native-codegen/DEFS.bzl +++ b/packages/react-native-codegen/DEFS.bzl @@ -43,17 +43,12 @@ def rn_codegen_cli(): ], visibility = ["PUBLIC"], ) - fb_native.sh_binary( + yarn_workspace_binary( name = "generate_all_from_schema", - main = "src/cli/generators/generate-all.sh", - resources = native.glob( - [ - "buck_tests/**/*.js", - "src/**/*.js", - ], - ) + [ - "package.json", - "//xplat/js:setup_env", + main = "src/cli/generators/generate-all.js", + root = "//xplat/js:workspace", + deps = [ + ":yarn-workspace", ], visibility = ["PUBLIC"], ) diff --git a/packages/react-native-codegen/src/cli/generators/generate-all.sh b/packages/react-native-codegen/src/cli/generators/generate-all.sh deleted file mode 100755 index cf5e3f9276f..00000000000 --- a/packages/react-native-codegen/src/cli/generators/generate-all.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -set -e -set -u - -THIS_DIR=$(cd -P "$(dirname "$(realpath "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) - -# shellcheck source=xplat/js/env-utils/setup_env_vars.sh -source "$THIS_DIR/../../../../../../env-utils/setup_env_vars.sh" - -pushd "$JS_DIR" >/dev/null - "$INSTALL_NODE_MODULES" -popd >/dev/null - -exec "$FLOW_NODE_BINARY" "$THIS_DIR/generate-all.js" "$@"