Skip to content

Commit e12aa2e

Browse files
committed
fix: serialize reason improvements
1 parent 82f5f39 commit e12aa2e

File tree

60 files changed

+618
-863
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+618
-863
lines changed

.changeset/weak-fans-fail.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@marko/translator-interop-class-tags": patch
3+
"@marko/runtime-tags": patch
4+
---
5+
6+
Track reasons for function closure serialization and add appropriate guards.

.changeset/wise-suns-hang.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@marko/runtime-tags": patch
3+
---
4+
5+
Track downstream serialize reasons for attribute tags.
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
// size: 74 (min) 72 (brotli)
2-
(_._content_resume("b0", "Goodbye", "b"),
3-
_._content_resume("b1", "Hello", "b"));
1+
// size: 0

packages/runtime-tags/src/__tests__/fixtures/at-tag-inside-if-tag/__snapshots__/dom.expected/template.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ export const $template = `<!>${_customTag_template}`;
22
export const $walks = /* over(1), beginChild, _customTag_walks, endChild */`b/${_customTag_walks}&`;
33
import { $setup as _customTag, $thing2 as _customTag_input_thing, $template as _customTag_template, $walks as _customTag_walks } from "./tags/custom-tag/index.marko";
44
import * as _ from "@marko/runtime-tags/debug/dom";
5-
const $thing_content2 = _._content_resume("__tests__/template.marko_2_content", "Goodbye", /* over(1) */"b");
6-
const $thing_content = _._content_resume("__tests__/template.marko_1_content", "Hello", /* over(1) */"b");
5+
const $thing_content2 = /* @__PURE__ */_._content("__tests__/template.marko_2_content", "Goodbye", /* over(1) */"b");
6+
const $thing_content = /* @__PURE__ */_._content("__tests__/template.marko_1_content", "Hello", /* over(1) */"b");
77
export function $setup($scope) {
88
_customTag($scope["#childScope/0"]);
99
}

