diff --git a/README.md b/README.md index 4850b129d7..b0cbd184f0 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/build/preset-es2015.js b/build/preset-es2015.js index 582444e6af..da094e5cda 100644 --- a/build/preset-es2015.js +++ b/build/preset-es2015.js @@ -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, } diff --git a/package.json b/package.json index 91a31044fa..ab82771d16 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" }, @@ -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", @@ -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", diff --git a/src/lib/debug.js b/src/lib/debug.js index 98dbc03861..7bb1db8574 100644 --- a/src/lib/debug.js +++ b/src/lib/debug.js @@ -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 @@ -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 } /** diff --git a/src/modules/Dropdown/Dropdown.js b/src/modules/Dropdown/Dropdown.js index 0b53ce8e4b..8c0d7091f9 100644 --- a/src/modules/Dropdown/Dropdown.js +++ b/src/modules/Dropdown/Dropdown.js @@ -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 */ @@ -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 diff --git a/src/modules/Search/Search.js b/src/modules/Search/Search.js index 1231e6463a..80eb9ef3c8 100644 --- a/src/modules/Search/Search.js +++ b/src/modules/Search/Search.js @@ -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)) { @@ -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