react-native: [0.57.0-rc.0] react-native-git-upgrade and old school upgrade are broken

Environment

  React Native Environment Info:
    System:
      OS: Windows 10
      CPU: x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
      Memory: 8.52 GB / 15.95 GB
    Binaries:
      Yarn: 1.9.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.4.0 - C:\Program Files\nodejs\npm.CMD

I’m upgrading from React Native 0.56.0.

Description

PS C:\Users\Gary\Documents\code\WonderSwipe> react-native-git-upgrade.cmd 0.57.0-rc.0
git-upgrade info Check for updates
git-upgrade info Using yarn 1.9.4
git-upgrade info Read package.json files
git-upgrade info Check declared version
git-upgrade info Check matching versions
git-upgrade info Check React peer dependency
git-upgrade info Check that Git is installed
git-upgrade info Get information from NPM registry
git-upgrade info Upgrading to React Native 0.57.0-rc.0, React 16.4.1
git-upgrade info Setup temporary working directory
git-upgrade info Configure Git environment
git-upgrade info Init Git repository
git-upgrade info Add all files to commit
git-upgrade info Commit current project sources
git-upgrade info Create a tag before updating sources
git-upgrade info Generate old version template
git-upgrade ERR! An error occurred during upgrade:
git-upgrade ERR! Error: Plugin 0 specified in "C:\\Users\\Gary\\Documents\\code\\WonderSwipe\\node_modules\\babel-preset-react-native\\index.js" provided an invalid property of "default" (While processing preset: "C:\\Users\\Gary\\Documents\\code\\WonderSwipe\\node_modules\\babel-preset-react-native\\index.js")
    at Plugin.init (C:\Users\Gary\AppData\Roaming\npm\node_modules\react-native-git-upgrade\node_modules\babel-core\lib\transformation\plugin.js:131:13)
    at Function.normalisePlugin (C:\Users\Gary\AppData\Roaming\npm\node_modules\react-native-git-upgrade\node_modules\babel-core\lib\transformation\file\options\option-manager.js:152:12)
    at C:\Users\Gary\AppData\Roaming\npm\node_modules\react-native-git-upgrade\node_modules\babel-core\lib\transformation\file\options\option-manager.js:184:30
    at Array.map (<anonymous>)
    at Function.normalisePlugins (C:\Users\Gary\AppData\Roaming\npm\node_modules\react-native-git-upgrade\node_modules\babel-core\lib\transformation\file\options\option-manager.js:158:20)
    at OptionManager.mergeOptions (C:\Users\Gary\AppData\Roaming\npm\node_modules\react-native-git-upgrade\node_modules\babel-core\lib\transformation\file\options\option-manager.js:234:36)
    at C:\Users\Gary\AppData\Roaming\npm\node_modules\react-native-git-upgrade\node_modules\babel-core\lib\transformation\file\options\option-manager.js:265:14
    at C:\Users\Gary\AppData\Roaming\npm\node_modules\react-native-git-upgrade\node_modules\babel-core\lib\transformation\file\options\option-manager.js:323:22
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (C:\Users\Gary\AppData\Roaming\npm\node_modules\react-native-git-upgrade\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
git-upgrade ERR! Restore initial sources
Note: checking out 'project-snapshot'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

Reproducible Demo

Run react-native-git-upgrade 0.57.0-rc.0. I can reproduce same error on both Windows and MacOS (latest High Sierra).

I’ve never encountered a similar breakage with git-upgrade for about the last 10 version of RN upgrades I’ve done with react-native-git-upgrade.

Ref: https://github.com/react-native-community/react-native-releases/issues/34

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 8
  • Comments: 16 (3 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve done some investigation and the original reported issue is caused by react-native-git-upgrade using still Babel 6 to transpile itself:

https://github.com/facebook/react-native/blob/9c1ea45d38a6ec731894443debe8879fa3876ab7/react-native-git-upgrade/cli.js#L12-L19

Babel by default tries to find .babelrc files to configure itself, and once it finds the one from the RN app (which links to the RN preset that only works on Babel 7) it fails.

The easiest patch to fix this issue is to add babelrc: false to the babel-register method, so Babel does not read any additional .babelrc file.

@fungilation can you give this a try? feel free to send a PR if this fixes the issue 😃

I guess that I’ve to lock this issue too, apparently it’s impossible to avoid disruptive people when trying to fix issues related to release candidates 🤷‍♂️

I’ll keep saying it, it’s an open source project. Don’t you like something? Fork it and fix it yourself. Writing these kinds of comments is just pathetic.

EDIT: Apparently, the user who posted the disruptive comment deleted it. And yes, I have a screenshot of the comment.

EDIT2: Unlocking, hoping that the conversation will now move towards helpful interactions. And, again, PRs are the first way to move forward this issue.

I tried upgrading to react 57 rc by first yarn add react-native-git-upgrade

Change its cli.js to

  presets: [
    require('babel-preset-es2015-node'),
    require('babel-preset-stage-3')
  ],
  babelrc: false,
  // Enable transpiling for react-native-git-upgrade AND the generator, just like the upgrade CLI command does
  only: /(react-native-git-upgrade\/(?!(node_modules)))|(local-cli\/generator)/
});

yarn react-native-git-upgrade 0.57.0-rc.0

It does seem to upgrade the node modules to 0.57.0 but the package.json is not updated.

FWIW, @rafeca’s fix worked for me. Patched and ran react-native-git-upgrade, resolved merge conflicts, cleaned up with npm uninstall babel-preset-react-native, and I’m good to go (or rather, I’ve moved on to the next issue, #20712).

Environment
  React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
      Memory: 849.51 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 8.10.0 - /usr/local/bin/node
      Yarn: 1.9.4 - /usr/local/bin/yarn
      npm: 5.10.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
      Android SDK:
        Build Tools: 23.0.1, 23.0.3, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.3, 27.0.3, 28.0.2
        API Levels: 23, 25, 26, 27
    IDEs:
      Android Studio: 3.1 AI-173.4907809
      Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
    npmPackages:
      react: ^16.4.1 => 16.4.1
      react-native: ^0.57.0-rc.0 => 0.57.0-rc.0
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

Made those changes and ran yarn. Confirmed that yarn.lock shows babel deps now at 7.0.0-beta.56 instead of 7.0.0-beta.47 before, and metro went from 0.38.3 to 0.43.6. (not 0.43.5, a problem?)

But running react-native upgrade hits the same Error: Cannot find module 'metro/src/blacklist'… as before.