Skip to content

Commit f7381c5

Browse files
committedDec 3, 2021
Fix old bundlers and improve browser use
Closes GH-24.
1 parent cd89b71 commit f7381c5

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed
 

‎lib/color.browser.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const color = false

‎lib/color.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import supportsColor from 'supports-color'
2+
3+
/** @type {boolean} */
4+
// @ts-expect-error Types are incorrect.
5+
const color = supportsColor.stderr.hasBasic
6+
7+
export {color}

‎lib/index.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,14 @@
3030
* @property {Sizes} sizes
3131
*/
3232

33-
import supportsColor from 'supports-color'
3433
import width from 'string-width'
3534
import {stringifyPosition} from 'unist-util-stringify-position'
3635
import {statistics} from 'vfile-statistics'
3736
import {sort} from 'vfile-sort'
37+
import {color} from './color.js'
3838

3939
const own = {}.hasOwnProperty
4040

41-
// @ts-expect-error Types are incorrect.
42-
const supported = supportsColor.stderr.hasBasic
43-
4441
// `log-symbols` without chalk, ignored for Windows:
4542
/* c8 ignore next 4 */
4643
const chars =
@@ -162,7 +159,7 @@ function format(map, one, options) {
162159
/** @type {boolean} */
163160
const enabled =
164161
options.color === undefined || options.color === null
165-
? supported
162+
? color
166163
: options.color
167164
/** @type {Array<string>} */
168165
const lines = []

‎package.json

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
"sideEffects": false,
3333
"type": "module",
3434
"main": "index.js",
35+
"browser": {
36+
"./lib/color.js": "./lib/color.browser.js"
37+
},
3538
"types": "index.d.ts",
3639
"files": [
3740
"lib/",

0 commit comments

Comments
 (0)
Please sign in to comment.