marko 5.38.8 → 5.38.9

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.
@@ -177,12 +177,16 @@ function _default(path, isNullable) {
177
177
  }
178
178
 
179
179
  let needsBlock;
180
+ let needsIIFE;
180
181
  for (const childNode of body) {
181
182
  if (_compiler.types.isVariableDeclaration(childNode)) {
182
183
  if (childNode.kind === "const" || childNode.kind === "let") {
183
184
  needsBlock = true;
184
- break;
185
+ } else {
186
+ needsIIFE = true;
185
187
  }
188
+
189
+ break;
186
190
  }
187
191
  }
188
192
 
@@ -203,7 +207,18 @@ function _default(path, isNullable) {
203
207
 
204
208
  path.replaceWithMultiple(
205
209
  [writeStartNode].
206
- concat(needsBlock ? _compiler.types.blockStatement(body) : body).
210
+ concat(
211
+ needsIIFE ?
212
+ _compiler.types.expressionStatement(
213
+ _compiler.types.callExpression(
214
+ _compiler.types.arrowFunctionExpression([], _compiler.types.blockStatement(body)),
215
+ []
216
+ )
217
+ ) :
218
+ needsBlock ?
219
+ _compiler.types.blockStatement(body) :
220
+ body
221
+ ).
207
222
  concat(writeEndNode)
208
223
  );
209
224
  }
@@ -65,18 +65,33 @@ function _default(path, isNullable) {
65
65
  }
66
66
 
67
67
  let needsBlock;
68
+ let needsIIFE;
68
69
  for (const childNode of body) {
69
70
  if (_compiler.types.isVariableDeclaration(childNode)) {
70
71
  if (childNode.kind === "const" || childNode.kind === "let") {
71
72
  needsBlock = true;
72
- break;
73
+ } else {
74
+ needsIIFE = true;
73
75
  }
76
+
77
+ break;
74
78
  }
75
79
  }
76
80
 
77
81
  path.replaceWithMultiple(
78
82
  [writeStartNode].
79
- concat(needsBlock ? _compiler.types.blockStatement(body) : body).
83
+ concat(
84
+ needsIIFE ?
85
+ _compiler.types.expressionStatement(
86
+ _compiler.types.callExpression(
87
+ _compiler.types.arrowFunctionExpression([], _compiler.types.blockStatement(body)),
88
+ []
89
+ )
90
+ ) :
91
+ needsBlock ?
92
+ _compiler.types.blockStatement(body) :
93
+ body
94
+ ).
80
95
  concat(writeEndNode)
81
96
  );
82
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.38.8",
3
+ "version": "5.38.9",
4
4
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
5
5
  "keywords": [
6
6
  "front-end",
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@babel/runtime": "^7.28.2",
73
- "@marko/compiler": "^5.39.45",
73
+ "@marko/compiler": "^5.39.47",
74
74
  "@marko/runtime-tags": "^6.0.126",
75
75
  "app-module-path": "^2.2.0",
76
76
  "argly": "^1.2.0",
@@ -177,12 +177,16 @@ export default function (path, isNullable) {
177
177
  }
178
178
 
179
179
  let needsBlock;
180
+ let needsIIFE;
180
181
  for (const childNode of body) {
181
182
  if (t.isVariableDeclaration(childNode)) {
182
183
  if (childNode.kind === "const" || childNode.kind === "let") {
183
184
  needsBlock = true;
184
- break;
185
+ } else {
186
+ needsIIFE = true;
185
187
  }
188
+
189
+ break;
186
190
  }
187
191
  }
188
192
 
@@ -203,7 +207,18 @@ export default function (path, isNullable) {
203
207
 
204
208
  path.replaceWithMultiple(
205
209
  [writeStartNode]
206
- .concat(needsBlock ? t.blockStatement(body) : body)
210
+ .concat(
211
+ needsIIFE
212
+ ? t.expressionStatement(
213
+ t.callExpression(
214
+ t.arrowFunctionExpression([], t.blockStatement(body)),
215
+ [],
216
+ ),
217
+ )
218
+ : needsBlock
219
+ ? t.blockStatement(body)
220
+ : body,
221
+ )
207
222
  .concat(writeEndNode),
208
223
  );
209
224
  }
@@ -65,18 +65,33 @@ export default function (path, isNullable) {
65
65
  }
66
66
 
67
67
  let needsBlock;
68
+ let needsIIFE;
68
69
  for (const childNode of body) {
69
70
  if (t.isVariableDeclaration(childNode)) {
70
71
  if (childNode.kind === "const" || childNode.kind === "let") {
71
72
  needsBlock = true;
72
- break;
73
+ } else {
74
+ needsIIFE = true;
73
75
  }
76
+
77
+ break;
74
78
  }
75
79
  }
76
80
 
77
81
  path.replaceWithMultiple(
78
82
  [writeStartNode]
79
- .concat(needsBlock ? t.blockStatement(body) : body)
83
+ .concat(
84
+ needsIIFE
85
+ ? t.expressionStatement(
86
+ t.callExpression(
87
+ t.arrowFunctionExpression([], t.blockStatement(body)),
88
+ [],
89
+ ),
90
+ )
91
+ : needsBlock
92
+ ? t.blockStatement(body)
93
+ : body,
94
+ )
80
95
  .concat(writeEndNode),
81
96
  );
82
97
  }