diff --git a/extensions/fastdom-sandbox.js b/extensions/fastdom-sandbox.js index 39afc28..c2ea72f 100644 --- a/extensions/fastdom-sandbox.js +++ b/extensions/fastdom-sandbox.js @@ -5,7 +5,7 @@ * * @return {Function} */ -var debug = 0 ? console.log.bind(console, '[fastdom-sandbox]') : function() {}; +var debug = process.env.NODE_ENV !== 'production' ? console.log.bind(console, '[fastdom-sandbox]') : function() {}; /** * Exports diff --git a/fastdom-strict.js b/fastdom-strict.js index 007521d..44f6658 100644 --- a/fastdom-strict.js +++ b/fastdom-strict.js @@ -64,7 +64,7 @@ return /******/ (function(modules) { // webpackBootstrap * * @return {Function} */ - var debug = 0 ? console.log.bind(console, '[fastdom-strict]') : function() {}; + var debug = false ? console.log.bind(console, '[fastdom-strict]') : function() {}; /** * Enabled state diff --git a/fastdom.js b/fastdom.js index 8579b62..f7c529e 100644 --- a/fastdom.js +++ b/fastdom.js @@ -18,7 +18,7 @@ * * @return {Function} */ -var debug = 0 ? console.log.bind(console, '[fastdom]') : function() {}; +var debug = process.env.NODE_ENV !== 'production' ? console.log.bind(console, '[fastdom]') : function() {}; /** * Normalized rAF diff --git a/fastdom.min.js b/fastdom.min.js index 7a89e96..492f074 100644 --- a/fastdom.min.js +++ b/fastdom.min.js @@ -1 +1 @@ -!function(t){"use strict";function e(){var e=this;e.reads=[],e.writes=[],e.raf=a.bind(t)}function n(t){t.scheduled||(t.scheduled=!0,t.raf(i.bind(null,t)))}function i(t){var e,i=t.writes,o=t.reads;try{r(o),r(i)}catch(s){e=s}if(t.scheduled=!1,(o.length||i.length)&&n(t),e){if(!t["catch"])throw e;t["catch"](e)}}function r(t){for(var e;e=t.shift();)e.fn.call(e.ctx)}function o(t,e){var n=t.indexOf(e);return!!~n&&!!t.splice(n,1)}function s(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])}var a=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.msRequestAnimationFrame||function(t){return setTimeout(t,16)};e.prototype={constructor:e,measure:function(t,e){var i={fn:t,ctx:e};return this.reads.push(i),n(this),i},mutate:function(t,e){var i={fn:t,ctx:e};return this.writes.push(i),n(this),i},clear:function(t){return o(this.reads,t)||o(this.writes,t)},extend:function(t){if("object"!=typeof t)throw new Error("expected object");var e=Object.create(this);return s(e,t),e.fastdom=this,e.initialize&&e.initialize(),e},"catch":null};var exports=t.fastdom=t.fastdom||new e;"f"==(typeof define)[0]?define(function(){return exports}):"o"==(typeof module)[0]&&(module.exports=exports)}(this); +!function(t){"use strict";function e(){var e=this;e.reads=[],e.writes=[],e.raf=c.bind(t)}function n(t){t.scheduled||(t.scheduled=!0,t.raf(i.bind(null,t)))}function i(t){var e,i=t.writes,o=t.reads;try{r(o),r(i)}catch(s){e=s}if(t.scheduled=!1,(o.length||i.length)&&n(t),e){if(!t["catch"])throw e;t["catch"](e)}}function r(t){for(var e;e=t.shift();)e.fn.call(e.ctx)}function o(t,e){var n=t.indexOf(e);return!!~n&&!!t.splice(n,1)}function s(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])}var c=("production"!==process.env.NODE_ENV?void 0:function(){},t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.msRequestAnimationFrame||function(t){return setTimeout(t,16)});e.prototype={constructor:e,measure:function(t,e){var i={fn:t,ctx:e};return this.reads.push(i),n(this),i},mutate:function(t,e){var i={fn:t,ctx:e};return this.writes.push(i),n(this),i},clear:function(t){return o(this.reads,t)||o(this.writes,t)},extend:function(t){if("object"!=typeof t)throw new Error("expected object");var e=Object.create(this);return s(e,t),e.fastdom=this,e.initialize&&e.initialize(),e},"catch":null};var exports=t.fastdom=t.fastdom||new e;"f"==(typeof define)[0]?define(function(){return exports}):"o"==(typeof module)[0]&&(module.exports=exports)}(this); diff --git a/package.json b/package.json index e2a20cc..01ca422 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "test-dev": "karma start test/karma.conf.js --browsers Firefox", "coveralls": "cat test/coverage/lcov.info | coveralls", "compress": "uglifyjs fastdom.js --compress='drop_console,sequences,dead_code,booleans,conditionals,unused,if_return,join_vars,pure_funcs=\"debug\"' --mangle --reserved='require,define,module,exports' > fastdom.min.js", - "build": "webpack && npm run -s compress", + "build": "NODE_ENV=production webpack && npm run -s compress", "watch": "webpack -w" }, "homepage": "https://github.com/wilsonpage/fastdom", diff --git a/src/fastdom-strict.js b/src/fastdom-strict.js index 86d3f4e..c0a3d51 100644 --- a/src/fastdom-strict.js +++ b/src/fastdom-strict.js @@ -8,7 +8,9 @@ var fastdom = require('../fastdom'); * * @return {Function} */ -var debug = 0 ? console.log.bind(console, '[fastdom-strict]') : function() {}; +var debug = process.env.NODE_ENV !== 'production' ? + console.log.bind(console, '[fastdom-strict]') : + function() {}; /** * Enabled state diff --git a/test/globals.js b/test/globals.js new file mode 100644 index 0000000..4b7de5c --- /dev/null +++ b/test/globals.js @@ -0,0 +1,2 @@ +// global variables for karma +window.process = { env: { NODE_ENV: 'production'} }; \ No newline at end of file diff --git a/test/karma.conf.js b/test/karma.conf.js index d639b36..6dea6fe 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -43,6 +43,7 @@ module.exports = function(config) { }, files: [ + 'test/globals.js', 'fastdom.js', 'extensions/fastdom-promised.js', 'extensions/fastdom-sandbox.js', diff --git a/webpack.config.js b/webpack.config.js index c115fd9..3297841 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,3 +1,5 @@ +var webpack = require('webpack'); + module.exports = [ { entry: './src/fastdom-strict.js', @@ -9,6 +11,14 @@ module.exports = [ externals: { '../fastdom': 'fastdom' - } + }, + + plugins: [ + new webpack.DefinePlugin({ + 'process.env': { + 'NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development') + } + }) + ] } ];