Last active
January 4, 2016 10:18
-
-
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…
This file contains 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
// 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); |
This file contains 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
// 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