marko 5.38.7 → 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.
- package/dist/translator/tag/native-tag[html]/index.js +17 -2
- package/dist/translator/tag/native-tag[vdom]/index.js +17 -2
- package/dist/translator/util/add-dependencies.js +45 -35
- package/package.json +2 -2
- package/src/translator/tag/native-tag[html]/index.js +17 -2
- package/src/translator/tag/native-tag[vdom]/index.js +17 -2
- package/src/translator/util/add-dependencies.js +44 -34
|
@@ -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
|
-
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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
|
}
|
|
@@ -267,52 +267,54 @@ function importPath(path) {
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
function tryGetTemplateImports(file, rendererRelativePath) {
|
|
270
|
-
const resolvedRendererPath =
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
rendererRelativePath
|
|
270
|
+
const resolvedRendererPath = tryResolveFrom(
|
|
271
|
+
rendererRelativePath,
|
|
272
|
+
file.opts.filename
|
|
274
273
|
);
|
|
275
274
|
let templateImports;
|
|
276
275
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
if (
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
276
|
+
if (resolvedRendererPath) {
|
|
277
|
+
if (resolvedRendererPath.endsWith(".marko")) {
|
|
278
|
+
addTemplateImport(resolvedRendererPath);
|
|
279
|
+
} else if (resolvedRendererPath.endsWith(".js")) {
|
|
280
|
+
try {
|
|
281
|
+
for (const statement of (0, _babelUtils.parseStatements)(
|
|
282
|
+
file,
|
|
283
|
+
file.markoOpts.fileSystem.readFileSync(resolvedRendererPath, "utf-8")
|
|
284
|
+
)) {
|
|
285
|
+
if (statement.type === "ImportDeclaration") {
|
|
286
|
+
addTemplateImport(statement.source.value);
|
|
287
|
+
} else {
|
|
288
|
+
_compiler.types.traverseFast(statement, (node) => {
|
|
289
|
+
if (
|
|
290
|
+
node.type === "CallExpression" && (
|
|
291
|
+
node.callee.name === "require" ||
|
|
292
|
+
node.callee.type === "MemberExpression" &&
|
|
293
|
+
node.callee.object.type === "Identifier" &&
|
|
294
|
+
node.callee.object.name === "require" &&
|
|
295
|
+
node.callee.property.type === "Identifier" &&
|
|
296
|
+
node.callee.property.name === "resolve") &&
|
|
297
|
+
node.arguments.length === 1 &&
|
|
298
|
+
node.arguments[0].type === "StringLiteral")
|
|
299
|
+
{
|
|
300
|
+
addTemplateImport(node.arguments[0].value);
|
|
301
|
+
}
|
|
302
|
+
});
|
|
298
303
|
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
} catch {
|
|
304
|
+
}
|
|
305
|
+
} catch {
|
|
303
306
|
|
|
304
|
-
|
|
307
|
+
// Ignore
|
|
308
|
+
}}
|
|
305
309
|
}
|
|
310
|
+
|
|
306
311
|
return templateImports;
|
|
307
312
|
|
|
308
313
|
function addTemplateImport(request) {
|
|
309
314
|
if (request.endsWith(".marko")) {
|
|
310
|
-
const resolvedTemplatePath =
|
|
311
|
-
request[0] === "." ?
|
|
312
|
-
_path.default.resolve(resolvedRendererPath, "..", request) :
|
|
313
|
-
_modules.default.tryResolve(
|
|
315
|
+
const resolvedTemplatePath = tryResolveFrom(
|
|
314
316
|
request,
|
|
315
|
-
|
|
317
|
+
resolvedRendererPath
|
|
316
318
|
);
|
|
317
319
|
if (resolvedTemplatePath) {
|
|
318
320
|
if (templateImports) {
|
|
@@ -325,6 +327,14 @@ function tryGetTemplateImports(file, rendererRelativePath) {
|
|
|
325
327
|
}
|
|
326
328
|
}
|
|
327
329
|
|
|
330
|
+
function tryResolveFrom(request, from) {
|
|
331
|
+
return request[0] === "." ?
|
|
332
|
+
_path.default.resolve(from, "..", request) :
|
|
333
|
+
/^(?:[/\\]|[a-zA-Z]:)/.test(request) ?
|
|
334
|
+
request :
|
|
335
|
+
_modules.default.tryResolve(request, _path.default.dirname(from));
|
|
336
|
+
}
|
|
337
|
+
|
|
328
338
|
function toTestFn(val) {
|
|
329
339
|
if (typeof val === "function") {
|
|
330
340
|
return val;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marko",
|
|
3
|
-
"version": "5.38.
|
|
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.
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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
|
}
|
|
@@ -267,53 +267,55 @@ function importPath(path) {
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
function tryGetTemplateImports(file, rendererRelativePath) {
|
|
270
|
-
const resolvedRendererPath =
|
|
271
|
-
file.opts.filename,
|
|
272
|
-
"..",
|
|
270
|
+
const resolvedRendererPath = tryResolveFrom(
|
|
273
271
|
rendererRelativePath,
|
|
272
|
+
file.opts.filename,
|
|
274
273
|
);
|
|
275
274
|
let templateImports;
|
|
276
275
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
if (
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
node.
|
|
292
|
-
node.callee.
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
276
|
+
if (resolvedRendererPath) {
|
|
277
|
+
if (resolvedRendererPath.endsWith(".marko")) {
|
|
278
|
+
addTemplateImport(resolvedRendererPath);
|
|
279
|
+
} else if (resolvedRendererPath.endsWith(".js")) {
|
|
280
|
+
try {
|
|
281
|
+
for (const statement of parseStatements(
|
|
282
|
+
file,
|
|
283
|
+
file.markoOpts.fileSystem.readFileSync(resolvedRendererPath, "utf-8"),
|
|
284
|
+
)) {
|
|
285
|
+
if (statement.type === "ImportDeclaration") {
|
|
286
|
+
addTemplateImport(statement.source.value);
|
|
287
|
+
} else {
|
|
288
|
+
t.traverseFast(statement, (node) => {
|
|
289
|
+
if (
|
|
290
|
+
node.type === "CallExpression" &&
|
|
291
|
+
(node.callee.name === "require" ||
|
|
292
|
+
(node.callee.type === "MemberExpression" &&
|
|
293
|
+
node.callee.object.type === "Identifier" &&
|
|
294
|
+
node.callee.object.name === "require" &&
|
|
295
|
+
node.callee.property.type === "Identifier" &&
|
|
296
|
+
node.callee.property.name === "resolve")) &&
|
|
297
|
+
node.arguments.length === 1 &&
|
|
298
|
+
node.arguments[0].type === "StringLiteral"
|
|
299
|
+
) {
|
|
300
|
+
addTemplateImport(node.arguments[0].value);
|
|
301
|
+
}
|
|
302
|
+
});
|
|
298
303
|
}
|
|
299
|
-
}
|
|
304
|
+
}
|
|
305
|
+
} catch {
|
|
306
|
+
// Ignore
|
|
300
307
|
}
|
|
301
308
|
}
|
|
302
|
-
} catch {
|
|
303
|
-
// Ignore
|
|
304
309
|
}
|
|
305
310
|
|
|
306
311
|
return templateImports;
|
|
307
312
|
|
|
308
313
|
function addTemplateImport(request) {
|
|
309
314
|
if (request.endsWith(".marko")) {
|
|
310
|
-
const resolvedTemplatePath =
|
|
311
|
-
request
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
request,
|
|
315
|
-
path.dirname(resolvedRendererPath),
|
|
316
|
-
);
|
|
315
|
+
const resolvedTemplatePath = tryResolveFrom(
|
|
316
|
+
request,
|
|
317
|
+
resolvedRendererPath,
|
|
318
|
+
);
|
|
317
319
|
if (resolvedTemplatePath) {
|
|
318
320
|
if (templateImports) {
|
|
319
321
|
templateImports.push(resolvedTemplatePath);
|
|
@@ -325,6 +327,14 @@ function tryGetTemplateImports(file, rendererRelativePath) {
|
|
|
325
327
|
}
|
|
326
328
|
}
|
|
327
329
|
|
|
330
|
+
function tryResolveFrom(request, from) {
|
|
331
|
+
return request[0] === "."
|
|
332
|
+
? path.resolve(from, "..", request)
|
|
333
|
+
: /^(?:[/\\]|[a-zA-Z]:)/.test(request)
|
|
334
|
+
? request
|
|
335
|
+
: markoModules.tryResolve(request, path.dirname(from));
|
|
336
|
+
}
|
|
337
|
+
|
|
328
338
|
function toTestFn(val) {
|
|
329
339
|
if (typeof val === "function") {
|
|
330
340
|
return val;
|