From: Robert Konigsberg Date: Sun, 16 Nov 2014 00:07:28 +0000 (-0500) Subject: Merge pull request #464 from danvk/sourcemap X-Git-Tag: v1.1.0~27 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=e8c635cc4e3c265e88f66b46b689e291531330b6;hp=794280e209e8eff709a83e3bf21cf32625a24282;p=dygraphs.git Merge pull request #464 from danvk/sourcemap Generate a source map! --- diff --git a/dygraph.js b/dygraph.js index 7b80e32..a9b1cf9 100644 --- a/dygraph.js +++ b/dygraph.js @@ -43,6 +43,9 @@ */ +// For "production" code, this gets set to false by uglifyjs. +if (typeof(DEBUG) === 'undefined') DEBUG=true; + /*jshint globalstrict: true */ /*global DygraphLayout:false, DygraphCanvasRenderer:false, DygraphOptions:false, G_vmlCanvasManager:false,ActiveXObject:false */ "use strict"; @@ -665,16 +668,16 @@ Dygraph.prototype.toString = function() { * @return { ... } The value of the option. */ Dygraph.prototype.attr_ = function(name, seriesName) { -// - if (typeof(Dygraph.OPTIONS_REFERENCE) === 'undefined') { - console.error('Must include options reference JS for testing'); - } else if (!Dygraph.OPTIONS_REFERENCE.hasOwnProperty(name)) { - console.error('Dygraphs is using property ' + name + ', which has no ' + - 'entry in the Dygraphs.OPTIONS_REFERENCE listing.'); - // Only log this error once. - Dygraph.OPTIONS_REFERENCE[name] = true; - } -// + if (DEBUG) { + if (typeof(Dygraph.OPTIONS_REFERENCE) === 'undefined') { + console.error('Must include options reference JS for testing'); + } else if (!Dygraph.OPTIONS_REFERENCE.hasOwnProperty(name)) { + console.error('Dygraphs is using property ' + name + ', which has no ' + + 'entry in the Dygraphs.OPTIONS_REFERENCE listing.'); + // Only log this error once. + Dygraph.OPTIONS_REFERENCE[name] = true; + } + } return seriesName ? this.attributes_.getForSeries(name, seriesName) : this.attributes_.get(name); }; diff --git a/file-size-stats.sh b/file-size-stats.sh deleted file mode 100755 index fb81519..0000000 --- a/file-size-stats.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# Reports compressed file sizes for each JS file in dygraphs. - -# This list needs to be kept in sync w/ the one in dygraph-dev.js -# and the one in jsTestDriver.conf. -for file in \ -dygraph-layout.js \ -dygraph-canvas.js \ -dygraph.js \ -dygraph-utils.js \ -dygraph-gviz.js \ -dygraph-interaction-model.js \ -dygraph-tickers.js \ -dashed-canvas.js \ -dygraph-plugin-base.js \ -plugins/annotations.js \ -plugins/axes.js \ -plugins/range-selector.js \ -plugins/chart-labels.js \ -plugins/grid.js \ -plugins/legend.js \ -dygraph-plugin-install.js \ -; do - base_size=$(cat $file | wc -c) - cat $file \ - | perl -ne 'print unless m,REMOVE_FOR_COMBINED,..m,/REMOVE_FOR_COMBINED,' \ - > /tmp/dygraph.js - min_size=$(java -jar yuicompressor-2.4.2.jar /tmp/dygraph.js | gzip -c | wc -c) - - echo "$min_size ($base_size) $file" -done diff --git a/generate-combined.sh b/generate-combined.sh index 30c0a7e..a224156 100755 --- a/generate-combined.sh +++ b/generate-combined.sh @@ -33,8 +33,7 @@ GetSources () { # Pack all the JS together. CatSources () { GetSources \ - | xargs cat \ - | perl -ne 'print unless m,REMOVE_FOR_COMBINED,..m,/REMOVE_FOR_COMBINED,' + | xargs cat } Copyright () { @@ -42,10 +41,13 @@ Copyright () { } CatCompressed () { - Copyright - CatSources \ - | grep -v '"use strict";' \ - | node_modules/uglify-js/bin/uglifyjs -c warnings=false -m + node_modules/uglify-js/bin/uglifyjs \ + $(GetSources | xargs) \ + --compress warnings=false \ + --mangle \ + --define DEBUG=false \ + --preamble "$(Copyright)" \ + $* } ACTION="${1:-update}" @@ -61,8 +63,9 @@ compress*|cat_compress*) CatCompressed ;; update) - CatCompressed > dygraph-combined.js - chmod a+r dygraph-combined.js + CatCompressed --source-map dygraph-combined.js.map \ + > dygraph-combined.js + chmod a+r dygraph-combined.js dygraph-combined.js.map ;; *) echo >&2 "Unknown action '$ACTION'"