From 1dffc59eb2d6a7751750d98e856239dc300b38d8 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Sun, 10 Mar 2019 11:25:31 +0200 Subject: [PATCH 1/2] fix(lib): fully remove debug in production --- .babel-preset.js | 2 +- src/lib/index.js | 6 ++++-- src/lib/{debug.js => makeDebugger.js} | 14 ++++---------- 3 files changed, 9 insertions(+), 13 deletions(-) rename src/lib/{debug.js => makeDebugger.js} (76%) diff --git a/.babel-preset.js b/.babel-preset.js index 1f0be52556..ec786a0795 100644 --- a/.babel-preset.js +++ b/.babel-preset.js @@ -48,7 +48,7 @@ const plugins = [ 'filter-imports', { imports: { - debug: ['default'], + './makeDebugger': ['default'], '../../lib': ['makeDebugger'], }, }, diff --git a/src/lib/index.js b/src/lib/index.js index ab617f151c..b2cdfeb66b 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -1,3 +1,5 @@ +import makeDebugger from './makeDebugger' + export AutoControlledComponent from './AutoControlledComponent' export { getChildMapping, mergeChildMappings } from './childMapping' export * as childrenUtils from './childrenUtils' @@ -13,8 +15,6 @@ export { } from './classNameBuilders' export * as customPropTypes from './customPropTypes' - -export { debug, makeDebugger } from './debug' export eventStack from './eventStack' export * from './factories' @@ -40,3 +40,5 @@ export normalizeOffset from './normalizeOffset' export normalizeTransitionDuration from './normalizeTransitionDuration' export objectDiff from './objectDiff' export { handleRef, isRefObject } from './refUtils' + +export { makeDebugger } diff --git a/src/lib/debug.js b/src/lib/makeDebugger.js similarity index 76% rename from src/lib/debug.js rename to src/lib/makeDebugger.js index dde45373f6..3ac38679ec 100644 --- a/src/lib/debug.js +++ b/src/lib/makeDebugger.js @@ -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') { @@ -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) } /** @@ -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 From 313ea2501d9e0a84813b93157198752900bcb254 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Sun, 10 Mar 2019 11:26:54 +0200 Subject: [PATCH 2/2] add comment --- src/lib/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/index.js b/src/lib/index.js index b2cdfeb66b..8ed65fb4ba 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -41,4 +41,5 @@ 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 }