Created
March 7, 2016 20:54
-
-
Save radiovisual/4fe224a5cb2be3cd0b5d to your computer and use it in GitHub Desktop.
Simple component boilerplate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Change references to "blahCode" on lines 10 and 19 | |
// to reflect the name of your module, as you want it to | |
// appear in the global scope of your enviornment | |
(function (root, factory) { | |
'use strict'; | |
if (typeof define === 'function' && define.amd) { | |
// AMD. Register as an anonymous module. | |
define([], function () { | |
return (root.blahCode = factory()); | |
}); | |
} else if (typeof exports === 'object') { | |
// Node. Does not work with strict CommonJS, but | |
// only CommonJS-like enviroments that support module.exports, | |
// like Node. | |
module.exports = factory(); | |
} else { | |
// Browser globals | |
root.blahCode = factory(); | |
} | |
})(this, function () { | |
// UMD Definition above, do not remove this line | |
// To get to know more about the Universal Module Definition | |
// visit: https://github.com/umdjs/umd | |
'use strict'; | |
// All your code now goes here. Everything above all | |
// of this some boilerplate to get your module ready to work in | |
// multiple enviornments | |
var myFunction = function (text) { | |
// ... | |
}; | |
return { | |
myFunction: myFunction | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment