Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose "external" property from webpack config #2771

Closed
rodrigolourenco opened this issue Jul 12, 2017 · 4 comments
Closed

Expose "external" property from webpack config #2771

rodrigolourenco opened this issue Jul 12, 2017 · 4 comments

Comments

@rodrigolourenco
Copy link

rodrigolourenco commented Jul 12, 2017

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 ?

@Timer
Copy link
Contributor

Timer commented Jul 12, 2017

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.

@Timer Timer closed this as completed Jul 12, 2017
@Timer
Copy link
Contributor

Timer commented Jul 12, 2017

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.

@viankakrisna
Copy link
Contributor

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

@Timer
Copy link
Contributor

Timer commented Jul 12, 2017

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.

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants