Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UMD format #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@
* Copyright 2011 Evan Wallace
* Released under the MIT license
*/
'''
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.%s = factory());
}(this, (function () { 'use strict';
''' % module

footer = '})));'

def sources():
return [os.path.join(base, f) for base, folders, files in \
Expand All @@ -35,7 +42,7 @@ def compress(match):
return text

def build():
data = 'var %s = (function() {\n\n%s\nreturn %s;\n})();\n' % (module, compile(sources()), module)
data = '\n%s\nreturn %s;\n' % (compile(sources()), module)
if 'release' in sys.argv:
f1, temp1_path = tempfile.mkstemp()
f2, temp2_path = tempfile.mkstemp()
Expand All @@ -47,7 +54,7 @@ def build():
data = open(temp2_path).read()
os.remove(temp2_path)
data = compress_glsl(data)
data = header + data
data = header + data + footer
open(output_path, 'w').write(data)
print 'built %s (%u lines)' % (output_path, len(data.split('\n')))

Expand Down
1 change: 1 addition & 0 deletions src/shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// }).draw(mesh);

function regexMap(regex, text, callback) {
var result = null;
while ((result = regex.exec(text)) != null) {
callback(result);
}
Expand Down