vovkasm / react-native-web-image

An image component for react-native with persistent disk and memory caching.
MIT License
146 stars 25 forks source link

Getting - You may need an appropriate loader to handle this file type error #7

Open jiteshwadia opened 7 years ago

jiteshwadia commented 7 years ago

Hi, I am facing issue in loading an image.

Error is :

ERROR in ./~/react-native-web-image/index.js
Module parse failed: /Users/MyName/Documents/Learning/Test3/node_modules/react-native-web-image/index.js Unexpected token (12:19)
You may need an appropriate loader to handle this file type.
| 
| class WebImage extends React.Component {
|   static propTypes = {
|     ...View.propTypes,
|     source: SourcePropType.isRequired,
 @ ./index.web.js 9:25-58
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./index.web.js
webpack: Failed to compile.

Webconfig file:

const webpack = require('webpack');

module.exports = {
  entry: {
    main: './index.web.js',
  },
  module: {
    loaders: [
      {
        test: /\.js?$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        query: {
          presets: ['es2015', 'react'],
        },
      },
    ],
  },
  resolve: {
    alias: {
      'react-native': 'react-native-web',
    },
  },
};
vovkasm commented 7 years ago

Hi,

Do I understand right, that you are using react-native-web and target browser, not mobile and your need to pack same codebase to iOS, Android and web?

Note that currently react-native-web-image supports only ios and android, so although we can make js code of the module es5 compatible, this will not make it workable on browsers automatically.

jiteshwadia commented 7 years ago

Yes, you are correct.

vovkasm commented 7 years ago

Ok, I will think about transpilation to es5 before next release.

I don't know react-native-web well, so if you or anyone can help with porting to that platform PRs are welcomed! :-)