Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(lib): fully remove debug in production #3485

Merged
merged 3 commits into from
Mar 10, 2019
Merged
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 .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