Reputation: 1126
So I have a HTML page (the main page) which has references to 2 javascript bundles created by 2 different teams, say app1.js and app2.js.
<html>
<script src='path to app1.js'/>
<script src='path to app2.js' />
</html>
Both teams use react and react-dom.
It seems to be redundant to use react and react-dom in both of the bundles.
Can the production bundle of a single page app be created without react/react-dom in it so that the main page can look something like this?
<html>
<script src='path to react-cdn.js'/>
<script src='path to react-dom-cdn.js' />
<script src='path to app1.js without react/react-dom'/>
<script src='path to app2.js without react/react-dom' />
</html>
If both teams use separate versions of react/react-dom, will it cause version conflicts?
Please note:
Upvotes: 2
Views: 744
Reputation: 36
You can use Webpack externals for this.
We have a similar setup where there are multiple react bundles in the same page. So it didnt make sense to have react, react-dom, moment etc in every bundle.
You could try the following:
Upvotes: 2