packages/runtime-tags/src/__tests__/fixtures/at-tag-inside-if-tag/__snapshots__/html.expected/template.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ export default _._template("__tests__/template.marko", input => {
1111
if (x) {
1212
$thing = _.attrTag({
1313
x: 1,
14-
content: _._content_resume("__tests__/template.marko_1_content", () => {
14+
content: _._content("__tests__/template.marko_1_content", () => {
1515
const $scope1_id = _._scope_id();
1616
_._html("Hello");
17-
}, $scope0_id)
17+
})
1818
});
1919
} else {
2020
$thing = _.attrTag({
2121
x: 2,
22-
content: _._content_resume("__tests__/template.marko_2_content", () => {
22+
content: _._content("__tests__/template.marko_2_content", () => {
2323
const $scope2_id = _._scope_id();
2424
_._html("Goodbye");
25-
}, $scope0_id)
25+
})
2626
});
2727
}
2828
_._set_serialize_reason({
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
1-
// size: 112 (min) 88 (brotli)
2-
_._content_closures(_._content_resume("b0", "<!>:<!>", "%c%b"), {
3-
2($scope, a) {
4-
_._text($scope[0], a);
5-
},
6-
3($scope, v) {
7-
_._text($scope[1], v);
8-
},
9-
});
1+
// size: 0

packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/dom.expected/template.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ export const $template = `<!>${_hello_template}<!>`;
22
export const $walks = /* over(1), beginChild, _hello_walks, endChild, over(1) */`b/${_hello_walks}&b`;
33
import * as _ from "@marko/runtime-tags/debug/dom";
44
import { $setup as _hello, $input_other as _hello_input_other, $input_item as _hello_input_item, $template as _hello_template, $walks as _hello_walks } from "./tags/hello/index.marko";
5-
const $item_content = _._content_closures(_._content_resume("__tests__/template.marko_2_content", "<!>:<!>", /* replace, over(2), replace, over(1) */"%c%b"), {
5+
const $other_content = /* @__PURE__ */_._content("__tests__/template.marko_2_content", "other", /* over(1) */"b");
6+
const $item_content = /* @__PURE__ */_._content_closures(/* @__PURE__ */_._content("__tests__/template.marko_1_content", "<!>:<!>", /* replace, over(2), replace, over(1) */"%c%b"), {
67
a($scope, a) {
78
_._text($scope["#text/0"], a);
89
},
910
v($scope, v) {
1011
_._text($scope["#text/1"], v);
1112
}
1213
});
13-
const $other_content = /* @__PURE__ */_._content("__tests__/template.marko_1_content", "other", /* over(1) */"b");
1414
export function $setup($scope) {
1515
_hello($scope["#childScope/0"]);
1616
_hello_input_other($scope["#childScope/0"], _.attrTag({

packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/html.expected/template.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,17 @@ export default _._template("__tests__/template.marko", input => {
88
b: 2
99
}, (a, v) => {
1010
$item = _.attrTags($item, {
11-
content: _._content_resume("__tests__/template.marko_2_content", () => {
12-
const $scope2_id = _._scope_id();
13-
_._html(`${_._escape(a)}${_._el_resume($scope2_id, "#text/0")}:<!>${_._escape(v)}${_._el_resume($scope2_id, "#text/1")}`);
14-
_._scope($scope2_id, {
15-
a,
16-
v
17-
}, "__tests__/template.marko", "3:8", {
18-
a: "2:10",
19-
v: "2:13"
20-
});
21-
}, $scope0_id)
11+
content: _._content("__tests__/template.marko_1_content", () => {
12+
const $scope1_id = _._scope_id();
13+
_._html(`${_._escape(a)}${_._el_resume($scope1_id, "#text/0")}:<!>${_._escape(v)}${_._el_resume($scope1_id, "#text/1")}`);
14+
_._scope($scope1_id, {}, "__tests__/template.marko", "3:8");
15+
})
2216
});
2317
});
2418
_hello({
2519
other: _.attrTag({
26-
content: _._content("__tests__/template.marko_1_content", () => {
27-
const $scope1_id = _._scope_id();
20+
content: _._content("__tests__/template.marko_2_content", () => {
21+
const $scope2_id = _._scope_id();
2822
_._html("other");
2923
})
3024
}),

packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/resume.expected.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,8 @@
1919
<script>
2020
WALKER_RUNTIME("M")("_");
2121
M._.r = [_ =&gt; (_.a = [0, 3,
22-
{
23-
a: "a",
24-
v: 1
25-
}, 1,
26-
{
27-
a: "b",
28-
v: 2
29-
}])]
22+
{}, 1,
23+
{}])]
3024
</script>
3125
</body>
3226
</html>

packages/runtime-tags/src/__tests__/fixtures/at-tags-dynamic-and-static/__snapshots__/ssr.expected.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Write
22
```html
3-
a<!--M_*4 #text/0-->:<!>1<!--M_*4 #text/1-->b<!--M_*6 #text/0-->:<!>2<!--M_*6 #text/1-->other<script>WALKER_RUNTIME("M")("_");M._.r=[_=>(_.a=[0,3,{a:"a",v:1},1,{a:"b",v:2}])]</script>
3+
a<!--M_*4 #text/0-->:<!>1<!--M_*4 #text/1-->b<!--M_*6 #text/0-->:<!>2<!--M_*6 #text/1-->other<script>WALKER_RUNTIME("M")("_");M._.r=[_=>(_.a=[0,3,{},1,{}])]</script>
44
```
55

66
# Render End
@@ -24,14 +24,8 @@
2424
<script>
2525
WALKER_RUNTIME("M")("_");
2626
M._.r = [_ =&gt; (_.a = [0, 3,
27-
{
28-
a: "a",
29-
v: 1
30-
}, 1,
31-
{
32-
a: "b",
33-
v: 2
34-
}])]
27+
{}, 1,
28+
{}])]
3529
</script>
3630
</body>
3731
</html>

0 commit comments

Comments
 (0)