Permalink
Browse files

create development builds and strip debugging code when creating prod…

…uction builds. See #17
  • Loading branch information...
1 parent 8b5b3af commit d5ded4c285223ac8f80ed9f1890b020eb464db0c @petermichaux committed Jun 22, 2013
Showing with 53 additions and 11 deletions.
  1. +1 −0 CHANGES.md
  2. +15 −8 Makefile
  3. +7 −1 README.md
  4. +10 −0 bin/strip-debugging-code
  5. +9 −2 src/ElementView.js
  6. +11 −0 src/namespace.js
View
@@ -1,5 +1,6 @@
1.1.0 - [date]
--------------
+* development builds in maria-debug.js and maria-amd-debug.js
* constructor functions have a superConstructor property
1.0.0 - June 1, 2013
View
@@ -48,11 +48,15 @@ tmp/maria-raw.js: $(LIBS) $(SRCS)
mkdir -p build/dist tmp
cat $(LIBS) $(SRCS) >tmp/maria-raw.js
-build/dist/maria.js: tmp/maria-raw.js
+build/dist/maria-debug.js: tmp/maria-raw.js
mkdir -p build/dist
- echo "var maria = (function() { // IIFE" > build/dist/maria.js
- cat tmp/maria-raw.js >> build/dist/maria.js
- echo "\nreturn maria;}()); // IIFE" >> build/dist/maria.js
+ echo "var maria = (function() { // IIFE" > build/dist/maria-debug.js
+ cat tmp/maria-raw.js >> build/dist/maria-debug.js
+ echo "\nreturn maria;}()); // IIFE" >> build/dist/maria-debug.js
+ gzip --best -c build/dist/maria-debug.js > build/dist/maria-debug.js.gz
+
+build/dist/maria.js: build/dist/maria-debug.js
+ bin/strip-debugging-code build/dist/maria-debug.js > build/dist/maria.js
gzip --best -c build/dist/maria.js > build/dist/maria.js.gz
build/dist/maria-min.js: build/dist/maria.js lib/compiler
@@ -61,10 +65,13 @@ build/dist/maria-min.js: build/dist/maria.js lib/compiler
echo "/*\n//@ sourceMappingURL=maria-min.map\n*/\n" >> build/dist/maria-min.js
gzip --best -c build/dist/maria-min.js > build/dist/maria-min.js.gz
-build/dist/maria-amd.js: tmp/maria-raw.js
- echo "define(function() { // AMD" > build/dist/maria-amd.js
- cat tmp/maria-raw.js >> build/dist/maria-amd.js
- echo "\nreturn maria;}); // AMD" >> build/dist/maria-amd.js
+build/dist/maria-amd-debug.js: tmp/maria-raw.js
+ echo "define(function() { // AMD" > build/dist/maria-amd-debug.js
+ cat tmp/maria-raw.js >> build/dist/maria-amd-debug.js
+ echo "\nreturn maria;}); // AMD" >> build/dist/maria-amd-debug.js
+
+build/dist/maria-amd.js: build/dist/maria-amd-debug.js
+ bin/strip-debugging-code build/dist/maria-amd-debug.js > build/dist/maria-amd.js
deploy-www: build/www
scp -r build/www/* peter@michaux.ca:~/sites/maria
View
@@ -17,12 +17,18 @@ Downloads
See [http://peter.michaux.ca/downloads/maria/](http://peter.michaux.ca/downloads/maria/?C=M;O=D)
-`maria.js` contains all the Maria source files concatenated together. This is a good file to use during the development of your application.
+There are several different built files from which to choose:
+
+`maria.js` the main release of the framework. If in doubt, use this file.
`maria-min.js` contains the same code as `maria.js` but `maria-min.js` has been minified to remove whitespace and code comments. This is a good file to serve in production.
+`maria-debug.js` contains additional code that is stripped when creating `maria.js`. This additional code points developers to potential problems with more informative console logging. `maria-debug.js` is a good file to use during development.
+
`maria-amd.js` contains the same code as `maria.js` but it is wrapped in an AMD module definition that returns the `maria` object.
+`maria-amd-debug.js` similar to `maria-debug.js` but for developers in the AMD world.
+
Install via Bower with ```bower install maria```
@@ -0,0 +1,10 @@
+#!/usr/bin/perl -p
+
+# http://stackoverflow.com/questions/1030787/multiline-search-replace-with-perl
+
+use warnings;
+use strict;
+
+BEGIN {undef $/;}
+
+s|/\* DEBUG BEGIN \*/.*?/\* DEBUG END \*/||sg
View
@@ -270,8 +270,15 @@ as the root element of this view. All other sibling elements of the
*/
maria.ElementView.prototype.buildTemplate = function() {
- // parseHTML returns a DocumentFragment so take firstChild as the rootEl
- this._rootEl = arbutus.parseHTML(this.getTemplate(), this.getDocument()).firstChild;
+ // parseHTML returns a DocumentFragment. Take its firstChild as the rootEl.
+
+ var fragment = arbutus.parseHTML(this.getTemplate(), this.getDocument());
+ /* DEBUG BEGIN */
+ if (fragment.childNodes.length > 1) {
+ console.warn('The following template has multiple root-level elements. Only the first root-level element is used and all following root-level elements are ignored.', this.getTemplate());
+ }
+ /* DEBUG END */
+ this._rootEl = fragment.firstChild;
};
(function() {
View
@@ -6,3 +6,14 @@ Root namespace
*/
var maria = {};
+
+/* DEBUG BEGIN */
+
+// Help older browsers without the `console` host object.
+
+var console = console || {};
+console.log = console.log || function() {};
+console.warn = console.warn || function() {};
+console.error = console.error || function() {};
+
+/* DEBUG END */

0 comments on commit d5ded4c

Please sign in to comment.