From 90da862e6e7ad9fbadacf65f84245fca41d46933 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 8 Oct 2018 19:50:23 +0330 Subject: [PATCH] feat: improve packaging and exports --- package.json | 3 ++- src/index.js | 25 +++++++++++++++++++------ src/reporters/index.js | 15 ++++----------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index d25b66d6..f6ca7dbf 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "release": "standard-version && yarn build && git push --follow-tags && npm publish" }, "files": [ - "dist" + "dist", + "src" ], "keywords": [ "console", diff --git a/src/index.js b/src/index.js index e7256bc6..3c8dc606 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,11 @@ import env from 'std-env' import Consola from './consola' -import Reporters from './reporters' +import { + BasicReporter, + FancyReporter, + JSONReporter, + WinstonReporter +} from './reporters' // Attach consola to the global to prevent // duplicated instances when used with different packages/versions @@ -16,18 +21,26 @@ if (!consola || Consola.prototype.__VERSION__ !== otherVersion) { }) if (env.minimalCLI) { - consola.add(new Reporters.BasicReporter()) + consola.add(new BasicReporter()) } else { - consola.add(new Reporters.FancyReporter()) + consola.add(new FancyReporter()) } - Object.assign(consola, { Consola }, Reporters) + Object.assign(consola, { + Consola, + BasicReporter, + FancyReporter, + JSONReporter, + WinstonReporter + }) - global.consola = consola + if (typeof global !== 'undefined') { + global.consola = consola + } if (otherVersion) { consola.warn( - 'Multiply versions of consola found!', + 'Different versions of consola found!', `${otherVersion} replaced by ${consola.__VERSION__}` ) } diff --git a/src/reporters/index.js b/src/reporters/index.js index 6866822d..c011df69 100644 --- a/src/reporters/index.js +++ b/src/reporters/index.js @@ -1,11 +1,4 @@ -import BasicReporter from './basic' -import FancyReporter from './fancy' -import JSONReporter from './json' -import WinstonReporter from './winston' - -export default { - BasicReporter, - FancyReporter, - JSONReporter, - WinstonReporter -} +export { default as BasicReporter } from './basic' +export { default as FancyReporter } from './fancy' +export { default as JSONReporter } from './json' +export { default as WinstonReporter } from './winston'