@parcel/utils 2.10.2 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/utils",
3
- "version": "2.10.2",
3
+ "version": "2.11.0",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -33,11 +33,11 @@
33
33
  }
34
34
  },
35
35
  "dependencies": {
36
- "@parcel/codeframe": "2.10.2",
37
- "@parcel/diagnostic": "2.10.2",
38
- "@parcel/logger": "2.10.2",
39
- "@parcel/markdown-ansi": "2.10.2",
40
- "@parcel/rust": "2.10.2",
36
+ "@parcel/codeframe": "2.11.0",
37
+ "@parcel/diagnostic": "2.11.0",
38
+ "@parcel/logger": "2.11.0",
39
+ "@parcel/markdown-ansi": "2.11.0",
40
+ "@parcel/rust": "2.11.0",
41
41
  "@parcel/source-map": "^2.1.1",
42
42
  "chalk": "^4.1.0",
43
43
  "nullthrows": "^1.1.1"
@@ -57,13 +57,15 @@
57
57
  "nullthrows": "^1.1.1",
58
58
  "open": "^7.0.3",
59
59
  "random-int": "^1.0.0",
60
+ "snarkdown": "^2.0.0",
60
61
  "strip-ansi": "^6.0.0",
61
62
  "terminal-link": "^2.1.1"
62
63
  },
63
64
  "browser": {
64
65
  "./src/generateCertificate.js": false,
65
66
  "./src/http-server.js": false,
66
- "./src/openInBrowser.js": false
67
+ "./src/openInBrowser.js": false,
68
+ "@parcel/markdown-ansi": false
67
69
  },
68
- "gitHead": "a1391ed8a719fc2f976dbadb528ca2dcffa7da12"
70
+ "gitHead": "f8076f1644cabc944695b5ec82602c8ae32bcf21"
69
71
  }
@@ -3,11 +3,16 @@ import type {Diagnostic} from '@parcel/diagnostic';
3
3
  import type {PluginOptions} from '@parcel/types';
4
4
 
5
5
  import formatCodeFrame from '@parcel/codeframe';
6
- import mdAnsi from '@parcel/markdown-ansi';
7
- import chalk from 'chalk';
6
+ import _mdAnsi from '@parcel/markdown-ansi';
7
+ import _chalk from 'chalk';
8
8
  import path from 'path';
9
9
  // $FlowFixMe
10
- import terminalLink from 'terminal-link';
10
+ import _terminalLink from 'terminal-link';
11
+
12
+ /* eslint-disable import/no-extraneous-dependencies */
13
+ // $FlowFixMe
14
+ import snarkdown from 'snarkdown';
15
+ /* eslint-enable import/no-extraneous-dependencies */
11
16
 
12
17
  export type FormattedCodeFrame = {|
13
18
  location: string,
@@ -29,6 +34,7 @@ export default async function prettyDiagnostic(
29
34
  diagnostic: Diagnostic,
30
35
  options?: PluginOptions,
31
36
  terminalWidth?: number,
37
+ format: 'ansi' | 'html' = 'ansi',
32
38
  ): Promise<AnsiDiagnosticResult> {
33
39
  let {
34
40
  origin,
@@ -40,10 +46,26 @@ export default async function prettyDiagnostic(
40
46
  documentationURL,
41
47
  } = diagnostic;
42
48
 
49
+ const md = format === 'ansi' ? _mdAnsi : snarkdown;
50
+ const terminalLink =
51
+ format === 'ansi'
52
+ ? _terminalLink
53
+ : // eslint-disable-next-line no-unused-vars
54
+ (text, url, _) => `<a href="${url}">${text}</a>`;
55
+ const chalk =
56
+ format === 'ansi'
57
+ ? _chalk
58
+ : {
59
+ gray: {
60
+ underline: v =>
61
+ `<span style="color: grey; text-decoration: underline;">${v}</span>`,
62
+ },
63
+ };
64
+
43
65
  let result = {
44
66
  message:
45
- mdAnsi(`**${origin ?? 'unknown'}**: `) +
46
- (skipFormatting ? message : mdAnsi(message)),
67
+ md(`**${origin ?? 'unknown'}**: `) +
68
+ (skipFormatting ? message : md(message)),
47
69
  stack: '',
48
70
  codeframe: '',
49
71
  frames: [],
@@ -104,7 +126,7 @@ export default async function prettyDiagnostic(
104
126
 
105
127
  if (Array.isArray(hints) && hints.length) {
106
128
  result.hints = hints.map(h => {
107
- return mdAnsi(h);
129
+ return md(h);
108
130
  });
109
131
  }
110
132