teamplanes / expobook

Share your component library using Expo
88 stars 6 forks source link

Build error from babel-plugin-module-resolver #9

Open jesconstantine opened 5 years ago

jesconstantine commented 5 years ago

I've followed the installation instructions, and added the recommended expobook script to package.json but I'm seeing an error when I try to run expobook with yarn expobook and npm run expobook. See package.json, app.json, expobook.js and error output below. I'd appreciate any insight. Thanks!

package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "eject": "expo eject",
    "expobook": "./node_modules/.bin/expobook",
    "test": "node ./node_modules/jest/bin/jest.js --watchAll"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "engines": {
    "yarn": ">=1.10.1",
    "node": ">=8.0 <11.0"
  },
  "dependencies": {
    "@expo/samples": "2.1.1",
    "expo": "^31.0.2",
    "expobook": "0.0.4",
    "react": "16.5.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
    "react-navigation": "^2.18.2"
  },
  "devDependencies": {
    "babel-preset-expo": "^5.0.0",
    "expo-cli": "^2.5.0",
    "jest-expo": "^31.0.0",
    "node": "^10.13.0"
  },
  "private": true
}

app.json

{
  "expo": {
    "name": "app",
    "slug": "app",
    "privacy": "public",
    "sdkVersion": "31.0.0",
    "platforms": [
      "ios",
      "android"
    ],
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "splash": {
      "image": "./assets/images/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "enabled": true,
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true
    }
  }
}

expobook.js

import React from 'react';
import createExpobook from 'expobook';
import TabBarIcon from './components/TabBarIcon';

const expobook = createExpobook();

expobook.add('Tab Bar Icon', () => <TabBarIcon name="Test" focused="true"/>);

export default expobook.build();

error output

yarn expobook
yarn run v1.12.3
$ ./node_modules/.bin/expobook
09:34:07 [exp] There is a new version of exp available (57.2.1).
You are currently using exp 51.4.0
Run `npm install -g exp` to get the latest version
09:34:08 [exp] Using project at <path/to/project>/app
09:34:14 [exp] Starting React Native packager...
09:34:15 [exp] <path/to/project>/app/node_modules/babel-plugin-module-resolver/lib/index.js:88
09:34:15 [exp]       })[1];
09:34:15 [exp]         ^
09:34:15 [exp] 
09:34:15 [exp] TypeError: Cannot read property '1' of undefined
09:34:15 [exp]     at Plugin.manipulateOptions (<path/to/project>/app/node_modules/babel-plugin-module-resolver/lib/index.js:88:9)
09:34:15 [exp]     at normalizeOptions (<path/to/project>/app/node_modules/@babel/core/lib/transformation/normalize-opts.js:59:16)
09:34:15 [exp]     at runSync (<path/to/project>/app/node_modules/@babel/core/lib/transformation/index.js:44:86)
09:34:15 [exp]     at transformSync (<path/to/project>/app/node_modules/@babel/core/lib/transform.js:43:38)
09:34:15 [exp]     at Object.transform (<path/to/project>/app/node_modules/@babel/core/lib/transform.js:22:38)
09:34:15 [exp]     at compile (<path/to/project>/app/node_modules/@babel/register/lib/node.js:73:20)
09:34:15 [exp]     at compileHook (<path/to/project>/app/node_modules/@babel/register/lib/node.js:102:12)
09:34:15 [exp]     at Module._compile (<path/to/project>/app/node_modules/pirates/lib/index.js:77:29)
09:34:15 [exp]     at Module._extensions..js (module.js:671:10)
09:34:15 [exp]     at Object.newLoader [as .js] (<path/to/project>/app/node_modules/pirates/lib/index.js:88:7)
yarn why babel-plugin-module-resolver
yarn why v1.12.3
[1/4] 🤔  Why do we have the module "babel-plugin-module-resolver"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "babel-plugin-module-resolver@2.7.1"
info Has been hoisted to "babel-plugin-module-resolver"
info Reasons this module exists
   - Hoisted from "expobook#exponent#babel-preset-exponent#babel-plugin-module-resolver"
   - Hoisted from "expobook#expo#react-native-maps#babel-plugin-module-resolver"
   - Hoisted from "expobook#expo#babel-preset-expo#babel-plugin-module-resolver"
info Disk size without dependencies: "76KB"
info Disk size with unique dependencies: "732KB"
info Disk size with transitive dependencies: "1.05MB"
info Number of shared dependencies: 12
=> Found "babel-preset-expo#babel-plugin-module-resolver@3.1.1"
info This module exists because "babel-preset-expo" depends on it.
info Disk size without dependencies: "76KB"
info Disk size with unique dependencies: "916KB"
info Disk size with transitive dependencies: "1.3MB"
info Number of shared dependencies: 15
kirkness commented 5 years ago

Hello, haven't run this in a while and looks like an issue with an update with expo. I'll give this a try today.

jesconstantine commented 5 years ago

@kirkness thanks for your speedy response. FWIW when I pull your branch into my project I can successfully build expobook!