@parcel/utils 2.5.0 → 2.6.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/lib/index.js +3190 -3308
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
- package/src/prettyDiagnostic.js +17 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.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.
|
|
37
|
-
"@parcel/diagnostic": "2.
|
|
38
|
-
"@parcel/hash": "2.
|
|
39
|
-
"@parcel/logger": "2.
|
|
40
|
-
"@parcel/markdown-ansi": "2.
|
|
36
|
+
"@parcel/codeframe": "2.6.0",
|
|
37
|
+
"@parcel/diagnostic": "2.6.0",
|
|
38
|
+
"@parcel/hash": "2.6.0",
|
|
39
|
+
"@parcel/logger": "2.6.0",
|
|
40
|
+
"@parcel/markdown-ansi": "2.6.0",
|
|
41
41
|
"@parcel/source-map": "^2.0.0",
|
|
42
42
|
"chalk": "^4.1.0"
|
|
43
43
|
},
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"./src/http-server.js": false,
|
|
64
64
|
"./src/openInBrowser.js": false
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "f2d0a3a27d6e493b23ddc2edbc8a4c0053ff34ab"
|
|
67
67
|
}
|
package/src/prettyDiagnostic.js
CHANGED
|
@@ -10,10 +10,18 @@ import nullthrows from 'nullthrows';
|
|
|
10
10
|
// $FlowFixMe
|
|
11
11
|
import terminalLink from 'terminal-link';
|
|
12
12
|
|
|
13
|
+
export type FormattedCodeFrame = {|
|
|
14
|
+
location: string,
|
|
15
|
+
code: string,
|
|
16
|
+
|};
|
|
17
|
+
|
|
13
18
|
export type AnsiDiagnosticResult = {|
|
|
14
19
|
message: string,
|
|
15
20
|
stack: string,
|
|
21
|
+
/** A formatted string containing all code frames, including their file locations. */
|
|
16
22
|
codeframe: string,
|
|
23
|
+
/** A list of code frames with highlighted code and file locations separately. */
|
|
24
|
+
frames: Array<FormattedCodeFrame>,
|
|
17
25
|
hints: Array<string>,
|
|
18
26
|
documentation: string,
|
|
19
27
|
|};
|
|
@@ -39,6 +47,7 @@ export default async function prettyDiagnostic(
|
|
|
39
47
|
(skipFormatting ? message : mdAnsi(message)),
|
|
40
48
|
stack: '',
|
|
41
49
|
codeframe: '',
|
|
50
|
+
frames: [],
|
|
42
51
|
hints: [],
|
|
43
52
|
documentation: '',
|
|
44
53
|
};
|
|
@@ -69,16 +78,20 @@ export default async function prettyDiagnostic(
|
|
|
69
78
|
});
|
|
70
79
|
}
|
|
71
80
|
|
|
72
|
-
|
|
81
|
+
let location =
|
|
73
82
|
typeof filePath !== 'string'
|
|
74
83
|
? ''
|
|
75
|
-
:
|
|
76
|
-
|
|
77
|
-
);
|
|
84
|
+
: `${filePath}:${highlights[0].start.line}:${highlights[0].start.column}`;
|
|
85
|
+
result.codeframe += location ? chalk.gray.underline(location) + '\n' : '';
|
|
78
86
|
result.codeframe += formattedCodeFrame;
|
|
79
87
|
if (codeFrame !== codeFrames[codeFrames.length - 1]) {
|
|
80
88
|
result.codeframe += '\n\n';
|
|
81
89
|
}
|
|
90
|
+
|
|
91
|
+
result.frames.push({
|
|
92
|
+
location,
|
|
93
|
+
code: formattedCodeFrame,
|
|
94
|
+
});
|
|
82
95
|
}
|
|
83
96
|
}
|
|
84
97
|
|