Skip to content

Commit 9d3d5e1

Browse files
javachefacebook-github-bot
authored andcommitted
Switch buck schema codegen to yarn_workspace_binary (facebook#33773)
Summary: Pull Request resolved: facebook#33773 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: d16r Differential Revision: D36164350 fbshipit-source-id: 5290587010fe6021b758bda98bf01995fdf14acd
1 parent 1e0226f commit 9d3d5e1

File tree

3 files changed

+23
-34
lines changed

3 files changed

+23
-34
lines changed

packages/react-native-codegen/DEFS.bzl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,21 @@ load(
2828
"rn_apple_library",
2929
"rn_xplat_cxx_library",
3030
)
31+
load("//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace_binary")
3132

3233
# Call this in the react-native-codegen/BUCK file
3334
def rn_codegen_cli():
3435
if not IS_OSS_BUILD:
3536
# FB Internal Setup
36-
fb_native.sh_binary(
37+
yarn_workspace_binary(
3738
name = "write_to_json",
38-
main = "src/cli/combine/combine_js_to_schema.sh",
39-
resources = [
40-
"src/cli/combine/combine-js-to-schema.js",
41-
"src/cli/combine/combine_js_to_schema.sh",
39+
main = "src/cli/combine/combine-js-to-schema-cli.js",
40+
root = "//xplat/js:workspace",
41+
deps = [
4242
":yarn-workspace",
43-
"//xplat/js:setup_env",
44-
"//xplat/js:setup_env_vars",
4543
],
4644
visibility = ["PUBLIC"],
4745
)
48-
4946
fb_native.sh_binary(
5047
name = "generate_all_from_schema",
5148
main = "src/cli/generators/generate-all.sh",

packages/react-native-codegen/src/cli/combine/combine_js_to_schema.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

tools/build_defs/third_party/yarn_defs.bzl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,21 @@ def yarn_workspace(name, srcs = [], transform_ignore = None, visibility = None):
1111
out = "{}.txt".format(name),
1212
visibility = visibility,
1313
)
14+
15+
def yarn_workspace_binary(
16+
name,
17+
main,
18+
deps = None,
19+
root = None,
20+
reuse = None,
21+
args = None,
22+
env = None,
23+
node_args = None,
24+
visibility = None):
25+
# Noop for OSS vs FB build compatibility for now
26+
native.genrule(
27+
name = name,
28+
cmd = "echo {} > $OUT".format(name),
29+
out = "{}.txt".format(name),
30+
visibility = visibility,
31+
)

0 commit comments

Comments
 (0)