marko 5.39.45 → 5.39.47
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/node_modules/@internal/components-registry/index-browser.js +4 -5
- package/dist/runtime/helpers/load-tag.js +19 -16
- package/dist/translator/util/add-dependencies.js +2 -0
- package/dist/translator/util/load-import.js +15 -2
- package/docs/compiler.md +1 -1
- package/package.json +4 -4
- package/src/node_modules/@internal/components-registry/index-browser.js +4 -5
- package/src/runtime/helpers/load-tag.js +20 -17
- package/src/translator/util/add-dependencies.js +2 -0
- package/src/translator/util/load-import.js +15 -2
|
@@ -46,7 +46,7 @@ function register(type, def) {
|
|
|
46
46
|
delete pendingDefs[type];
|
|
47
47
|
setImmediate(function () {
|
|
48
48
|
pendingForType.forEach(function (args) {
|
|
49
|
-
tryHydrateComponent(args[0], args[1], args[2], args[3])
|
|
49
|
+
tryInvoke(tryHydrateComponent(args[0], args[1], args[2], args[3]));
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
}
|
|
@@ -516,10 +516,9 @@ function tryHydrateComponent(rawDef, meta, host, runtimeId) {
|
|
|
516
516
|
);
|
|
517
517
|
var mount = hydrateComponentAndGetMount(componentDef, host);
|
|
518
518
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
// DOM has fully loaded to attempt to init the component again.
|
|
519
|
+
// A root still being parsed is retried once the document loads; after that,
|
|
520
|
+
// a missing root was removed (eg. by a client reorder) and never returns.
|
|
521
|
+
if (!mount && document.readyState === "loading") {
|
|
523
522
|
if (deferredDefs) {
|
|
524
523
|
deferredDefs.push(componentDef);
|
|
525
524
|
} else {
|
|
@@ -68,29 +68,32 @@ runtimeId)
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
// Its importer passes the bundler's resolver, so it resolves on a page of either
|
|
71
|
-
// API, whichever page entry rendered.
|
|
71
|
+
// API, whichever page entry rendered. Only its tag renders it, reading the template
|
|
72
|
+
// as it renders: an import cycle may not have evaluated that module yet.
|
|
72
73
|
exports.withLoadAssets = function withLoadAssets(
|
|
73
74
|
typeId,
|
|
74
|
-
|
|
75
|
+
getTemplate,
|
|
75
76
|
assetFlush,
|
|
76
77
|
triggers)
|
|
77
78
|
{
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
return {
|
|
80
|
+
_: function (input, out) {
|
|
81
|
+
var key = out.ad_;
|
|
82
|
+
var def = out.ac_;
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
if (willRerender(def)) {
|
|
85
|
+
out.bf(key + "s", def.s_, true);
|
|
86
|
+
writeLoadAsset(out, typeId, assetFlush, triggers);
|
|
87
|
+
out.ef();
|
|
88
|
+
out.bf(key, def.s_, true);
|
|
89
|
+
getTemplate()._(input, out);
|
|
90
|
+
out.ef();
|
|
91
|
+
} else {
|
|
92
|
+
writeLoadAsset(out, typeId, assetFlush, triggers);
|
|
93
|
+
getTemplate()._(input, out);
|
|
94
|
+
}
|
|
92
95
|
}
|
|
93
|
-
}
|
|
96
|
+
};
|
|
94
97
|
};
|
|
95
98
|
|
|
96
99
|
// Within Tags content the Tags writer places it apart from what a `@catch` drops,
|
|
@@ -166,7 +166,9 @@ const entryBuilder = exports.entryBuilder = {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
if (fileMeta.classHydration) {
|
|
169
|
+
const loadImports = file.path.node.extra?.loadImports;
|
|
169
170
|
for (const tag of fileMeta.tags) {
|
|
171
|
+
if (loadImports?.has(tag)) continue;
|
|
170
172
|
if (tag.endsWith(".marko")) {
|
|
171
173
|
visitChild(tag);
|
|
172
174
|
} else if (/^@lasso\/marko-taglib\//.test(tag)) {
|
|
@@ -5,6 +5,7 @@ var _babelUtils = require("@marko/compiler/babel-utils");
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
|
|
8
9
|
const triggerRegExp = /\s*([\w-]+)\s*([^?|]+?)?\s*(?:\?([^|]*?))?\s*(?:\||$)/g;
|
|
9
10
|
const loadTagsByFile = new WeakMap();
|
|
10
11
|
|
|
@@ -47,7 +48,8 @@ function analyzeLoadImport(importDecl, tagEntry) {
|
|
|
47
48
|
// `_` slot, recursing on render (see load-tag-browser.js). Without `linkAssets`
|
|
48
49
|
// there is no asset orchestration for lazy loading either. Both cases drop the
|
|
49
50
|
// attribute so the import compiles as a normal eager tag import.
|
|
50
|
-
const {
|
|
51
|
+
const { file } = importDecl.hub;
|
|
52
|
+
const { markoOpts } = file;
|
|
51
53
|
if (markoOpts.hot || !markoOpts.linkAssets) {
|
|
52
54
|
loadAttrPath.remove();
|
|
53
55
|
return;
|
|
@@ -59,7 +61,18 @@ function analyzeLoadImport(importDecl, tagEntry) {
|
|
|
59
61
|
);
|
|
60
62
|
}
|
|
61
63
|
|
|
64
|
+
// A Tags template renders through the compat tag, which loads it eagerly.
|
|
65
|
+
if (
|
|
66
|
+
(0, _babelUtils.loadFileForImport)(file, tagEntry)?.ast.program.extra?.featureType === "tags")
|
|
67
|
+
{
|
|
68
|
+
loadAttrPath.remove();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
62
72
|
(importDecl.node.extra ??= {}).loadImport = loadImport;
|
|
73
|
+
// The page entry links eager templates only; a lazy one arrives through
|
|
74
|
+
// its own load entry.
|
|
75
|
+
((file.path.node.extra ??= {}).loadImports ??= new Set()).add(tagEntry);
|
|
63
76
|
}
|
|
64
77
|
|
|
65
78
|
function translateLoadTag(path, tagName, relativePath) {
|
|
@@ -130,7 +143,7 @@ function translateLoadTag(path, tagName, relativePath) {
|
|
|
130
143
|
);
|
|
131
144
|
loadArgs = [
|
|
132
145
|
_compiler.types.stringLiteral(childFile.metadata.marko.id),
|
|
133
|
-
_compiler.types.identifier(tagName),
|
|
146
|
+
_compiler.types.arrowFunctionExpression([], _compiler.types.identifier(tagName)),
|
|
134
147
|
(0, _babelUtils.importNamed)(file, linkAssets.runtime, "flush", "marko_asset_flush")];
|
|
135
148
|
|
|
136
149
|
if (triggers) loadArgs.push(_compiler.types.valueToNode(triggers));
|
package/docs/compiler.md
CHANGED
|
@@ -291,7 +291,7 @@ The `hydrateIncludeImports` option allows you to provide a function which receiv
|
|
|
291
291
|
The default regexp includes a list of common known asset file extensions, and is as follows:
|
|
292
292
|
|
|
293
293
|
```js
|
|
294
|
-
/\.(css
|
|
294
|
+
/\.(css(\.[cm]?[jt]s)?|less|s[ac]ss|styl(us)?|p(ost)?css|sss|png|jpe?g|gif|svg|ico|webp|avif|mp4|webm|ogg|mp3|wav|flac|aac|woff2?|eot|ttf|otf)$/;
|
|
295
295
|
```
|
|
296
296
|
|
|
297
297
|
Looking at a partial Marko file such as:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marko",
|
|
3
|
-
"version": "5.39.
|
|
3
|
+
"version": "5.39.47",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
|
|
6
6
|
"keywords": [
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
},
|
|
68
68
|
"types": "index.d.ts",
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@marko/compiler": "^5.42.
|
|
71
|
-
"@marko/runtime-tags": "^6.4.
|
|
70
|
+
"@marko/compiler": "^5.42.13",
|
|
71
|
+
"@marko/runtime-tags": "^6.4.7",
|
|
72
72
|
"app-module-path": "^2.2.0",
|
|
73
73
|
"argly": "^1.2.0",
|
|
74
74
|
"browser-refresh-client": "1.1.4",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"warp10": "^2.1.0"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"marko": "5.39.
|
|
87
|
+
"marko": "5.39.47"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=22"
|
|
@@ -46,7 +46,7 @@ function register(type, def) {
|
|
|
46
46
|
delete pendingDefs[type];
|
|
47
47
|
setImmediate(function () {
|
|
48
48
|
pendingForType.forEach(function (args) {
|
|
49
|
-
tryHydrateComponent(args[0], args[1], args[2], args[3])
|
|
49
|
+
tryInvoke(tryHydrateComponent(args[0], args[1], args[2], args[3]));
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
}
|
|
@@ -516,10 +516,9 @@ function tryHydrateComponent(rawDef, meta, host, runtimeId) {
|
|
|
516
516
|
);
|
|
517
517
|
var mount = hydrateComponentAndGetMount(componentDef, host);
|
|
518
518
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
// DOM has fully loaded to attempt to init the component again.
|
|
519
|
+
// A root still being parsed is retried once the document loads; after that,
|
|
520
|
+
// a missing root was removed (eg. by a client reorder) and never returns.
|
|
521
|
+
if (!mount && document.readyState === "loading") {
|
|
523
522
|
if (deferredDefs) {
|
|
524
523
|
deferredDefs.push(componentDef);
|
|
525
524
|
} else {
|
|
@@ -68,29 +68,32 @@ exports.withPageAssets = function withPageAssets(
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
// Its importer passes the bundler's resolver, so it resolves on a page of either
|
|
71
|
-
// API, whichever page entry rendered.
|
|
71
|
+
// API, whichever page entry rendered. Only its tag renders it, reading the template
|
|
72
|
+
// as it renders: an import cycle may not have evaluated that module yet.
|
|
72
73
|
exports.withLoadAssets = function withLoadAssets(
|
|
73
74
|
typeId,
|
|
74
|
-
|
|
75
|
+
getTemplate,
|
|
75
76
|
assetFlush,
|
|
76
77
|
triggers,
|
|
77
78
|
) {
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
return {
|
|
80
|
+
_: function (input, out) {
|
|
81
|
+
var key = out.___assignedKey;
|
|
82
|
+
var def = out.___assignedComponentDef;
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
if (willRerender(def)) {
|
|
85
|
+
out.bf(key + "s", def.___component, true);
|
|
86
|
+
writeLoadAsset(out, typeId, assetFlush, triggers);
|
|
87
|
+
out.ef();
|
|
88
|
+
out.bf(key, def.___component, true);
|
|
89
|
+
getTemplate()._(input, out);
|
|
90
|
+
out.ef();
|
|
91
|
+
} else {
|
|
92
|
+
writeLoadAsset(out, typeId, assetFlush, triggers);
|
|
93
|
+
getTemplate()._(input, out);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
};
|
|
94
97
|
};
|
|
95
98
|
|
|
96
99
|
// Within Tags content the Tags writer places it apart from what a `@catch` drops,
|
|
@@ -166,7 +166,9 @@ export const entryBuilder = {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
if (fileMeta.classHydration) {
|
|
169
|
+
const loadImports = file.path.node.extra?.loadImports;
|
|
169
170
|
for (const tag of fileMeta.tags) {
|
|
171
|
+
if (loadImports?.has(tag)) continue;
|
|
170
172
|
if (tag.endsWith(".marko")) {
|
|
171
173
|
visitChild(tag);
|
|
172
174
|
} else if (/^@lasso\/marko-taglib\//.test(tag)) {
|
|
@@ -2,6 +2,7 @@ import { types as t } from "@marko/compiler";
|
|
|
2
2
|
import {
|
|
3
3
|
importDefault,
|
|
4
4
|
importNamed,
|
|
5
|
+
loadFileForImport,
|
|
5
6
|
loadFileForTag,
|
|
6
7
|
} from "@marko/compiler/babel-utils";
|
|
7
8
|
|
|
@@ -47,7 +48,8 @@ export function analyzeLoadImport(importDecl, tagEntry) {
|
|
|
47
48
|
// `_` slot, recursing on render (see load-tag-browser.js). Without `linkAssets`
|
|
48
49
|
// there is no asset orchestration for lazy loading either. Both cases drop the
|
|
49
50
|
// attribute so the import compiles as a normal eager tag import.
|
|
50
|
-
const {
|
|
51
|
+
const { file } = importDecl.hub;
|
|
52
|
+
const { markoOpts } = file;
|
|
51
53
|
if (markoOpts.hot || !markoOpts.linkAssets) {
|
|
52
54
|
loadAttrPath.remove();
|
|
53
55
|
return;
|
|
@@ -59,7 +61,18 @@ export function analyzeLoadImport(importDecl, tagEntry) {
|
|
|
59
61
|
);
|
|
60
62
|
}
|
|
61
63
|
|
|
64
|
+
// A Tags template renders through the compat tag, which loads it eagerly.
|
|
65
|
+
if (
|
|
66
|
+
loadFileForImport(file, tagEntry)?.ast.program.extra?.featureType === "tags"
|
|
67
|
+
) {
|
|
68
|
+
loadAttrPath.remove();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
62
72
|
(importDecl.node.extra ??= {}).loadImport = loadImport;
|
|
73
|
+
// The page entry links eager templates only; a lazy one arrives through
|
|
74
|
+
// its own load entry.
|
|
75
|
+
((file.path.node.extra ??= {}).loadImports ??= new Set()).add(tagEntry);
|
|
63
76
|
}
|
|
64
77
|
|
|
65
78
|
export function translateLoadTag(path, tagName, relativePath) {
|
|
@@ -130,7 +143,7 @@ export function translateLoadTag(path, tagName, relativePath) {
|
|
|
130
143
|
);
|
|
131
144
|
loadArgs = [
|
|
132
145
|
t.stringLiteral(childFile.metadata.marko.id),
|
|
133
|
-
t.identifier(tagName),
|
|
146
|
+
t.arrowFunctionExpression([], t.identifier(tagName)),
|
|
134
147
|
importNamed(file, linkAssets.runtime, "flush", "marko_asset_flush"),
|
|
135
148
|
];
|
|
136
149
|
if (triggers) loadArgs.push(t.valueToNode(triggers));
|