From: Dan Vanderkam Date: Wed, 28 Dec 2016 20:06:21 +0000 (-0500) Subject: Guard process access for rollup X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=39a2594ec2c2eadb53d80cbb8dad6b11f7d5a680;p=dygraphs.git Guard process access for rollup --- diff --git a/src/dygraph-options-reference.js b/src/dygraph-options-reference.js index 19718e6..4a066bb 100644 --- a/src/dygraph-options-reference.js +++ b/src/dygraph-options-reference.js @@ -9,6 +9,7 @@ var OPTIONS_REFERENCE = null; // For "production" code, this gets removed by uglifyjs. +if (typeof(process) !== 'undefined') { if (process.env.NODE_ENV != 'production') { // NOTE: in addition to parsing as JS, this snippet is expected to be valid @@ -876,5 +877,6 @@ for (var k in OPTIONS_REFERENCE) { } } +} export default OPTIONS_REFERENCE; diff --git a/src/dygraph-options.js b/src/dygraph-options.js index c77e498..7c7f745 100644 --- a/src/dygraph-options.js +++ b/src/dygraph-options.js @@ -167,8 +167,10 @@ DygraphOptions.prototype.reparseSeries = function() { utils.update(this.xAxis_.options, axis_opts["x"] || {}); // For "production" code, this gets removed by uglifyjs. - if (process.env.NODE_ENV != 'production') { - this.validateOptions_(); + if (typeof(process) !== 'undefined') { + if (process.env.NODE_ENV != 'production') { + this.validateOptions_(); + } } }; @@ -326,6 +328,7 @@ DygraphOptions.prototype.seriesNames = function() { }; // For "production" code, this gets removed by uglifyjs. +if (typeof(process) !== 'undefined') { if (process.env.NODE_ENV != 'production') { /** @@ -395,5 +398,6 @@ DygraphOptions.resetWarnings_ = function() { }; } +} export default DygraphOptions; diff --git a/src/dygraph.js b/src/dygraph.js index 7cb9bff..28dff23 100644 --- a/src/dygraph.js +++ b/src/dygraph.js @@ -366,14 +366,16 @@ Dygraph.prototype.toString = function() { */ Dygraph.prototype.attr_ = function(name, seriesName) { // For "production" code, this gets removed by uglifyjs. - if (process.env.NODE_ENV != 'production') { - if (typeof(OPTIONS_REFERENCE) === 'undefined') { - console.error('Must include options reference JS for testing'); - } else if (!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. - OPTIONS_REFERENCE[name] = true; + if (typeof(process) !== 'undefined') { + if (process.env.NODE_ENV != 'production') { + if (typeof(OPTIONS_REFERENCE) === 'undefined') { + console.error('Must include options reference JS for testing'); + } else if (!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. + OPTIONS_REFERENCE[name] = true; + } } } return seriesName ? this.attributes_.getForSeries(name, seriesName) : this.attributes_.get(name);