Skip to content

Commit

Permalink
chore(debug): remove debug from builds (#2058)
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter authored and Alexander Fedyashov committed Sep 11, 2017
1 parent 416a7bc commit ccac471
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 28 deletions.
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,6 @@ We're seeking component parity with Semantic UI, plus some addons. There is an

Any other issue labeled [`help wanted`][4] is ready for a PR.

## Debugger

We use the [debug](https://www.npmjs.com/package/debug) module for debugging. You can turn debugging on and off via the `localStorage.debug` flag from the browser console. See the [debug docs](https://www.npmjs.com/package/debug) for more.

```js
localStorage.debug = 'semanticUIReact:*' // default, debug all components
localStorage.debug = 'semanticUIReact:dropdown' // debug only the dropdown
localStorage.debug = null // turn debug off
```

Once you change the flag, you need to refresh your browser to see the changes in debug output.

## Support

| Elements | Collections | Views | Modules | Behaviors |
Expand Down
12 changes: 11 additions & 1 deletion build/preset-es2015.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
const options = process.env.BABEL_ENV === 'es' ? { modules: false } : {}
const env = process.env.NODE_ENV
const options = env === 'build-es' ? { modules: false } : {}
const plugins = env === 'build' || env === 'build-es' ? [
['filter-imports', {
imports: {
debug: ['default'],
'../../lib': ['makeDebugger'],
},
}],
] : []

module.exports = {
presets: [
['es2015', options],
],
plugins,
}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"docs": "gulp docs",
"build": "npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:docs",
"prebuild:commonjs": "rimraf dist/commonjs",
"build:commonjs": "babel src -d dist/commonjs && npm run tsd",
"build:commonjs": "cross-env NODE_ENV=build babel src -d dist/commonjs && npm run tsd",
"prebuild:es": "rimraf dist/es",
"build:es": "cross-env BABEL_ENV=es babel src -d dist/es",
"build:es": "cross-env NODE_ENV=build-es babel src -d dist/es",
"prebuild:docs": "npm run build:docs-toc",
"build:dll": "gulp dll",
"build:docs": "gulp build:docs",
"build:umd": "gulp umd",
"build:umd": "cross-env NODE_ENV=build gulp umd",
"build:docs-toc": "doctoc ./.github/CONTRIBUTING.md --github --maxlevel 4",
"build:docs-cname": "echo react.semantic-ui.com > docs/build/CNAME",
"predeploy:docs": "cross-env NODE_ENV=production npm run build:docs && npm run build:docs-cname",
Expand Down Expand Up @@ -56,7 +56,6 @@
"dependencies": {
"babel-runtime": "^6.25.0",
"classnames": "^2.2.5",
"debug": "^3.0.0",
"lodash": "^4.17.4",
"prop-types": "^15.5.10"
},
Expand All @@ -66,6 +65,7 @@
"babel-core": "^6.25.0",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.1.1",
"babel-plugin-filter-imports": "^1.0.3",
"babel-plugin-istanbul": "^4.1.4",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-transform-react-handled-props": "^0.2.5",
Expand All @@ -81,6 +81,7 @@
"connect-history-api-fallback": "^1.3.0",
"copy-to-clipboard": "^3.0.8",
"cross-env": "^5.0.5",
"debug": "^3.0.1",
"dirty-chai": "^2.0.1",
"doctoc": "^1.3.0",
"doctrine": "^2.0.0",
Expand Down
8 changes: 1 addition & 7 deletions src/lib/debug.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import _debug from 'debug'
import isBrowser from './isBrowser'

let _debug
const noop = () => undefined

if (isBrowser && process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {
// Heads Up!
// https://github.com/visionmedia/debug/pull/331
Expand All @@ -19,12 +17,8 @@ if (isBrowser && process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !
/* eslint-enable no-console */
}

_debug = require('debug')

// enable what ever settings we got from storage
_debug.enable(DEBUG)
} else {
_debug = () => noop
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/modules/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ export default class Dropdown extends Component {
componentWillReceiveProps(nextProps) {
super.componentWillReceiveProps(nextProps)
debug('componentWillReceiveProps()')
// TODO objectDiff still runs in prod, stop it
debug('to props:', objectDiff(this.props, nextProps))

/* eslint-disable no-console */
Expand Down Expand Up @@ -424,7 +423,6 @@ export default class Dropdown extends Component {

componentDidUpdate(prevProps, prevState) { // eslint-disable-line complexity
debug('componentDidUpdate()')
// TODO objectDiff still runs in prod, stop it
debug('to state:', objectDiff(prevState, this.state))

// focused / blurred
Expand Down
2 changes: 0 additions & 2 deletions src/modules/Search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ export default class Search extends Component {
componentWillReceiveProps(nextProps) {
super.componentWillReceiveProps(nextProps)
debug('componentWillReceiveProps()')
// TODO objectDiff still runs in prod, stop it
debug('changed props:', objectDiff(nextProps, this.props))

if (!_.isEqual(nextProps.value, this.props.value)) {
Expand All @@ -228,7 +227,6 @@ export default class Search extends Component {

componentDidUpdate(prevProps, prevState) { // eslint-disable-line complexity
debug('componentDidUpdate()')
// TODO objectDiff still runs in prod, stop it
debug('to state:', objectDiff(prevState, this.state))

// focused / blurred
Expand Down

0 comments on commit ccac471

Please sign in to comment.