I'm trying to make my NPM module work in the browser, but I'm having a little trouble understanding the UMD syntax. Here are my requirements for my module, which I'll call Mod.
- I need to be able to call child functions of Mod, like
Mod.DoSomething()
,Mod.Utils.DoSomethingElse()
, etc. from other files in the browser - It needs to play nice with Webpack, Browserify, RequireJS, etc.
- I need to be able to require it as a module in an NPM package, just like any other package.
var mod = require('mod'); var returnedVal = Mod.DoSomething;
I don't have any dependencies, but I'd appreciate an example of how to do it both with and without dependencies. One of my main questions is how to export the child functions, so please include them in the example. Thanks!