@marko/compiler 5.28.3 → 5.28.5

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.
@@ -53,6 +53,7 @@ const SOURCE_FILES = new WeakMap();var _default =
53
53
  opts.parserOpts.allowReturnOutsideFunction =
54
54
  opts.parserOpts.allowSuperOutsideMethod =
55
55
  opts.parserOpts.allowUndeclaredExports =
56
+ opts.parserOpts.allowNewTargetOutsideFunction =
56
57
  true;
57
58
  curOpts = opts;
58
59
  },
package/dist/index.js CHANGED
@@ -65,14 +65,14 @@ function loadMarkoConfig(config) {
65
65
  const markoConfig = { ...globalConfig, ...config };
66
66
 
67
67
  if (markoConfig.stripTypes === undefined) {
68
- markoConfig.stripTypes =
69
- markoConfig.output !== "source" && markoConfig.output !== "migrate";
68
+ markoConfig.stripTypes = isTranslatedOutput(markoConfig.output);
70
69
  }
71
70
 
72
71
  return markoConfig;
73
72
  }
74
73
 
75
74
  function loadBabelConfig(filename, { babelConfig, ...markoConfig }) {
75
+ const isTranslated = isTranslatedOutput(markoConfig.output);
76
76
  const requiredPlugins = [
77
77
  [_babelPlugin.default, markoConfig],
78
78
  [
@@ -92,23 +92,29 @@ function loadBabelConfig(filename, { babelConfig, ...markoConfig }) {
92
92
  _path.default.relative(process.cwd(), filename) :
93
93
  undefined,
94
94
  sourceFileName: filename ? _path.default.basename(filename) : undefined,
95
+ configFile: isTranslated,
96
+ babelrc: isTranslated,
95
97
  ...babelConfig,
96
98
  filename,
97
99
  sourceType: "module",
98
100
  sourceMaps: markoConfig.sourceMaps,
99
101
  code: markoConfig.code,
100
- ast: markoConfig.ast
102
+ ast: markoConfig.ast,
103
+ plugins:
104
+ babelConfig && babelConfig.plugins ?
105
+ requiredPlugins.concat(babelConfig.plugins) :
106
+ requiredPlugins
101
107
  };
102
108
 
103
- if (markoConfig.modules === "cjs") {
104
- requiredPlugins.push([_pluginTransformModulesCommonjs.default, { loose: true }]);
105
- }
106
-
107
- baseBabelConfig.plugins = requiredPlugins.concat(
108
- baseBabelConfig.plugins || []);
109
+ if (isTranslated) {
110
+ if (markoConfig.modules === "cjs") {
111
+ baseBabelConfig.plugins.push([_pluginTransformModulesCommonjs.default, { loose: true }]);
112
+ }
109
113
 
114
+ return babel.loadPartialConfig(baseBabelConfig).options;
115
+ }
110
116
 
111
- return babel.loadPartialConfig(baseBabelConfig).options;
117
+ return baseBabelConfig;
112
118
  }
113
119
 
114
120
  function buildResult(src, filename, errorRecovery, babelResult) {
@@ -124,7 +130,7 @@ function buildResult(src, filename, errorRecovery, babelResult) {
124
130
 
125
131
  for (const diag of meta.diagnostics) {
126
132
  if (diag.type === _babelUtils.DiagnosticType.Error) {
127
- errors.push(diag);
133
+ errors.push((0, _buildCodeFrame.buildCodeFrameError)(filename, src, diag.loc, diag.label));
128
134
  }
129
135
  }
130
136
 
@@ -132,13 +138,12 @@ function buildResult(src, filename, errorRecovery, babelResult) {
132
138
  case 0:
133
139
  break;
134
140
  case 1:{
135
- const [diag] = errors;
136
- throw (0, _buildCodeFrame.buildCodeFrameError)(filename, src, diag.loc, diag.label);
141
+ throw errors[0];
137
142
  }
138
143
  default:{
139
144
  let err;
140
145
  const message = `${_kleur.default.red("AggregationError:")}\n${errors.
141
- map((diag) => (0, _buildCodeFrame.buildCodeFrame)(filename, src, diag.loc, diag.label)).
146
+ map((err) => err.message).
142
147
  join("\n\n").
143
148
  replace(/^(?!\s*$)/gm, "\t")}\n`;
144
149
 
@@ -181,4 +186,8 @@ function isDefaultCache(config) {
181
186
 
182
187
  function getFs(config) {
183
188
  return config.fileSystem || globalConfig.fileSystem;
189
+ }
190
+
191
+ function isTranslatedOutput(output) {
192
+ return output !== "source" && output !== "migrate";
184
193
  }
@@ -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.3",
4
+ "version": "5.28.5",
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.3"
33
+ "@marko/translator-default": "^5.26.5"
34
34
  },
35
35
  "files": [
36
36
  "dist",