Skip to content

Commit

Permalink
fix: improve browser packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 9, 2018
1 parent 3842e0e commit 4d8c8d0
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion main/consola.js → index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if (global.consola) {
module.exports = global.consola
} else {
const env = require('std-env')
const { Consola, BasicReporter, FancyReporter } = require('../dist/consola.cjs.js')
const { Consola, BasicReporter, FancyReporter } = require('./dist/consola.cjs.js')

// Log level
let level = env.debug ? 4 : 3
Expand Down
12 changes: 0 additions & 12 deletions main/consola.browser.js

This file was deleted.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
"repository": "nuxt/consola",
"main": "main/consola.js",
"browser": "dist/consola.js",
"side-effects": false,
"scripts": {
"build": "yarn build:cjs && yarn build:browser",
"build:cjs": "bili -t node --format cjs src/index.js",
"build:browser": "bili --format umd main/consola.browser.js",
"build:browser": "bili --format umd src/browser.js",
"lint": "eslint .",
"test": "yarn lint && yarn build && jest test",
"prepublish": "yarn build",
"release": "standard-version && yarn build && git push --follow-tags && npm publish"
},
"files": [
"dist",
"main",
"src"
"src",
"index.js"
],
"keywords": [
"console",
Expand Down
13 changes: 13 additions & 0 deletions src/browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Consola from './consola'
import BrowserReporter from './reporters/browser'

if (!window.consola) {
// Create new consola instance
window.consola = new Consola({
reporters: [
new BrowserReporter()
]
})
}

export default window.consola
4 changes: 2 additions & 2 deletions src/consola.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Types } from './types'
import Types from './types'
import { isLogObj } from './utils'
import { version } from '../package.json'

export class Consola {
export default class Consola {
constructor (options = {}) {
this.reporters = options.reporters || []
this.level = options.level != null ? options.level : 3
Expand Down
14 changes: 3 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
export {
Consola
} from './consola'

export {
Types
} from './types'

export {
isLogObj
} from './utils'
export { default as Consola } from './consola'
export { default as Types } from './types'
export { isLogObj } from './utils'

export * from './reporters'
2 changes: 1 addition & 1 deletion src/types.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const Types = {
export default {
fatal: {
level: 0,
color: 'red'
Expand Down

0 comments on commit 4d8c8d0

Please sign in to comment.