Skip to content

Commit b2eb4e9

Browse files
committed
fix: optimize pure signals as plain functions
1 parent 897a00d commit b2eb4e9

File tree

354 files changed

+2010
-1843
lines changed

Some content is hidden

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

354 files changed

+2010
-1843
lines changed

.changeset/cute-melons-vanish.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+
Optimize pure const signals which cache downstream as plain functions

.sizes.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@
4444
{
4545
"name": "comments",
4646
"user": {
47-
"min": 745,
48-
"brotli": 396
47+
"min": 701,
48+
"brotli": 372
4949
},
5050
"runtime": {
5151
"min": 7059,
5252
"brotli": 3086
5353
},
5454
"total": {
55-
"min": 7804,
56-
"brotli": 3482
55+
"min": 7760,
56+
"brotli": 3458
5757
}
5858
},
5959
{

.sizes/comments.csr/entry.js

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// size: 745 (min) 396 (brotli)
1+
// size: 701 (min) 372 (brotli)
22
const $if_content__setup = ($scope) => {
33
($scope.a,
44
$if_content__comment_comments._($scope),
@@ -29,42 +29,37 @@ const $if_content__setup = ($scope) => {
2929
$for_content__setup = ($scope) => {
3030
($for_content__input_path._($scope), $for_content__open($scope, !0));
3131
},
32-
$for_content__comment_text = _const(7, ($scope) => _text($scope.b, $scope.h)),
3332
$for_content__if = _if(4, "<ul></ul>", "/ b&", $if_content__setup),
3433
$for_content__comment_comments = _const(8, ($scope) => {
3534
($for_content__if($scope, $scope.i ? 0 : 1),
3635
$if_content__comment_comments($scope));
3736
}),
38-
$for_content__$params = _const(5, ($scope) =>
39-
$for_content__comment($scope, $scope.f[0]),
40-
),
41-
$for_content__comment = _const(6, ($scope) => {
42-
($for_content__comment_text($scope, $scope.g?.text),
43-
$for_content__comment_comments($scope, $scope.g?.comments));
44-
}),
37+
$for_content__$params = ($scope, $params2) =>
38+
$for_content__comment($scope, $params2[0]),
39+
$for_content__comment = ($scope, comment) => {
40+
((($scope, comment_text) => {
41+
_text($scope.b, comment_text);
42+
})($scope, comment?.text),
43+
$for_content__comment_comments($scope, comment?.comments));
44+
},
4545
$for = _for_of(
4646
0,
4747
"<li><span> </span><button> </button><!></li>",
4848
" E l D l%l",
4949
$for_content__setup,
5050
$for_content__$params,
5151
),
52-
$input_comments$1 = _const(3, ($scope) => $for($scope, [$scope.d])),
52+
$input_comments$1 = ($scope, input_comments) =>
53+
$for($scope, [input_comments]),
5354
$input_path$1 = _const(4, $for_content__input_path);
5455
function $setup($scope) {
5556
$scope.a;
5657
}
57-
const $input_comments = _const(3, ($scope) =>
58-
$input_comments$1($scope.a, $scope.d),
59-
),
60-
$input_path = _const(4, ($scope) => $input_path$1($scope.a, $scope.e));
61-
_template(
62-
"b",
63-
"<ul></ul>",
64-
"/ b&",
65-
$setup,
66-
_const(2, ($scope) => {
67-
($input_comments($scope, $scope.c.comments),
68-
$input_path($scope, $scope.c.path));
69-
}),
70-
).mount();
58+
_template("b", "<ul></ul>", "/ b&", $setup, ($scope, input) => {
59+
((($scope, input_comments) => {
60+
$input_comments$1($scope.a, input_comments);
61+
})($scope, input.comments),
62+
(($scope, input_path) => {
63+
$input_path$1($scope.a, input_path);
64+
})($scope, input.path));
65+
}).mount();

packages/runtime-tags/src/__tests__/fixtures-interop/custom-tag-parameters-from-args/__snapshots__/dom.expected/components/custom-tag.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ export function $setup($scope) {
2323
$y($scope, 10);
2424
}
2525
export const $input_content = /* @__PURE__ */_._const("input_content", $input_content__OR__x__OR__y);
26-
export const $input = /* @__PURE__ */_._const("input", $scope => $input_content($scope, $scope.input.content));
26+
export const $input = ($scope, input) => $input_content($scope, input.content);
2727
export default /* @__PURE__ */_._template("__tests__/components/custom-tag.marko", $template, $walks, $setup, $input);

packages/runtime-tags/src/__tests__/fixtures-interop/interop-basic-class-to-tags/__snapshots__/dom.expected/components/tags-counter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ const $count = /* @__PURE__ */_._let("count/5", $scope => {
1111
export function $setup($scope) {
1212
$count($scope, 0);
1313
}
14-
export const $input_count = /* @__PURE__ */_._const("input_count", $scope => _._attr($scope["#button/0"], "data-parent", $scope.input_count));
15-
export const $input = /* @__PURE__ */_._const("input", $scope => $input_count($scope, $scope.input.count));
14+
export const $input_count = ($scope, input_count) => _._attr($scope["#button/0"], "data-parent", input_count);
15+
export const $input = ($scope, input) => $input_count($scope, input.count);
1616
export default /* @__PURE__ */_._template("__tests__/components/tags-counter.marko", $template, $walks, $setup, $input);

packages/runtime-tags/src/__tests__/fixtures-interop/interop-class-to-tags-import/__snapshots__/dom.expected/components/tags-counter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ const $count = /* @__PURE__ */_._let("count/5", $scope => {
1111
export function $setup($scope) {
1212
$count($scope, 0);
1313
}
14-
export const $input_count = /* @__PURE__ */_._const("input_count", $scope => _._attr($scope["#button/0"], "data-parent", $scope.input_count));
15-
export const $input = /* @__PURE__ */_._const("input", $scope => $input_count($scope, $scope.input.count));
14+
export const $input_count = ($scope, input_count) => _._attr($scope["#button/0"], "data-parent", input_count);
15+
export const $input = ($scope, input) => $input_count($scope, input.count);
1616
export default /* @__PURE__ */_._template("__tests__/components/tags-counter.marko", $template, $walks, $setup, $input);

packages/runtime-tags/src/__tests__/fixtures-interop/interop-nested-attr-tags-class-to-tags/__snapshots__/dom.expected/components/tags-layout.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function $setup($scope) {
1212
$count($scope, 0);
1313
}
1414
const $dynamicTag = /* @__PURE__ */_._dynamic_tag("#text/2");
15-
export const $input_stuff_content = /* @__PURE__ */_._const("input_stuff_content", $scope => $dynamicTag($scope, $scope.input_stuff_content));
16-
export const $input = /* @__PURE__ */_._const("input", $scope => $input_stuff($scope, $scope.input.stuff));
17-
export const $input_stuff = /* @__PURE__ */_._const("input_stuff", $scope => $input_stuff_content($scope, $scope.input_stuff?.content));
15+
export const $input_stuff_content = ($scope, input_stuff_content) => $dynamicTag($scope, input_stuff_content);
16+
export const $input = ($scope, input) => $input_stuff($scope, input.stuff);
17+
export const $input_stuff = ($scope, input_stuff) => $input_stuff_content($scope, input_stuff?.content);
1818
export default /* @__PURE__ */_._template("__tests__/components/tags-layout.marko", $template, $walks, $setup, $input);

packages/runtime-tags/src/__tests__/fixtures-interop/interop-nested-class-to-tags/__snapshots__/dom.expected/components/tags-layout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ export function $setup($scope) {
1212
$count($scope, 0);
1313
}
1414
const $dynamicTag = /* @__PURE__ */_._dynamic_tag("#text/2");
15-
export const $input_content = /* @__PURE__ */_._const("input_content", $scope => $dynamicTag($scope, $scope.input_content));
16-
export const $input = /* @__PURE__ */_._const("input", $scope => $input_content($scope, $scope.input.content));
15+
export const $input_content = ($scope, input_content) => $dynamicTag($scope, input_content);
16+
export const $input = ($scope, input) => $input_content($scope, input.content);
1717
export default /* @__PURE__ */_._template("__tests__/components/tags-layout.marko", $template, $walks, $setup, $input);

packages/runtime-tags/src/__tests__/fixtures-interop/interop-tag-params-class-to-tags/__snapshots__/dom.expected/components/tags-layout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ export function $setup($scope) {
1515
$count($scope, 0);
1616
}
1717
export const $input_content = /* @__PURE__ */_._const("input_content", $input_content__OR__count);
18-
export const $input = /* @__PURE__ */_._const("input", $scope => $input_content($scope, $scope.input.content));
18+
export const $input = ($scope, input) => $input_content($scope, input.content);
1919
export default /* @__PURE__ */_._template("__tests__/components/tags-layout.marko", $template, $walks, $setup, $input);

packages/runtime-tags/src/__tests__/fixtures-interop/interop-tag-params-tags-to-class/__snapshots__/dom.expected/template.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const $walks = /* over(1), replace, over(2) */"b%c";
44
import * as _ from "@marko/runtime-tags/debug/dom";
55
import _classLayout from "./components/class-layout.marko";
66
_._resume("__tests__/components/class-layout.marko", _classLayout);
7-
const $classlayout_content__message = /* @__PURE__ */_._const("message", $scope => _._text($scope["#text/0"], $scope.message));
7+
const $classlayout_content__message = ($scope, message) => _._text($scope["#text/0"], message);
88
const $classlayout_content__multiplier__OR__baseCount = /* @__PURE__ */_._or(7, $scope => _._text($scope["#text/4"], $scope._.multiplier * $scope.baseCount));
99
const $classlayout_content__multiplier__script = _._script("__tests__/template.marko_1_multiplier", $scope => _._on($scope["#button/1"], "click", function () {
1010
$multiplier($scope._, $scope._.multiplier + 1);
@@ -19,10 +19,10 @@ const $classlayout_content__baseCount = /* @__PURE__ */_._const("baseCount", $sc
1919
$classlayout_content__multiplier__OR__baseCount($scope);
2020
});
2121
const $classlayout_content__setup = $classlayout_content__multiplier;
22-
const $classlayout_content__$params = /* @__PURE__ */_._const("$params2", $scope => {
23-
$classlayout_content__baseCount($scope, $scope.$params2[0]);
24-
$classlayout_content__message($scope, $scope.$params2[1]);
25-
});
22+
const $classlayout_content__$params = ($scope, $params2) => {
23+
$classlayout_content__baseCount($scope, $params2[0]);
24+
$classlayout_content__message($scope, $params2[1]);
25+
};
2626
const $classlayout_content = _._content_resume("__tests__/template.marko_1_content", "<h1> </h1><button id=tags><!> * <!> = <!></button>", /* next(1), get, out(1), get, next(1), replace, over(2), replace, over(2), replace, out(1) */"D l D%c%c%l", $classlayout_content__setup, $classlayout_content__$params);
2727
const $multiplier__closure = /* @__PURE__ */_._closure($classlayout_content__multiplier);
2828
const $multiplier = /* @__PURE__ */_._let("multiplier/1", $multiplier__closure);

0 commit comments

Comments
 (0)