Skip to content
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

chore: move to monorepo with bun #4255

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

KrzysztofMoch
Copy link
Member

Summary

I have replaced yarn with bun as it is much faster.
Also changed our repo structure to mono repo so we have now:
-> docs
-> examples
| -> bare
| -> expo
-> packages
| -> react-native-video (library code)
| -> react-native-video-plugin-sample

Motivation

Speed up "node_modules" installation and allow for installing react-native-video as dependency in examples with simplify configuration.

Changes

  • Expo example now does not have included android & ios folder - they should be created each time via prebuild
  • replaced yarn with bun

Test plan

  • CI should work

@KrzysztofMoch
Copy link
Member Author

@freeboub this PR will create conflicts in all PRs, so I would like to merge as many PRs as possible before this one

@KrzysztofMoch
Copy link
Member Author

Also builds are faster by 1.5 minute and node_modules for all projects are installing in ~8 sec

@freeboub
Copy link
Collaborator

finally a clean repo 🙏 Thank you !

@freeboub
Copy link
Collaborator

freeboub commented Nov 5, 2024

@KrzysztofMoch I would be happy if this PR is merged soon!
I don't want to start any dev or fixes to avoid conflict :)
Thank you

@KrzysztofMoch
Copy link
Member Author

@freeboub I fine to merge it - other PRs will need to rebase but I guess this is probably inevitable

@freeboub
Copy link
Collaborator

freeboub commented Nov 9, 2024

@KrzysztofMoch I am not able to build samples with this PR ...

on bare sample:
olivier@OrdinateOlivier bare % bun run android
$ react-native run-android
(node:17082) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
(Use node --trace-deprecation ... to show where the warning was created)
info Installing the app...

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor

FAILURE: Build failed with an exception.

  • Where:
    Script '/Users/olivier/openSource/react-native-video/examples/bare/node_modules/react-native-test-app/android/config-plugins.gradle' line: 17

  • What went wrong:
    A problem occurred evaluating script.

Failed to apply config plugins:
node:internal/process/promises:394
triggerUncaughtException(err, true /* fromPromise */);
^

SyntaxError: Unexpected token 'typeof'
at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:310:18)
at loadESMFromCJS (node:internal/modules/cjs/loader:1381:24)
at Module._compile (node:internal/modules/cjs/loader:1503:5)
at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
at Module.load (node:internal/modules/cjs/loader:1317:32)
at Module._load (node:internal/modules/cjs/loader:1127:12)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Module.require (node:internal/modules/cjs/loader:1339:12) {
name: 'PluginError',
isPluginError: true,
code: 'INVALID_PLUGIN_IMPORT',
cause: undefined
}

Node.js v22.9.0

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.

BUILD FAILED in 466ms
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * Where:
Script '/Users/olivier/openSource/react-native-video/examples/bare/node_modules/react-native-test-app/android/config-plugins.gradle' line: 17 * What went wrong:
A problem occurred evaluating script.

Failed to apply config plugins: node:internal/process/promises:394 triggerUncaughtException(err, true /* fromPromise */); ^ SyntaxError: Unexpected token 'typeof' at compileSourceTextModule (node:internal/modules/esm/utils:337:16) at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:310:18) at loadESMFromCJS (node:internal/modules/cjs/loader:1381:24) at Module._compile (node:internal/modules/cjs/loader:1503:5) at Module._extensions..js (node:internal/modules/cjs/loader:1691:10) at Module.load (node:internal/modules/cjs/loader:1317:32) at Module._load (node:internal/modules/cjs/loader:1127:12) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:217:24) at Module.require (node:internal/modules/cjs/loader:1339:12) { name: 'PluginError', isPluginError: true, code: 'INVALID_PLUGIN_IMPORT', cause: undefined } Node.js v22.9.0 * Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org. BUILD FAILED in 466ms.
info Run CLI with --verbose flag for more details.
error: script "android" exited with code 1

I also think you should move react-native-video-plugin-sample to exemple folder as it is not made to be released.

Thank you

@freeboub
Copy link
Collaborator

freeboub commented Nov 9, 2024

pod install is also failing on ios:
olivier@OrdinateOlivier bare % pod install --project-directory=ios
Framework build type is static library
[Codegen] Generating ios/build/generated/ios/React-Codegen.podspec.json
(node:19807) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
(Use node --trace-deprecation ... to show where the warning was created)
Auto-linking React Native modules for target ReactTestApp: RNCPicker and ReactTestApp-DevSupport
Analyzing dependencies
Fetching podspec for DoubleConversion from ../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec
[Codegen] Found FBReactNativeSpec
Fetching podspec for RCT-Folly from ../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec
[Codegen] Found rncore
Fetching podspec for boost from ../node_modules/react-native/third-party-podspecs/boost.podspec
Fetching podspec for glog from ../node_modules/react-native/third-party-podspecs/glog.podspec
Downloading dependencies
Removing react-native-video
Generating Pods project
Setting USE_HERMES build settings
Setting REACT_NATIVE build settings
Setting CLANG_CXX_LANGUAGE_STANDARD to c++20 on /Users/olivier/openSource/react-native-video/examples/bare/node_modules/.generated/ios/ReactTestApp.xcodeproj
Pod install took 9 [s] to run
node:internal/process/promises:394
triggerUncaughtException(err, true /* fromPromise */);
^

