Skip to content

Commit 7b0f838

Browse files
author
pooya parsa
committedFeb 23, 2019
fix: bundle std-env and entrypoint
1 parent a86359d commit 7b0f838

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed
 

‎package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"browser": "dist/consola.browser.js",
99
"typings": "types/consola.d.ts",
1010
"scripts": {
11-
"build": "rm -rf dist && yarn build:cjs && yarn build:browser && rm dist/*.map",
12-
"build:cjs": "bili --file-name consola.js --format cjs --bundle-node-modules --minify src/index.js",
11+
"build": "rm -rf dist && yarn build:node && yarn build:browser && rm dist/*.map",
12+
"build:node": "bili --file-name consola.js --format cjs --bundle-node-modules --minify src/node.js",
1313
"build:browser": "bili --file-name consola.browser.js --format umd --module-name consola --bundle-node-modules --minify src/browser.js",
1414
"demo": "node demo",
1515
"browser": "serve",
@@ -21,7 +21,6 @@
2121
},
2222
"files": [
2323
"dist",
24-
"consola.js",
2524
"types"
2625
],
2726
"keywords": [

‎consola.js renamed to ‎src/node.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
if (global.consola) {
2-
module.exports = global.consola
3-
} else {
4-
const env = require('std-env')
5-
const { Consola, BasicReporter, FancyReporter } = require('./dist/consola.js')
1+
import env from 'std-env'
2+
import { Consola, BasicReporter, FancyReporter } from '.'
63

4+
function createConsola () {
75
// Log level
86
let level = env.debug ? 4 : 3
97
if (process.env['CONSOLA_LEVEL']) {
108
level = parseInt(process.env['CONSOLA_LEVEL']) || level
119
}
1210

1311
// Create new consola instance
14-
module.exports = global.consola = new Consola({
12+
return new Consola({
1513
level,
1614
reporters: [
1715
(env.ci || env.test)
@@ -20,3 +18,9 @@ if (global.consola) {
2018
]
2119
})
2220
}
21+
22+
if (!global.consola) {
23+
global.consola = createConsola()
24+
}
25+
26+
export default global.consola

0 commit comments

Comments
 (0)
Please sign in to comment.