Created
April 20, 2015 17:04
-
-
Save git-toni/c28a0c626234fddc9558 to your computer and use it in GitHub Desktop.
Brunch + Riot troubles
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
(function() { | |
'use strict'; | |
var globals = typeof window === 'undefined' ? global : window; | |
if (typeof globals.require === 'function') return; | |
var modules = {}; | |
var cache = {}; | |
var has = ({}).hasOwnProperty; | |
var aliases = {}; | |
var endsWith = function(str, suffix) { | |
return str.indexOf(suffix, str.length - suffix.length) !== -1; | |
}; | |
var unalias = function(alias, loaderPath) { | |
var start = 0; | |
if (loaderPath) { | |
if (loaderPath.indexOf('components/' === 0)) { | |
start = 'components/'.length; | |
} | |
if (loaderPath.indexOf('/', start) > 0) { | |
loaderPath = loaderPath.substring(start, loaderPath.indexOf('/', start)); | |
} | |
} | |
var result = aliases[alias + '/index.js'] || aliases[loaderPath + '/deps/' + alias + '/index.js']; | |
if (result) { | |
return 'components/' + result.substring(0, result.length - '.js'.length); | |
} | |
return alias; | |
}; | |
var expand = (function() { | |
var reg = /^\.\.?(\/|$)/; | |
return function(root, name) { | |
var results = [], parts, part; | |
parts = (reg.test(name) ? root + '/' + name : name).split('/'); | |
for (var i = 0, length = parts.length; i < length; i++) { | |
part = parts[i]; | |
if (part === '..') { | |
results.pop(); | |
} else if (part !== '.' && part !== '') { | |
results.push(part); | |
} | |
} | |
return results.join('/'); | |
}; | |
})(); | |
var dirname = function(path) { | |
return path.split('/').slice(0, -1).join('/'); | |
}; | |
var localRequire = function(path) { | |
return function(name) { | |
var absolute = expand(dirname(path), name); | |
return globals.require(absolute, path); | |
}; | |
}; | |
var initModule = function(name, definition) { | |
var module = {id: name, exports: {}}; | |
cache[name] = module; | |
definition(module.exports, localRequire(name), module); | |
return module.exports; | |
}; | |
var require = function(name, loaderPath) { | |
var path = expand(name, '.'); | |
if (loaderPath == null) loaderPath = '/'; | |
path = unalias(name, loaderPath); | |
if (has.call(cache, path)) return cache[path].exports; | |
if (has.call(modules, path)) return initModule(path, modules[path]); | |
var dirIndex = expand(path, './index'); | |
if (has.call(cache, dirIndex)) return cache[dirIndex].exports; | |
if (has.call(modules, dirIndex)) return initModule(dirIndex, modules[dirIndex]); | |
throw new Error('Cannot find module "' + name + '" from '+ '"' + loaderPath + '"'); | |
}; | |
require.alias = function(from, to) { | |
aliases[to] = from; | |
}; | |
require.register = require.define = function(bundle, fn) { | |
if (typeof bundle === 'object') { | |
for (var key in bundle) { | |
if (has.call(bundle, key)) { | |
modules[key] = bundle[key]; | |
} | |
} | |
} else { | |
modules[bundle] = fn; | |
} | |
}; | |
require.list = function() { | |
var result = []; | |
for (var item in modules) { | |
if (has.call(modules, item)) { | |
result.push(item); | |
} | |
} | |
return result; | |
}; | |
require.brunch = true; | |
globals.require = require; | |
})(); | |
require.register("application", function(exports, require, module) { | |
"use strict"; | |
var count = 0; | |
var App = { | |
items: ['Learn Brunch', 'Apply to my projects', '…', 'Profit!'], | |
init: function init() { | |
var box = require('tags/comment-box'); | |
console.log(box); | |
} | |
}; | |
} | |
module.exports = App; | |
}); | |
require.register("tags/comment-box", function(exports, require, module) { | |
riot.tag('h2', 'Hello Hola', function(opts) { //< -------------------------------- Riot TAG properly compiled | |
}); | |
}); | |
require.register("views/list", function(exports, require, module) { | |
var __templateData = function template(locals) { | |
var buf = []; | |
var jade_mixins = {}; | |
var jade_interp; | |
var locals_ = (locals || {}),items = locals_.items; | |
buf.push("<h2>Things to do:</h2><ul id=\"mainTodo\" class=\"tasks\">"); | |
// iterate items | |
;(function(){ | |
var $$obj = items; | |
if ('number' == typeof $$obj.length) { | |
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) { | |
var item = $$obj[$index]; | |
buf.push("<li>" + (jade.escape(null == (jade_interp = item) ? "" : jade_interp)) + "</li>"); | |
} | |
} else { | |
var $$l = 0; | |
for (var $index in $$obj) { | |
$$l++; var item = $$obj[$index]; | |
buf.push("<li>" + (jade.escape(null == (jade_interp = item) ? "" : jade_interp)) + "</li>"); | |
} | |
} | |
}).call(this); | |
buf.push("</ul>");;return buf.join(""); | |
}; | |
if (typeof define === 'function' && define.amd) { | |
define([], function() { | |
return __templateData; | |
}); | |
} else if (typeof module === 'object' && module && module.exports) { | |
module.exports = __templateData; | |
} else { | |
__templateData; | |
} | |
}); | |
; | |
//# sourceMappingURL=app.js.map |
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
"use strict"; | |
var count = 0; | |
var App = { | |
items: ['Learn Brunch', 'Apply to my projects', '…', 'Profit!'], | |
init: function init() { | |
var box = require('tags/comment-box'); | |
console.log(box); | |
} | |
}; | |
} | |
module.exports = App; |
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
module.exports = config: | |
files: | |
javascripts: joinTo: | |
'libraries.js': /^bower_components/ | |
'app.js': /^app/ | |
stylesheets: joinTo: 'app.css' | |
templates: joinTo: 'app.js' | |
server: | |
#path: 'custom-server.js' | |
run: yes | |
plugins: | |
on: ["riot"] | |
riot: | |
extension: 'tag' # pattern overrides extension | |
pattern: /\.tag$/ # default | |
template: 'jade' | |
#type: 'coffeescript' |
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
h2 Hello there! |
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
<!doctype html> | |
<html> | |
<hea | |
<meta charset="utf-8"> | |
<title>Simple Brunch Demo</title> | |
<link rel="stylesheet" href="app.css"> | |
</head> | |
<body> | |
<comment-box></comment-box> | |
<script src="libraries.js"></script> | |
<script src="app.js"></script> | |
<script>riot.mount('comment-box');</script> | |
<script>require('application').init();</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment