New to browserify: I have a normal js file with some react components grouped in a namespace like:
var myNameSpace= {
'reactFunc1': React....,
'reactFunc2': React....,
'reactFunc3': React....,
'nonreactFunc1' function(..)
}
And in some other js file I'm trying to use:
myNameSpace.reactFunc1(...);
this works fine when I tranform jsx to js using babel.
But when I browerify the files using the command browserify -t [ babelify --presets [ react ] ] some.js someOther.js
myNameSpace not defined
What I'm doing wrong here. Is there any way to get this working without much hastle / code change?
myNameSpace.reactFunc1is defined but when I browserifymyNameSpace.reactFunc2is undefinedvar myNameSpace= { 'reactFunc1': React...., 'reactFunc2': React...., 'reactFunc3': React...., 'nonreactFunc1' function(..) }as module and export it with namemyNameSpaceand use this in other js file and do something likemyNameSpace.reactFunc1(...);vardefinitions are local to that module. You'll need to import one module into the other, or dowindow.myNameSpace = ...