Preventing Browserify from Including React as Dependency


#1

I’m trying to include the React-Bootstrap NPM module into my Meteor/React app using Browserify. For my app, I am using meteor add react for including React. Unfortunately, it seems that Browserify itself is also seeing that React-Bootstrap depends on React.

As a result, in packages/npm-container/.npm/package.js, there are actually two React and ReactDOM dependencies being generated when there really should be none.

Just FYI, my packages.json file at the project root only contains the following:

{
  "react-bootstrap" : "0.28.1"
}

I let cosmos:browserify do the rest.

What can I do to prevent Browserify from pulling in that dependency? I’ve also tried meteor remove react and then adding React and ReactDOM into packages.json instead, but for some reason I get strange routing errors (I am using Flow-Router).

Anybody experience anything similar?


#2

Did you add this to app.browserify.options.json?

{
  "transforms": {
    "externalify": {
      "global": true,
      "external": {
        "react": "React.require"
      }
    }
  }
}

http://react-in-meteor.readthedocs.org/en/latest/client-npm/#4-configure-browserify-and-transforms-in-appbrowserifyoptionsjson