Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added NODE_ENV to configure debug mode #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extensions/fastdom-sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to throw if users aren't using webpack/browserify


/**
* Exports
Expand Down
2 changes: 1 addition & 1 deletion fastdom-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this different to the change in /fastdom.js?


/**
* Enabled state
Expand Down
2 changes: 1 addition & 1 deletion fastdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to throw if users aren't using webpack/browserify.


/**
* Normalized rAF
Expand Down
2 changes: 1 addition & 1 deletion fastdom.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/fastdom-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// global variables for karma
window.process = { env: { NODE_ENV: 'production'} };
1 change: 1 addition & 0 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module.exports = function(config) {
},

files: [
'test/globals.js',
'fastdom.js',
'extensions/fastdom-promised.js',
'extensions/fastdom-sandbox.js',
Expand Down
12 changes: 11 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var webpack = require('webpack');

module.exports = [
{
entry: './src/fastdom-strict.js',
Expand All @@ -9,6 +11,14 @@ module.exports = [

externals: {
'../fastdom': 'fastdom'
}
},

plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}
})
]
}
];