@marko/compiler 5.28.2 → 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.
@@ -233,26 +233,6 @@ function getMarkoFile(code, fileOpts, markoOpts) {
233
233
  file.___compileStage = "migrate";
234
234
  traverseAll(file, rootMigrators);
235
235
 
236
- const { applyFixes } = markoOpts;
237
- if (applyFixes) {
238
- for (let i = 0; i < meta.diagnostics.length; i++) {
239
- const diag = meta.diagnostics[i];
240
- if (diag.fix) {
241
- if (applyFixes.has(i)) {
242
- (typeof diag.fix === "function" ? diag.fix : diag.fix.apply)(
243
- applyFixes.get(i));
244
-
245
- }
246
- }
247
- }
248
- } else {
249
- for (const diag of meta.diagnostics) {
250
- if (diag.fix) {
251
- (typeof diag.fix === "function" ? diag.fix : diag.fix.apply)(undefined);
252
- }
253
- }
254
- }
255
-
256
236
  if (isMigrate) {
257
237
  return file;
258
238
  }
@@ -385,29 +365,4 @@ function isMarkoOutput(output) {
385
365
 
386
366
  function finalizeMeta(meta) {
387
367
  meta.watchFiles = [...new Set(meta.watchFiles)];
388
- meta.diagnostics = meta.diagnostics.map(
389
- ({ type, label, loc, fix: rawFix }) => {
390
- let fix = false;
391
-
392
- switch (typeof rawFix) {
393
- case "function":
394
- fix = true;
395
- break;
396
- case "object":
397
- // strip off the apply function.
398
- ({
399
- // eslint-disable-next-line no-empty-pattern
400
- apply: {},
401
- ...fix
402
- } = rawFix);
403
- break;}
404
-
405
- return {
406
- type,
407
- label,
408
- loc,
409
- fix
410
- };
411
- });
412
-
413
368
  }
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
- const [diag] = errors;
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((diag) => (0, _buildCodeFrame.buildCodeFrame)(filename, src, diag.loc, diag.label)).
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.buildCodeFrame = buildCodeFrame;exports.buildCodeFrameError = buildCodeFrameError;var _path = _interopRequireDefault(require("path"));
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.2",
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": {
@@ -15,7 +15,7 @@
15
15
  "@babel/runtime": "^7.16.0",
16
16
  "@babel/traverse": "^7.16.0",
17
17
  "@babel/types": "^7.16.0",
18
- "@marko/babel-utils": "^5.22.0",
18
+ "@marko/babel-utils": "^5.22.1",
19
19
  "complain": "^1.6.0",
20
20
  "he": "^1.2.0",
21
21
  "htmljs-parser": "^5.4.3",
@@ -30,7 +30,7 @@
30
30
  "strip-json-comments": "^3.1.1"
31
31
  },
32
32
  "devDependencies": {
33
- "@marko/translator-default": "^5.26.2"
33
+ "@marko/translator-default": "^5.26.4"
34
34
  },
35
35
  "files": [
36
36
  "dist",