Skip to content

Commit

Permalink
fix(lib): fully remove debug in production (#3485)
Browse files Browse the repository at this point in the history
* fix(lib): fully remove debug in production

* add comment
  • Loading branch information
layershifter authored Mar 10, 2019
1 parent ce521fc commit 5086470
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .babel-preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const plugins = [
'filter-imports',
{
imports: {
debug: ['default'],
'./makeDebugger': ['default'],
'../../lib': ['makeDebugger'],
},
},
Expand Down
7 changes: 5 additions & 2 deletions src/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import makeDebugger from './makeDebugger'

export AutoControlledComponent from './AutoControlledComponent'
export { getChildMapping, mergeChildMappings } from './childMapping'
export * as childrenUtils from './childrenUtils'
Expand All @@ -13,8 +15,6 @@ export {
} from './classNameBuilders'

export * as customPropTypes from './customPropTypes'

export { debug, makeDebugger } from './debug'
export eventStack from './eventStack'

export * from './factories'
Expand All @@ -40,3 +40,6 @@ export normalizeOffset from './normalizeOffset'
export normalizeTransitionDuration from './normalizeTransitionDuration'
export objectDiff from './objectDiff'
export { handleRef, isRefObject } from './refUtils'

// Heads up! We import/export for this module to safely remove it with "babel-plugin-filter-imports"
export { makeDebugger }
14 changes: 4 additions & 10 deletions src/lib/debug.js → src/lib/makeDebugger.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _debug from 'debug'
import debug from 'debug'
import isBrowser from './isBrowser'

if (isBrowser() && process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {
Expand All @@ -18,7 +18,7 @@ if (isBrowser() && process.env.NODE_ENV !== 'production' && process.env.NODE_ENV
}

// enable what ever settings we got from storage
_debug.enable(DEBUG)
debug.enable(DEBUG)
}

/**
Expand All @@ -31,12 +31,6 @@ if (isBrowser() && process.env.NODE_ENV !== 'production' && process.env.NODE_ENV
* debug('Some message')
* @returns {Function}
*/
export const makeDebugger = namespace => _debug(`semanticUIReact:${namespace}`)
const makeDebugger = namespace => debug(`semanticUIReact:${namespace}`)

/**
* Default debugger, simple log.
* @example
* import { debug } from 'src/lib'
* debug('Some message')
*/
export const debug = makeDebugger('log')
export default makeDebugger

0 comments on commit 5086470

Please sign in to comment.