webex/webex-js-sdk

Build fails out of the box on exif dependency

andrewplummer opened this issue · 4 comments

Building a basic React app out of the box, trying to import webex generates the following error:

ERROR in ./node_modules/exif/lib/exif/ExifImage.js
Module not found: Error: Can't resolve 'fs' in '/Users/andrew/Experiments/webex/node_modules/exif/lib/exif'
 @ ./node_modules/exif/lib/exif/ExifImage.js 5:9-22
 @ ./node_modules/exif/lib/exif/index.js
 @ ./node_modules/@webex/helper-image/dist/index.js
 @ ./node_modules/@webex/internal-plugin-conversation/dist/conversation.js
 @ ./node_modules/@webex/internal-plugin-conversation/dist/index.js
 @ ./node_modules/@webex/internal-plugin-calendar/dist/index.js
 @ ./node_modules/webex/dist/webex.js
 @ ./node_modules/webex/dist/index.js
 @ ./src/index.js

App is a skeleton React app using webpack and babel to compile:

import React from 'react';
import ReactDOM from 'react-dom';
import { init as webexInit } from 'webex';

const App = () => {
  return (
    <div />
  );
}

ReactDOM.render(<App />, document.getElementById('root'));

package.json:

{
  "scripts": {
    "build": "webpack"
  },
  "dependencies": {
    "@babel/core": "^7.9.6",
    "@babel/preset-env": "^7.9.6",
    "@babel/preset-react": "^7.9.4",
    "babel-loader": "^8.1.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "webex": "^1.80.199",
    "webpack": "^4.43.0",
    "webpack-cli": "^3.3.11"
  }
}

For usage with a base webpack config, you will need to add the following to your configuration file:

node: {
  fs: 'empty'
}

For reference, check out the webpack docs: https://webpack.js.org/configuration/node/

Would be great if that were in the docs somewhere ... a lot of people are using webpack and the "getting started" guide will fail outright for them. Thanks for the quick reply!

Good call @andrewplummer! I've created PR #1658 to add those to the readme.

Thank you!