Skip to content

Instantly share code, notes, and snippets.

@drewlustro
Last active January 4, 2016 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewlustro/8607452 to your computer and use it in GitHub Desktop.
Save drewlustro/8607452 to your computer and use it in GitHub Desktop.
I'm trying to create an AMD-style library called "Brace" using requirejs and I'm having issues. I try to make the master Brace object and decorate it with classes. On build, "Brace" is undefined for the Brace.Base class. How do I attach class modules to the master Brace object? I'm surely missing something here about exports or global scope or s…
// brace/brace.js
(function(Brace) {
define('brace/base',
['THREE'],
function (THREE) {
Base = function() {
Object.call(this);
this.settingsFolder = 'Global';
}
Base.prototype = new Object;
Base.prototype.init = function() {};
Base.prototype.log = function () {
[].unshift.call(arguments, this.constructor.name, ']]');
console.log.apply(console, arguments);
}
Base.prototype.slugify = function (text) {
return text.toLowerCase()
.replace(/ /g, '_')
.replace(/[^\w-]+/g, '');
}
Brace.Base = Base;
return Brace.Base;
});
})(Brace);
// brace/base.js
(function() {
Brace = {};
define('brace/brace', ['THREE', 'brace/base', 'brace/publisher', 'brace/app', 'brace/object', 'brace/settings'],
function (THREE, Base, Publisher, App, SceneObject, Settings) {
Brace.Base = Base;
Brace.Object = SceneObject;
Brace.Settings = Settings;
Brace.Publisher = Publisher;
Brace.App = App;
return Brace;
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment