@marko/compiler 5.39.49 → 5.39.50

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.
@@ -64,17 +64,20 @@ let stripTypesVisitor;var _default =
64
64
  return {
65
65
  name: "marko",
66
66
  manipulateOptions(opts) {
67
+ const { parserOpts } = opts;
67
68
  // We need to allow these for now since we are not parsing the entire file
68
69
  // These types of syntax errors will be picked up by the bundler / runtime anyways.
69
- opts.parserOpts.allowAwaitOutsideFunction =
70
- opts.parserOpts.allowImportExportEverywhere =
71
- opts.parserOpts.allowReturnOutsideFunction =
72
- opts.parserOpts.allowSuperOutsideMethod =
73
- opts.parserOpts.allowUndeclaredExports =
74
- opts.parserOpts.allowNewTargetOutsideFunction =
70
+ parserOpts.allowAwaitOutsideFunction =
71
+ parserOpts.allowImportExportEverywhere =
72
+ parserOpts.allowReturnOutsideFunction =
73
+ parserOpts.allowSuperOutsideMethod =
74
+ parserOpts.allowUndeclaredExports =
75
+ parserOpts.allowNewTargetOutsideFunction =
76
+ parserOpts.createParenthesizedExpressions =
77
+ parserOpts.createImportExpressions =
75
78
  true;
76
79
 
77
- opts.parserOpts.plugins.push("objectRestSpread", "classProperties", [
80
+ parserOpts.plugins.push("objectRestSpread", "classProperties", [
78
81
  "typescript",
79
82
  {
80
83
  disallowAmbiguousJSXLike: false,
@@ -1,10 +1,5 @@
1
- "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");require("../types/patch");
2
-
3
- var _printer = _interopRequireDefault(require("@babel/generator/lib/printer"));
4
- var t = _interopRequireWildcard(require("@babel/types"));
5
- var _selfClosingTags = _interopRequireDefault(require("self-closing-tags"));function _interopRequireWildcard(e, t) {if ("function" == typeof WeakMap) var r = new WeakMap(),n = new WeakMap();return (_interopRequireWildcard = function (e, t) {if (!t && e && e.__esModule) return e;var o,i,f = { __proto__: null, default: e };if (null === e || "object" != typeof e && "function" != typeof e) return f;if (o = t ? n : r) {if (o.has(e)) return o.get(e);o.set(e, f);}for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);return f;})(e, t);}
6
-
7
- Object.assign(_printer.default.prototype, {
1
+ "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");var _selfClosingTags = _interopRequireDefault(require("self-closing-tags"));
2
+ Object.assign(require("@babel/generator/lib/generators/template-literals"), {
8
3
  MarkoParseError(node) {
9
4
  this.token(node.source);
10
5
  },
@@ -29,26 +24,16 @@ Object.assign(_printer.default.prototype, {
29
24
  this.token("-->");
30
25
  },
31
26
  MarkoPlaceholder(node, parent) {
32
- if (parent) {
33
- const parentBody = getBody(parent);
34
- const prev = parentBody[parentBody.indexOf(node) - 1];
27
+ const isRootLevel = parent.type === "Program";
35
28
 
36
- if (prev && (t.isMarkoText(prev) || t.isMarkoPlaceholder(prev))) {
37
- this.removeTrailingNewline();
38
- }
29
+ if (isRootLevel) {
30
+ this.token("-- ");
39
31
  }
40
-
41
32
  this.token(node.escape ? "${" : "$!{");
42
- this.print(node.value);
33
+ this.print(node.value, true, true);
43
34
  this.token("}");
44
35
  },
45
36
  MarkoScriptlet(node, parent) {
46
- this.removeTrailingNewline();
47
-
48
- if (!(t.isProgram(parent) && getBody(parent)[0] === node)) {
49
- this.token("\n");
50
- }
51
-
52
37
  this.token(`${node.static ? node.target ?? "static" : "$"} `);
53
38
 
54
39
  if (
@@ -56,20 +41,17 @@ Object.assign(_printer.default.prototype, {
56
41
  !statementCouldHaveUnenclosedNewline(node.body[0]))
57
42
  {
58
43
  // TODO should determine if node has unenclosed newlines.
59
- this.print(node.body[0]);
44
+ this.print(node.body[0], false, true);
60
45
  } else {
61
46
  this.token("{");
62
- this.newline();
63
- this.indent();
64
- this.printSequence(node.body);
65
- this.dedent();
47
+ this.printSequence(node.body, true, true);
66
48
  this.token("}");
67
49
  }
68
50
  },
69
51
  MarkoClass(node) {
70
52
  this.token("class");
71
53
  this.token(" ");
72
- this.print(node.body);
54
+ this.print(node.body, true, true);
73
55
  },
74
56
  MarkoAttribute(node) {
75
57
  const value = node.value;
@@ -89,15 +71,18 @@ Object.assign(_printer.default.prototype, {
89
71
  }
90
72
  }
91
73
 
92
- if (node.default || !t.isBooleanLiteral(value, { value: true })) {
74
+ if (
75
+ node.default ||
76
+ !(node.value.type === "BooleanLiteral" && node.value.value))
77
+ {
93
78
  if (
94
- t.isFunctionExpression(value) &&
79
+ value.type === "FunctionExpression" &&
95
80
  !(value.id || value.async || value.generator))
96
81
  {
97
82
  this.token("(");
98
83
  this.printList(value.params);
99
- this.token(") ");
100
- this.print(value.body);
84
+ this.token(")");
85
+ this.printBlock(value.body);
101
86
  } else {
102
87
  this.token(node.bound ? ":=" : "=");
103
88
  printWithParansIfNeeded.call(this, value);
@@ -109,17 +94,10 @@ Object.assign(_printer.default.prototype, {
109
94
  printWithParansIfNeeded.call(this, node.value);
110
95
  },
111
96
  MarkoText(node, parent) {
112
- const parentBody = getBody(parent);
113
- const prev = parentBody[parentBody.indexOf(node) - 1];
114
- const concatToPrev = prev && t.isMarkoPlaceholder(prev);
115
- let { value } = node;
116
-
117
- if (concatToPrev) {
118
- this.removeTrailingNewline();
119
- }
97
+ const { value } = node;
120
98
 
121
99
  const isMultiLine = /[\r\n]/g.test(value);
122
- const isRootLevel = !concatToPrev && t.isProgram(parent);
100
+ const isRootLevel = parent.type === "Program";
123
101
 
124
102
  if (isRootLevel) {
125
103
  if (isMultiLine) {
@@ -136,10 +114,10 @@ Object.assign(_printer.default.prototype, {
136
114
  }
137
115
  },
138
116
  MarkoTagBody(node) {
139
- this.printSequence(node.body, true);
117
+ this.printSequence(node.body);
140
118
  },
141
119
  MarkoTag(node) {
142
- const isDynamicTag = !t.isStringLiteral(node.name);
120
+ const isDynamicTag = node.name.type !== "StringLiteral";
143
121
  const tagName = !isDynamicTag && node.name.value;
144
122
  const rawValue = node.rawValue;
145
123
  let bodyOverride;
@@ -159,7 +137,7 @@ Object.assign(_printer.default.prototype, {
159
137
  } else {
160
138
  if (isDynamicTag) {
161
139
  this.token("${");
162
- this.print(node.name);
140
+ this.print(node.name, true, true);
163
141
  this.token("}");
164
142
  } else {
165
143
  this.token(tagName);
@@ -173,10 +151,10 @@ Object.assign(_printer.default.prototype, {
173
151
 
174
152
  if (node.var) {
175
153
  this.token("/");
176
- this.print(node.var);
154
+ this.print(node.var, true, true);
177
155
 
178
156
  if (node.var.typeAnnotation) {
179
- this.print(node.var.typeAnnotation);
157
+ this.print(node.var.typeAnnotation, true, true);
180
158
  }
181
159
  }
182
160
 
@@ -239,8 +217,11 @@ Object.assign(_printer.default.prototype, {
239
217
  this.token("/>");
240
218
  } else {
241
219
  this.token(">");
242
- this.newline();
243
- this.printSequence(bodyOverride || zipAttributeTagsAndBody(node), true);
220
+ this.printSequence(
221
+ bodyOverride || zipAttributeTagsAndBody(node),
222
+ true,
223
+ true
224
+ );
244
225
  this.token("</");
245
226
  if (!isDynamicTag) {
246
227
  this.token(tagName);
@@ -261,7 +242,7 @@ function printWithParansIfNeeded(value) {
261
242
  this.token("(");
262
243
  }
263
244
 
264
- this.print(value);
245
+ this.print(value, true, true);
265
246
 
266
247
  if (needsParans) {
267
248
  this.token(")");
@@ -1,4 +1,6 @@
1
1
  "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2
+ require("../generator/patch");
3
+
2
4
  var babelTypes = _interopRequireWildcard(require("@babel/types"));
3
5
  var definitionUtils = _interopRequireWildcard(require("@babel/types/lib/definitions/utils"));
4
6
  var generatedValidators = _interopRequireWildcard(require("@babel/types/lib/validators/generated"));
package/dist/types.d.ts CHANGED
@@ -447,8 +447,8 @@ export interface ClassDeclaration extends BaseNode {
447
447
  export interface ExportAllDeclaration extends BaseNode {
448
448
  type: "ExportAllDeclaration";
449
449
  source: StringLiteral;
450
- assertions: Array<ImportAttribute> | null;
451
450
  attributes: Array<ImportAttribute> | null;
451
+ assertions: Array<ImportAttribute> | null;
452
452
  exportKind: "type" | "value" | null;
453
453
  }
454
454
 
@@ -463,8 +463,8 @@ export interface ExportNamedDeclaration extends BaseNode {
463
463
  declaration: Declaration | null;
464
464
  specifiers: Array<ExportSpecifier | ExportDefaultSpecifier | ExportNamespaceSpecifier>;
465
465
  source: StringLiteral | null;
466
- assertions: Array<ImportAttribute> | null;
467
466
  attributes: Array<ImportAttribute> | null;
467
+ assertions: Array<ImportAttribute> | null;
468
468
  exportKind: "type" | "value" | null;
469
469
  }
470
470
 
@@ -487,8 +487,8 @@ export interface ImportDeclaration extends BaseNode {
487
487
  type: "ImportDeclaration";
488
488
  specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
489
489
  source: StringLiteral;
490
- assertions: Array<ImportAttribute> | null;
491
490
  attributes: Array<ImportAttribute> | null;
491
+ assertions: Array<ImportAttribute> | null;
492
492
  importKind: "type" | "typeof" | "value" | null;
493
493
  module: boolean | null;
494
494
  phase: "source" | "defer" | null;
@@ -1962,12 +1962,12 @@ export function arrowFunctionExpression(params: Array<FunctionParameter>, body:
1962
1962
  export function classBody(body: Array<ClassMethod | ClassPrivateMethod | ClassProperty | ClassPrivateProperty | ClassAccessorProperty | TSDeclareMethod | TSIndexSignature | StaticBlock>): ClassBody;
1963
1963
  export function classExpression(id: Identifier | null | undefined, superClass: Expression | null | undefined, body: ClassBody, decorators?: Array<Decorator> | null): ClassExpression;
1964
1964
  export function classDeclaration(id: Identifier | null | undefined, superClass: Expression | null | undefined, body: ClassBody, decorators?: Array<Decorator> | null): ClassDeclaration;
1965
- export function exportAllDeclaration(source: StringLiteral): ExportAllDeclaration;
1965
+ export function exportAllDeclaration(source: StringLiteral, attributes?: Array<ImportAttribute> | null): ExportAllDeclaration;
1966
1966
  export function exportDefaultDeclaration(declaration: TSDeclareFunction | FunctionDeclaration | ClassDeclaration | Expression): ExportDefaultDeclaration;
1967
- export function exportNamedDeclaration(declaration?: Declaration | null, specifiers?: Array<ExportSpecifier | ExportDefaultSpecifier | ExportNamespaceSpecifier>, source?: StringLiteral | null): ExportNamedDeclaration;
1967
+ export function exportNamedDeclaration(declaration?: Declaration | null, specifiers?: Array<ExportSpecifier | ExportDefaultSpecifier | ExportNamespaceSpecifier>, source?: StringLiteral | null, attributes?: Array<ImportAttribute> | null): ExportNamedDeclaration;
1968
1968
  export function exportSpecifier(local: Identifier, exported: Identifier | StringLiteral): ExportSpecifier;
1969
1969
  export function forOfStatement(left: VariableDeclaration | LVal, right: Expression, body: Statement, _await?: boolean): ForOfStatement;
1970
- export function importDeclaration(specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>, source: StringLiteral): ImportDeclaration;
1970
+ export function importDeclaration(specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>, source: StringLiteral, attributes?: Array<ImportAttribute> | null): ImportDeclaration;
1971
1971
  export function importDefaultSpecifier(local: Identifier): ImportDefaultSpecifier;
1972
1972
  export function importNamespaceSpecifier(local: Identifier): ImportNamespaceSpecifier;
1973
1973
  export function importSpecifier(local: Identifier, imported: Identifier | StringLiteral): ImportSpecifier;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/compiler",
3
- "version": "5.39.49",
3
+ "version": "5.39.50",
4
4
  "description": "Marko template to JS compiler.",
5
5
  "keywords": [
6
6
  "babel",
@@ -62,20 +62,20 @@
62
62
  "prepare": "node -r ~ts scripts/types"
63
63
  },
64
64
  "dependencies": {
65
- "@babel/code-frame": "^7.27.1",
66
- "@babel/core": "^7.28.0",
67
- "@babel/generator": "^7.28.0",
68
- "@babel/parser": "^7.28.0",
69
- "@babel/plugin-syntax-typescript": "^7.27.1",
70
- "@babel/plugin-transform-modules-commonjs": "^7.27.1",
71
- "@babel/plugin-transform-typescript": "^7.28.0",
72
- "@babel/runtime": "^7.28.2",
73
- "@babel/traverse": "^7.28.0",
74
- "@babel/types": "^7.28.2",
65
+ "@babel/code-frame": "^7.29.0",
66
+ "@babel/core": "^7.29.0",
67
+ "@babel/generator": "^7.29.1",
68
+ "@babel/parser": "^7.29.0",
69
+ "@babel/plugin-syntax-typescript": "^7.28.6",
70
+ "@babel/plugin-transform-modules-commonjs": "^7.28.6",
71
+ "@babel/plugin-transform-typescript": "^7.28.6",
72
+ "@babel/runtime": "^7.28.6",
73
+ "@babel/traverse": "^7.29.0",
74
+ "@babel/types": "^7.29.0",
75
75
  "@luxass/strip-json-comments": "^1.4.0",
76
76
  "complain": "^1.6.1",
77
77
  "he": "^1.2.0",
78
- "htmljs-parser": "^5.7.3",
78
+ "htmljs-parser": "^5.7.4",
79
79
  "jsesc": "^3.1.0",
80
80
  "kleur": "^4.1.5",
81
81
  "lasso-package-root": "^1.0.1",
@@ -87,7 +87,7 @@
87
87
  "source-map-support": "^0.5.21"
88
88
  },
89
89
  "devDependencies": {
90
- "marko": "^5.38.18"
90
+ "marko": "^5.38.20"
91
91
  },
92
92
  "engines": {
93
93
  "node": "18 || 20 || >=22"