Skip to content

Instantly share code, notes, and snippets.

@radiovisual
Created March 7, 2016 20:54
Show Gist options
  • Save radiovisual/4fe224a5cb2be3cd0b5d to your computer and use it in GitHub Desktop.
Save radiovisual/4fe224a5cb2be3cd0b5d to your computer and use it in GitHub Desktop.
Simple component boilerplate
// 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