Skip to content

Commit

Permalink
Use codegen from source in default iOS template apps
Browse files Browse the repository at this point in the history
Summary:
Add the `react-native-codegen` source to the `react-native` npm package.
Instead of using `react-native-codegen` from npm, the iOS app template will now build the package from source. Doing so removes the need to carefully time `react-native-codegen` npm releases to oss `react-native` releases, as the codegen and the oss release will be cut at the same time.

Changelog: [Internal] - Removed react-native-codegen dependency from iOS app template

Reviewed By: TheSavior

Differential Revision: D24904655

fbshipit-source-id: a07932bc748e2afb9359de584181bcb9dd0810ea
  • Loading branch information
fkgozali authored and facebook-github-bot committed Nov 13, 2020
1 parent 6a039d7 commit 58c80d4
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"Libraries",
"LICENSE",
"local-cli",
"packages/react-native-codegen",
"React-Core.podspec",
"react-native.config.js",
"react.gradle",
Expand Down
4 changes: 1 addition & 3 deletions packages/rn-tester/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ pre_install do |installer|
frameworks_pre_install(installer) if ENV['USE_FRAMEWORKS'] == '1'
if ENV['USE_CODEGEN'] != '0'
prefix_path = "../.."
codegen_path = "../../packages/react-native-codegen"
system("(cd #{codegen_path} && yarn install && yarn run build)")
codegen_pre_install(installer, {path:prefix_path, codegen_path:codegen_path})
codegen_pre_install(installer, {path:prefix_path})
end
end

Expand Down
2 changes: 1 addition & 1 deletion packages/rn-tester/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,6 @@ SPEC CHECKSUMS:
Yoga: 69ef0b2bba5387523f793957a9f80dbd61e89631
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: 497dba59a3312b3cb22d518b96672409db90460d
PODFILE CHECKSUM: 961e081223f82b7e9208869de4d73534d949ae9e

COCOAPODS: 1.10.0
2 changes: 1 addition & 1 deletion scripts/generate-native-modules-specs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RN_DIR=$(cd "$THIS_DIR/.." && pwd)
CODEGEN_DIR=$(cd "$RN_DIR/packages/react-native-codegen" && pwd)
OUTPUT_DIR="${1:-$RN_DIR/Libraries/FBReactNativeSpec/FBReactNativeSpec}"
SCHEMA_FILE="$RN_DIR/schema-native-modules.json"
YARN_BINARY="${YARN_BINARY:-yarn}"
YARN_BINARY="${YARN_BINARY:-$(command -v yarn)}"

describe () {
printf "\\n\\n>>>>> %s\\n\\n\\n" "$1"
Expand Down
4 changes: 2 additions & 2 deletions scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ def flipper_post_install(installer)
# Pre Install processing for Native Modules
def codegen_pre_install(installer, options={})
prefix = options[:path] ||= "../node_modules/react-native"
codegen_path = options[:codegen_path] ||= "../node_modules/react-native-codegen"
system("./#{prefix}/packages/react-native-codegen/scripts/oss/build.sh")

Dir.mktmpdir do |dir|
native_module_spec_name = "FBReactNativeSpec"
schema_file = dir + "/schema-#{native_module_spec_name}.json"
srcs_dir = "#{prefix}/Libraries"
schema_generated = system("node #{codegen_path}/lib/cli/combine/combine-js-to-schema-cli.js #{schema_file} #{srcs_dir}")
schema_generated = system("node #{prefix}/packages/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js #{schema_file} #{srcs_dir}")
specs_generated = system("node #{prefix}/scripts/generate-native-modules-specs-cli.js ios #{schema_file} #{srcs_dir}/#{native_module_spec_name}/#{native_module_spec_name}")
end
end
3 changes: 1 addition & 2 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"eslint": "7.12.0",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.64.0",
"react-test-renderer": "17.0.1",
"react-native-codegen": "0.0.4"
"react-test-renderer": "17.0.1"
},
"jest": {
"preset": "react-native"
Expand Down

0 comments on commit 58c80d4

Please sign in to comment.