@marko/compiler 5.34.0 → 5.34.2

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.
@@ -203,16 +203,16 @@ function parseMarko(file) {
203
203
  currentTag.node.typeArguments = (0, _babelUtils.parseTypeArgs)(
204
204
  file,
205
205
  parser.read(part.value),
206
- part.start,
207
- part.end
206
+ part.value.start,
207
+ part.value.end
208
208
  );
209
209
  },
210
210
  onTagTypeParams(part) {
211
211
  currentBody.node.typeParameters = (0, _babelUtils.parseTypeParams)(
212
212
  file,
213
213
  parser.read(part.value),
214
- part.start,
215
- part.end
214
+ part.value.start,
215
+ part.value.end
216
216
  );
217
217
  },
218
218
  onPlaceholder(part) {
@@ -4,16 +4,6 @@ var t = _interopRequireWildcard(require("@babel/types"));
4
4
  var _selfClosingTags = _interopRequireDefault(require("self-closing-tags"));
5
5
  var _printer = _interopRequireDefault(require("@babel/generator/lib/printer"));function _getRequireWildcardCache(nodeInterop) {if (typeof WeakMap !== "function") return null;var cacheBabelInterop = new WeakMap();var cacheNodeInterop = new WeakMap();return (_getRequireWildcardCache = function (nodeInterop) {return nodeInterop ? cacheNodeInterop : cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj, nodeInterop) {if (!nodeInterop && obj && obj.__esModule) {return obj;}if (obj === null || typeof obj !== "object" && typeof obj !== "function") {return { default: obj };}var cache = _getRequireWildcardCache(nodeInterop);if (cache && cache.has(obj)) {return cache.get(obj);}var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {Object.defineProperty(newObj, key, desc);} else {newObj[key] = obj[key];}}}newObj.default = obj;if (cache) {cache.set(obj, newObj);}return newObj;}
6
6
 
7
- const UNENCLOSED_WHITESPACE_TYPES = [
8
- "LogicalExpression",
9
- "AssignmentExpression",
10
- "ConditionalExpression",
11
- "BinaryExpression",
12
- "NewExpression",
13
- "Function",
14
- "AssignmentExpression"];
15
-
16
-
17
7
  Object.assign(_printer.default.prototype, {
18
8
  MarkoParseError(node) {
19
9
  this.token(node.source);
@@ -61,7 +51,10 @@ Object.assign(_printer.default.prototype, {
61
51
 
62
52
  this.token(`${node.static ? "static" : "$"} `);
63
53
 
64
- if (node.body.length === 1) {
54
+ if (
55
+ node.body.length === 1 &&
56
+ !statementCouldHaveUnenclosedNewline(node.body[0]))
57
+ {
65
58
  // TODO should determine if node has unenclosed newlines.
66
59
  this.print(node.body[0], node);
67
60
  } else {
@@ -242,7 +235,7 @@ function spaceSeparator() {
242
235
  }
243
236
 
244
237
  function printWithParansIfNeeded(value, parent) {
245
- const needsParans = hasUnenclosedWhitespace(value);
238
+ const needsParans = expressionCouldHaveUnenclosedWhitespace(value);
246
239
 
247
240
  if (needsParans) {
248
241
  this.token("(");
@@ -255,6 +248,25 @@ function printWithParansIfNeeded(value, parent) {
255
248
  }
256
249
  }
257
250
 
258
- function hasUnenclosedWhitespace(node) {
259
- return UNENCLOSED_WHITESPACE_TYPES.includes(node.type);
251
+ function expressionCouldHaveUnenclosedWhitespace(node) {
252
+ switch (node.type) {
253
+ case "AssignmentExpression":
254
+ case "BinaryExpression":
255
+ case "ConditionalExpression":
256
+ case "Function":
257
+ case "LogicalExpression":
258
+ case "NewExpression":
259
+ return true;
260
+ default:
261
+ return false;
262
+ }
263
+ }
264
+
265
+ function statementCouldHaveUnenclosedNewline(node) {
266
+ switch (node.type) {
267
+ case "VariableDeclaration":
268
+ return node.declarations.length > 1;
269
+ default:
270
+ return false;
271
+ }
260
272
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/compiler",
3
- "version": "5.34.0",
3
+ "version": "5.34.2",
4
4
  "description": "Marko template to JS compiler.",
5
5
  "keywords": [
6
6
  "babel",
@@ -61,7 +61,7 @@
61
61
  "strip-json-comments": "^3.1.1"
62
62
  },
63
63
  "devDependencies": {
64
- "@marko/translator-default": "^5.31.8"
64
+ "@marko/translator-default": "^5.31.9"
65
65
  },
66
66
  "publishConfig": {
67
67
  "access": "public"