From 7b4d0af5fd8cfa6ea613f20e843e81032fac2d48 Mon Sep 17 00:00:00 2001 From: Sascha Gehlich Date: Tue, 18 Feb 2014 22:28:45 +0100 Subject: [PATCH] Add support for CommonJS --- utils/build/build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/build/build.py b/utils/build/build.py index 70210d564a..3e13e9a741 100644 --- a/utils/build/build.py +++ b/utils/build/build.py @@ -46,7 +46,7 @@ def main(argv=None): sources = [] if args.amd: - tmp.write('( function ( root, factory ) {\n\n\tif ( typeof define === \'function\' && define.amd ) {\n\n\t\tdefine( factory );\n\n\t} else {\n\n\t\troot.THREE = factory();\n\n\t}\n\n}( this, function () {\n\n') + tmp.write('( function ( root, factory ) {\n\n\tif ( typeof define === \'function\' && define.amd ) {\n\n\t\tdefine( [\'exports\'], factory );\n\n\t} else if (typeof exports === \'object\') {\n\n\t\tfactory(exports);\n\n\t} else {\n\n\t\tfactory(root);\n\n\t}\n\n}( this, function (exports) {\n\n') for include in args.include: with open('includes/' + include + '.json','r') as f: @@ -59,7 +59,7 @@ def main(argv=None): tmp.write('\n') if args.amd: - tmp.write('return THREE;\n\n} ) );') + tmp.write('exports.THREE = THREE;\n\n} ) );') tmp.close() -- GitLab