Create-react-app: Expose "external" property from webpack config

Created on 12 Jul 2017  路  4Comments  路  Source: facebook/create-react-app

I would like to use this property to remove some dependencies from create-react-app. In my case I already have a page with React and ReactDOM, but I don't have control over them, it's not my project. I will just do some components, to contribuite with this page, so when I generate the build file I don't want React or ReactDOM, only the code for the components. There is another way for to do this ?

question

Most helpful comment

Yeah, right now there's no work around for that.
You can create a fake react dependency if you'd like (where all it does is module.exports = window.React;).
Then update package.json to reference a file:../react-stub or something.

All 4 comments

I'm going to close this as I feel it's a dupe of #2758.
Short answer, no -- you cannot do this. We're also not exposing external anytime soon; but we want to figure out an "external" method.

If React is already loaded on the page, you should be able to do something like:

const React = window.React

Just never import React yourself.

How about peer dependencies?
import Panel from 'react-bootstrap/lib/Panel' is still causing React to be included in the bundle right?

Yeah, right now there's no work around for that.
You can create a fake react dependency if you'd like (where all it does is module.exports = window.React;).
Then update package.json to reference a file:../react-stub or something.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gabrielmicko picture gabrielmicko  路  70Comments

sgriffey picture sgriffey  路  113Comments

ericvicenti picture ericvicenti  路  83Comments

godmar picture godmar  路  130Comments

benneq picture benneq  路  99Comments