SyntaxError: Unexpected token 'typeof'
at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:310:18)
at loadESMFromCJS (node:internal/modules/cjs/loader:1381:24)
at Module._compile (node:internal/modules/cjs/loader:1503:5)
at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
at Module.load (node:internal/modules/cjs/loader:1317:32)
at Module._load (node:internal/modules/cjs/loader:1127:12)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Module.require (node:internal/modules/cjs/loader:1339:12) {
name: 'PluginError',
isPluginError: true,
code: 'INVALID_PLUGIN_IMPORT',
cause: undefined
}

Node.js v22.9.0
[!] An error occurred while processing the post-install hook of the Podfile.

Failed to apply config plugins

/Users/olivier/openSource/react-native-video/examples/bare/node_modules/react-native-test-app/ios/test_app.rb:29:in apply_config_plugins' /Users/olivier/openSource/react-native-video/examples/bare/node_modules/react-native-test-app/ios/test_app.rb:447:in block in use_test_app_internal!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/podfile.rb:196:in post_install!' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:1013:in run_podfile_post_install_hook'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:1001:in block in run_podfile_post_install_hooks' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:149:in message'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:1000:in run_podfile_post_install_hooks' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:337:in block (2 levels) in create_and_save_projects'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:61:in write!' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:336:in block in create_and_save_projects'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in section' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:315:in create_and_save_projects'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:307:in generate_pods_project' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:183:in integrate'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:170:in install!' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/command/install.rb:52:in run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:334:in run' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/command.rb:52:in run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/bin/pod:55:in <top (required)>' /usr/local/bin/pod:23:in load'
/usr/local/bin/pod:23:in `

'

[!] CocoaPods will not include resources it cannot find:
dist/assets
dist/main.ios.jsbundle

The app will still build and run if they are served by the dev server. To include missing resources, make sure they exist, then run pod install again to update the workspace.

@KrzysztofMoch
Copy link
Member Author

I have bumped react-native version in bare example, I have tested it and now I am able to build and run android

my versions

  • node: 18.20.0
  • bun: 1.1.33

@KrzysztofMoch
Copy link
Member Author

@freeboub it took a while but it's should be good now

@freeboub
Copy link
Collaborator

@KrzysztofMoch sorry for the testing delays, but it is still not working on my side...

I started from my existing repo , can it be the issue ?

on bare project:
olivier@OrdinateOlivier bare % bun android
$ react-native run-android
(node:15937) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
(Use node --trace-deprecation ... to show where the warning was created)
info A dev server is already running for this project on port 8081.
info Installing the app...

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor

FAILURE: Build failed with an exception.

  • Where:
    Script '/Users/olivier/openSource/react-native-video/examples/bare/node_modules/react-native-test-app/android/config-plugins.gradle' line: 17

  • What went wrong:
    A problem occurred evaluating script.

Failed to apply config plugins:
(node:15951) ExperimentalWarning: CommonJS module /Users/olivier/openSource/react-native-video/lib/Video.js is loading ES Module /Users/olivier/openSource/react-native-video/node_modules/react-native/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)
node:internal/process/promises:394
triggerUncaughtException(err, true /* fromPromise */);
^

SyntaxError: Unexpected token 'typeof'
at compileSourceTextModule (node:internal/modules/esm/utils:338:16)
at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:318:18)
at loadESMFromCJS (node:internal/modules/cjs/loader:1396:24)
at Module._compile (node:internal/modules/cjs/loader:1529:5)
at Object..js (node:internal/modules/cjs/loader:1709:10)
at Module.load (node:internal/modules/cjs/loader:1315:32)
at Function._load (node:internal/modules/cjs/loader:1125:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:216:24)
at Module.require (node:internal/modules/cjs/loader:1337:12) {
name: 'PluginError',
isPluginError: true,
code: 'INVALID_PLUGIN_IMPORT',
cause: undefined
}

Node.js v23.1.0

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.

BUILD FAILED in 438ms
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * Where:
Script '/Users/olivier/openSource/react-native-video/examples/bare/node_modules/react-native-test-app/android/config-plugins.gradle' line: 17 * What went wrong:
A problem occurred evaluating script.

Failed to apply config plugins: (node:15951) ExperimentalWarning: CommonJS module /Users/olivier/openSource/react-native-video/lib/Video.js is loading ES Module /Users/olivier/openSource/react-native-video/node_modules/react-native/index.js using require(). Support for loading ES Module in require() is an experimental feature and might change at any time (Use node --trace-warnings ... to show where the warning was created) node:internal/process/promises:394 triggerUncaughtException(err, true /* fromPromise */); ^ SyntaxError: Unexpected token 'typeof' at compileSourceTextModule (node:internal/modules/esm/utils:338:16) at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:318:18) at loadESMFromCJS (node:internal/modules/cjs/loader:1396:24) at Module._compile (node:internal/modules/cjs/loader:1529:5) at Object..js (node:internal/modules/cjs/loader:1709:10) at Module.load (node:internal/modules/cjs/loader:1315:32) at Function._load (node:internal/modules/cjs/loader:1125:12) at TracingChannel.traceSync (node:diagnostics_channel:322:14) at wrapModuleLoad (node:internal/modules/cjs/loader:216:24) at Module.require (node:internal/modules/cjs/loader:1337:12) { name: 'PluginError', isPluginError: true, code: 'INVALID_PLUGIN_IMPORT', cause: undefined } Node.js v23.1.0 * Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org. BUILD FAILED in 438ms.
info Run CLI with --verbose flag for more details.
error: script "android" exited with code 1

in expo project:
olivier@OrdinateOlivier expo % bun run android
$ EXPO_TV=0 expo run:android
› Building app...
Configuration on demand is an incubating feature.

FAILURE: Build failed with an exception.

  • What went wrong:
    Included build /Users/olivier/openSource/react-native-video/examples/expo/node_modules/react-native/node_modules/@react-native/gradle-plugin has build path :gradle-plugin which is the same as included build /Users/olivier/openSource/react-native-video/node_modules/@react-native/gradle-plugin

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.

BUILD FAILED in 1s
8 actionable tasks: 2 executed, 6 up-to-date
Error: /Users/olivier/openSource/react-native-video/examples/expo/android/gradlew app:assembleDebug -x lint -x test --configure-on-demand --build-cache -PreactNativeDevServerPort=8081 -PreactNativeArchitectures=arm64-v8a exited with non-zero code: 1
Error: /Users/olivier/openSource/react-native-video/examples/expo/android/gradlew app:assembleDebug -x lint -x test --configure-on-demand --build-cache -PreactNativeDevServerPort=8081 -PreactNativeArchitectures=arm64-v8a exited with non-zero code: 1
at ChildProcess.completionListener (/Users/olivier/openSource/react-native-video/node_modules/@expo/spawn-async/src/spawnAsync.ts:67:13)
at Object.onceWrapper (node:events:622:26)
at ChildProcess.emit (node:events:507:28)
at maybeClose (node:internal/child_process:1101:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:305:5)
...
at spawnAsync (/Users/olivier/openSource/react-native-video/node_modules/@expo/spawn-async/src/spawnAsync.ts:28:21)
at spawnGradleAsync (/Users/olivier/openSource/react-native-video/node_modules/@expo/cli/src/start/platforms/android/gradle.ts:134:28)
at assembleAsync (/Users/olivier/openSource/react-native-video/node_modules/@expo/cli/src/start/platforms/android/gradle.ts:83:16)
at runAndroidAsync (/Users/olivier/openSource/react-native-video/node_modules/@expo/cli/src/run/android/runAndroidAsync.ts:48:24)
error: script "android" exited with code 1

@KrzysztofMoch
Copy link
Member Author

KrzysztofMoch commented Dec 1, 2024

Hmm... We have my favourite situation "it's working on my machine" 🥲
Let me look at it
Also I will clean all CI cache and see if it will build - this will allow to test it on other pc as well...
Also bun sometime has problem with lock file, removing it and runing bun install again can help sometimes

@freeboub
Copy link
Collaborator

freeboub commented Dec 1, 2024

Hmm... We have my favourite situation "it's working on my machine" 🥲
Let me look at it
Also I will clean all CI cache and see if it will build - this will allow to test it on other pc as well...
Also bun sometime has problem with lock file, removing it and runing bun install again can help sometimes

It was expecting this answer 😂 I will try a clean clone to check if it fixes the issue... Maybe a node version issue ? I don't know ...

@freeboub
Copy link
Collaborator

freeboub commented Dec 1, 2024

Hmm... We have my favourite situation "it's working on my machine" 🥲
Let me look at it
Also I will clean all CI cache and see if it will build - this will allow to test it on other pc as well...
Also bun sometime has problem with lock file, removing it and runing bun install again can help sometimes

And we will not ship your computer to customers 😁

@KrzysztofMoch
Copy link
Member Author

What version of bun do you have installed ?

@freeboub
Copy link
Collaborator

freeboub commented Dec 5, 2024

@KrzysztofMoch Still not, but great progress !

I think you just miss to add the splash screen file (expo exemple)

Execution failed for task ':app:processDebugResources'.

A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
Android resource linking failed
com.anonymous.ExpoExample.app-mergeDebugResources-39:/values/values.xml:2362: error: resource drawable/splashscreen_logo (aka com.anonymous.ExpoExample:drawable/splashscreen_logo) not found.
com.anonymous.ExpoExample.app-mergeDebugResources-39:/values/values.xml:2362: error: resource drawable/splashscreen_logo (aka com.anonymous.ExpoExample:drawable/splashscreen_logo) not found.
error: failed linking references.

@KrzysztofMoch
Copy link
Member Author

oh, i think i forgot to commit new prebuild, can you copy settings.gradle and make new prebuild ?

@KrzysztofMoch
Copy link
Member Author

@freeboub - I have fixed issue with missing splash screen and not loading app (in expo), if this won't work I give up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants