Skip to content

Commit

Permalink
allow setting namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
maccman committed Nov 14, 2017
1 parent 80a2d1e commit ff23b45
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,6 @@
<% namespace = Sprockets::CommonJS.default_namespace %>
(function() { (function() {
if (!this.require) { if (!<%= namespace %>) {
var modules = {}, cache = {}; var modules = {}, cache = {};


var require = function(name, root) { var require = function(name, root) {
Expand Down Expand Up @@ -42,19 +43,19 @@
return path.split('/').slice(0, -1).join('/'); return path.split('/').slice(0, -1).join('/');
}; };


this.require = function(name) { <%= namespace %> = function(name) {
return require(name, ''); return require(name, '');
}; };


this.require.define = function(bundle) { <%= namespace %>.define = function(bundle) {
for (var key in bundle) { for (var key in bundle) {
modules[key] = bundle[key]; modules[key] = bundle[key];
} }
}; };


this.require.modules = modules; <%= namespace %>.modules = modules;
this.require.cache = cache; <%= namespace %>.cache = cache;
} }


return this.require; return <%= namespace %>;
}).call(this); }).call(this);

0 comments on commit ff23b45

Please sign in to comment.