In my webapplication I have ReactJS bundled together with the my code and included as into html page.
We also have set of modules that we load using requireJs. And one of those modules is built using WebPack as umd target.
Whenever the client tries to load that module using requireJS, requirejs also tries to load React and ReactDOM because of that line in the module:
define(["React", "ReactDOM"], factory);
But I don't want require to donwload React and ReactDOM since it already loaded. How to I let requireJS know that this module is already loaded and there is no need to load it again?
You can define a set of named dummy modules, prior to loading your module.
define('React', function() {
// return the React global (if there is one)
return React;
});
define('ReactDOM', function() {
// return the ReactDOM global (if there is one)
return ReactDOM;
});
That will "trick" Require into thinking they are already loaded... which they are.
Note: I'm not familiar with React so you may need to return something different. It is going to depend on how you've included React and ReactDOM in you webpage prior to this.