APSL/react-native-button

Unable to import module (with babel)

shivekkhurana opened this issue · 1 comments

I'm using the react-native-webpack-starter-kit with babel

I get the following error while importing :

ERROR in ./~/apsl-react-native-button/Button.js
Module parse failed: /Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/apsl-react-native-button/Button.js Unexpected token (53:10)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (53:10)
    at Parser.pp.raise (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:923:13)
    at Parser.pp.unexpected (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:1490:8)
    at Parser.pp.parseExprAtom (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:333:12)
    at Parser.pp.parseExprSubscripts (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:228:19)
    at Parser.pp.parseMaybeUnary (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:207:17)
    at Parser.pp.parseExprOps (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:154:19)
    at Parser.pp.parseMaybeConditional (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:136:19)
    at Parser.pp.parseMaybeAssign (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:112:19)
    at Parser.pp.parseParenAndDistinguishExpression (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:376:28)
    at Parser.pp.parseExprAtom (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:307:19)
    at Parser.pp.parseExprSubscripts (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:228:19)
    at Parser.pp.parseMaybeUnary (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:207:17)
    at Parser.pp.parseExprOps (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:154:19)
    at Parser.pp.parseMaybeConditional (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:136:19)
    at Parser.pp.parseMaybeAssign (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:112:19)
    at Parser.pp.parseVar (/Users/shivekkhurana/Documents/WIP/Cfel/LifeU/node_modules/webpack/node_modules/acorn/dist/acorn.js:2060:24)
 @ ./src/components/auth/Login.js 4:27-62
  • "apsl-react-native-button": "^3.0.0"
  • "react": "^15.2.1"
  • "react-native": "^0.28.0"
  • "babel-core": "^6.10.4"
  • "babel-loader": "^6.2.4"
  • "babel-preset-es2015": "^6.9.0"

On browsing through closed solutions, I found #2, but adding whitelist to web pack config doesn't solve the issue.

...
      loaders: [
        {
          test: /\.(js|jsx|es6)$/,
          include: /node_modules\/react-native/,
          loader: 'babel',
          query: {
            cacheDirectory: true,
            presets: ['es2015', 'stage-1', 'react']
          },
          whitelist: 'es6.modules'
        },
...

How to go about this ?

Thank you.

When I shifted from webpack to native packager, this problem went away.