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

React Native TransformError #161

Closed
vincentma opened this issue Jan 25, 2017 · 6 comments
Closed

React Native TransformError #161

vincentma opened this issue Jan 25, 2017 · 6 comments

Comments

@vincentma
Copy link

Steps to reproduce,

  1. Create a React Native project.
react-native init test_diff
cd test_diff
npm install --save diff
  1. Modify index.ios.js file, and add the following line.
import {diffChars} from "diff";
  1. Now run the React Native packager.
react-native run-ios
  1. Error shows up. See attached.

screen shot 2017-01-25 at 4 56 50 pm

@vincentma
Copy link
Author

I fixed this problem by add the babel presets into my project.

yarn add babel-preset-es3
yarn add babel-preset-es2015-mod

Also add the ignore file list into .babelrc. So the .babelrc looks like

{
  "presets": ["react-native"],
  "ignore": [
    "node_modules/diff/lib/**/*.js",
    "node_modules/diff/node_modules/**/*.js"
  ]
}

And make sure clear RN cache.

watchman watch-del-all
./node_modules/react-native/packager/packager.sh start --reset-cache
react-native run-ios

@piaaaac
Copy link

piaaaac commented Apr 24, 2017

Had the same error using react (for web, not native), and your solution worked for me as well:

npm i --save-dev babel-preset-es3
npm i --save-dev babel-preset-es2015-mod

and in webpack.config.js added:

  module: {
    rules: [{
      query: {
        presets: [
          'es2015', 'react',
          'es3', 'es2015-mod' // <- added these
        ]
      }
    }]
  }

@motiz88
Copy link
Contributor

motiz88 commented Dec 21, 2017

I believe this issue should be reopened; the fix here would be to move the config to a .babelrc file and exclude it from npm publishing.

@akehir
Copy link

akehir commented Jan 24, 2018

Hi @kpdecker,

Since babel-preset-es2015 has been deprecated, and it's recommended to use babel-preset-env, it would be great, if it wasn't required to install babel-preset-es3 / babel-preset-es2015-mod for jsdiff to run without exceptions. I understand this has been fixed with a47aca9, are you planning to release a new version of jsdiff to npm which would fix this?

@cdutson
Copy link

cdutson commented Feb 16, 2018

Agreed with @akehir. Doubly so since having babel-preset-env and babel-preset-es2015 seems to cause some weird stuff to happen

@kpdecker
Copy link
Owner

kpdecker commented Mar 5, 2018

Released in 3.5.0

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

No branches or pull requests

6 participants