react-native 将pretty-format升级到29

3lxsmp7m  于 9个月前  发布在  React
关注(0)|答案(2)|浏览(102)

描述

由于某种原因,在我们的项目中,运行时react-native代码使用了pretty-format v29,而代码期望的是v26。一位同事通过使用下面的补丁解决了这个问题,但在我们的项目中,将package.json指定为版本26也起到了作用。
在我们的项目中,我发现Jest使用了pretty-format v29,这无疑与此有关。我没有调查根本原因,而是认为升级pretty-format会更有利。因此,我为此问题提交了这个issue;参见this PR

  1. diff --git a/node_modules/react-native/Libraries/Utilities/HMRClient.js b/node_modules/react-native/Libraries/Utilities/HMRClient.js
  2. index 03ae287..7f3fd21 100644
  3. --- a/node_modules/react-native/Libraries/Utilities/HMRClient.js
  4. +++ b/node_modules/react-native/Libraries/Utilities/HMRClient.js
  5. @@ -124,7 +124,13 @@ const HMRClient: HMRClientNativeInterface = {
  6. data: data.map(item =>
  7. typeof item === 'string'
  8. ? item
  9. - : prettyFormat(item, {
  10. + /*
  11. + https://jira.ops.expertcity.com/browse/GTCMOB-5830
  12. + fix for console.log that stopped working after RN 71
  13. + the require for prettyFormat is importing the wrong version (high major version which has the breaking change)
  14. + in this package it should be ^26 but it is pulling ^29
  15. + */
  16. + : prettyFormat.format(item, {
  17. escapeString: true,
  18. highlight: true,
  19. maxDepth: 3,

重现步骤

执行一个类似于console.log('index.native.js', { myObject: 'myvalue' });的操作,没有任何输出
执行console.log('index.native.js')操作,有输出

React Native版本

0.73.9

受影响的平台

运行时 - Android,运行时 - iOS

npx react-native info的输出

  1. WARNING: You should run npx react-native@latest to ensure you're always using the most current version of the CLI. NPX has cached version (0.73.9) != current release (0.74.3)
  2. info Fetching system and libraries information...
  3. System:
  4. OS: macOS 14.5
  5. CPU: (12) arm64 Apple M2 Pro
  6. Memory: 4.53 GB / 32.00 GB
  7. Shell:
  8. version: "5.9"
  9. path: /bin/zsh
  10. Binaries:
  11. Node:
  12. version: 18.19.1
  13. path: ~/.nvm/versions/node/v18.19.1/bin/node
  14. Yarn:
  15. version: 1.22.21
  16. path: /opt/homebrew/bin/yarn
  17. npm:
  18. version: 10.2.4
  19. path: ~/.nvm/versions/node/v18.19.1/bin/npm
  20. Watchman:
  21. version: 2024.01.22.00
  22. path: /opt/homebrew/bin/watchman
  23. Managers:
  24. CocoaPods:
  25. version: 1.15.2
  26. path: /Users/dprevost/.rbenv/shims/pod
  27. SDKs:
  28. iOS SDK:
  29. Platforms:
  30. - DriverKit 23.0
  31. - iOS 17.0
  32. - macOS 14.0
  33. - tvOS 17.0
  34. - watchOS 10.0
  35. Android SDK: Not Found
  36. IDEs:
  37. Android Studio: 2024.1 AI-241.18034.62.2411.12071903
  38. Xcode:
  39. version: 15.0.1/15A507
  40. path: /usr/bin/xcodebuild
  41. Languages:
  42. Java:
  43. version: 17.0.8
  44. path: /usr/bin/javac
  45. Ruby:
  46. version: 2.6.10
  47. path: /Users/dprevost/.rbenv/shims/ruby
  48. npmPackages:
  49. "@react-native-community/cli": Not Found
  50. react: Not Found
  51. react-native:
  52. installed: 0.73.9
  53. wanted: 0.73.9
  54. react-native-macos: Not Found
  55. npmGlobalPackages:
  56. "*react-native*": Not Found
  57. Android:
  58. hermesEnabled: Not found
  59. newArchEnabled: Not found
  60. iOS:
  61. hermesEnabled: true
  62. newArchEnabled: false

堆栈跟踪或日志

  1. None

可复现问题

https://github.com/facebook/react-native/pull/45732/files

截图和视频

  • 无响应*
cuxqih21

cuxqih211#

⚠️缺失可复现示例
i️我们无法在您的问题报告中检测到可复现的示例。请提供以下内容:* 如果您的错误与UI相关:一个 Snack* 如果您的错误与构建/更新相关:使用我们的 Reproducer Template 。需要在您用户名下的GitHub仓库中有一个复现器。
nnvyjq4y

nnvyjq4y2#

⚠️缺失可复现示例
i️我们无法在您的问题报告中检测到可复现的示例。请提供以下内容:* 如果您的错误与UI相关:一个 Snack* 如果您的错误与构建/更新相关:使用我们的 Reproducer Template

相关问题