@marko/compiler 5.28.3 → 5.28.4
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/dist/index.js +3 -4
- package/dist/util/build-code-frame.js +26 -25
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -124,7 +124,7 @@ function buildResult(src, filename, errorRecovery, babelResult) {
|
|
|
124
124
|
|
|
125
125
|
for (const diag of meta.diagnostics) {
|
|
126
126
|
if (diag.type === _babelUtils.DiagnosticType.Error) {
|
|
127
|
-
errors.push(diag);
|
|
127
|
+
errors.push((0, _buildCodeFrame.buildCodeFrameError)(filename, src, diag.loc, diag.label));
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -132,13 +132,12 @@ function buildResult(src, filename, errorRecovery, babelResult) {
|
|
|
132
132
|
case 0:
|
|
133
133
|
break;
|
|
134
134
|
case 1:{
|
|
135
|
-
|
|
136
|
-
throw (0, _buildCodeFrame.buildCodeFrameError)(filename, src, diag.loc, diag.label);
|
|
135
|
+
throw errors[0];
|
|
137
136
|
}
|
|
138
137
|
default:{
|
|
139
138
|
let err;
|
|
140
139
|
const message = `${_kleur.default.red("AggregationError:")}\n${errors.
|
|
141
|
-
map((
|
|
140
|
+
map((err) => err.message).
|
|
142
141
|
join("\n\n").
|
|
143
142
|
replace(/^(?!\s*$)/gm, "\t")}\n`;
|
|
144
143
|
|
|
@@ -1,8 +1,33 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.
|
|
1
|
+
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.buildCodeFrameError = buildCodeFrameError;var _path = _interopRequireDefault(require("path"));
|
|
2
2
|
var _kleur = _interopRequireDefault(require("kleur"));
|
|
3
3
|
var _codeFrame = require("@babel/code-frame");
|
|
4
4
|
const CWD = process.cwd();
|
|
5
5
|
|
|
6
|
+
function buildCodeFrameError(
|
|
7
|
+
filename,
|
|
8
|
+
code,
|
|
9
|
+
loc,
|
|
10
|
+
message,
|
|
11
|
+
Error = SyntaxError)
|
|
12
|
+
{
|
|
13
|
+
const err = new Error();
|
|
14
|
+
const codeFrame = buildCodeFrame(filename, code, loc, message);
|
|
15
|
+
|
|
16
|
+
err.loc = loc;
|
|
17
|
+
err.label = message;
|
|
18
|
+
err.stack = ""; // Avoid showing the stack trace for this error.
|
|
19
|
+
|
|
20
|
+
// Prevent babel from changing our error message.
|
|
21
|
+
Object.defineProperty(err, "message", {
|
|
22
|
+
get() {
|
|
23
|
+
return codeFrame;
|
|
24
|
+
},
|
|
25
|
+
set() {}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return err;
|
|
29
|
+
}
|
|
30
|
+
|
|
6
31
|
function buildCodeFrame(filename, code, loc, message) {
|
|
7
32
|
return `${_kleur.default.cyan(_path.default.relative(CWD, filename))}${
|
|
8
33
|
loc ?
|
|
@@ -27,28 +52,4 @@ function buildCodeFrame(filename, code, loc, message) {
|
|
|
27
52
|
}` :
|
|
28
53
|
`: ${message}`
|
|
29
54
|
}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function buildCodeFrameError(
|
|
33
|
-
filename,
|
|
34
|
-
code,
|
|
35
|
-
loc,
|
|
36
|
-
message,
|
|
37
|
-
Error = SyntaxError)
|
|
38
|
-
{
|
|
39
|
-
const err = new Error();
|
|
40
|
-
const codeFrame = buildCodeFrame(filename, code, loc, message);
|
|
41
|
-
|
|
42
|
-
// Avoid showing the stack trace for this error.
|
|
43
|
-
err.stack = "";
|
|
44
|
-
|
|
45
|
-
// Prevent babel from changing our error message.
|
|
46
|
-
Object.defineProperty(err, "message", {
|
|
47
|
-
get() {
|
|
48
|
-
return codeFrame;
|
|
49
|
-
},
|
|
50
|
-
set() {}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
return err;
|
|
54
55
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/compiler",
|
|
3
3
|
"description": "Marko template to JS compiler.",
|
|
4
|
-
"version": "5.28.
|
|
4
|
+
"version": "5.28.4",
|
|
5
5
|
"author": "Dylan Piercey <dpiercey@ebay.com>",
|
|
6
6
|
"bugs": "https://github.com/marko-js/marko/issues/new?template=Bug_report.md",
|
|
7
7
|
"dependencies": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"strip-json-comments": "^3.1.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@marko/translator-default": "^5.26.
|
|
33
|
+
"@marko/translator-default": "^5.26.4"
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
36
|
"dist",
|