diff --git a/.changeset/const-fold-primitives.md b/.changeset/const-fold-primitives.md new file mode 100644 index 00000000000..2f0fa3da859 --- /dev/null +++ b/.changeset/const-fold-primitives.md @@ -0,0 +1,5 @@ +--- +"@marko/runtime-tags": patch +--- + +Fold `` tags with statically known primitive values: bare references are baked into the static template output and reactive positions inline the literal, so the binding carries no reactive signal and is never serialized. diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/ambiguous-tags-and-components-dir/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/ambiguous-tags-and-components-dir/sizes.json index ccffa3aa94c..99d59f8ea4f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/ambiguous-tags-and-components-dir/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/ambiguous-tags-and-components-dir/sizes.json @@ -3,7 +3,7 @@ "template.marko.page.mjs": { "total": { "min": 921, - "brotli": 452 + "brotli": 453 }, "files": { "v:template.marko.hydrate-6.js": 104, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/class/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/class/sizes.json index 38def9a9b07..43e2b77aa25 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/class/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/class/sizes.json @@ -2,7 +2,7 @@ "dom": { "template.marko.page.mjs": { "min": 49563, - "brotli": 14671 + "brotli": 14672 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/custom-tag-parameters-from-args/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/custom-tag-parameters-from-args/sizes.json index e8e2fe9780a..d1bd872c21b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/custom-tag-parameters-from-args/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/custom-tag-parameters-from-args/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 68022, - "brotli": 21118 + "min": 68015, + "brotli": 21132 }, "files": { "components/custom-tag.marko": 1121, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-basic-class-to-tags/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-basic-class-to-tags/sizes.json index 066c229bd74..8f9a6ff1345 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-basic-class-to-tags/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-basic-class-to-tags/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 65782, - "brotli": 20201 + "min": 65755, + "brotli": 20208 }, "files": { "components/tags-counter.marko": 691, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-basic-tags-to-class/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-basic-tags-to-class/sizes.json index 9b8d818333a..140ffc4a558 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-basic-tags-to-class/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-basic-tags-to-class/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 67231, - "brotli": 20838 + "min": 67215, + "brotli": 20859 }, "files": { "components/class-counter.marko": 1028, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-class-in-components-in-tags-dir/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-class-in-components-in-tags-dir/sizes.json index 48ad8a42cf4..12d6795ff9e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-class-in-components-in-tags-dir/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-class-in-components-in-tags-dir/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 66817, - "brotli": 20584 + "min": 66798, + "brotli": 20608 }, "files": { "tags/components/hello-internal.marko": 941, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-class-to-tags-import/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-class-to-tags-import/sizes.json index 066c229bd74..8f9a6ff1345 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-class-to-tags-import/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-class-to-tags-import/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 65782, - "brotli": 20201 + "min": 65755, + "brotli": 20208 }, "files": { "components/tags-counter.marko": 691, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-event-handler-render-body-tags-to-class/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-event-handler-render-body-tags-to-class/sizes.json index 1c8e3502678..c4ef2232d81 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-event-handler-render-body-tags-to-class/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-event-handler-render-body-tags-to-class/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 67549, - "brotli": 20983 + "min": 67536, + "brotli": 20950 }, "files": { "components/my-button.marko": 1048, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-events-tags-to-class/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-events-tags-to-class/sizes.json index 2b766c77d39..9204a9617a3 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-events-tags-to-class/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-events-tags-to-class/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 67184, - "brotli": 20787 + "min": 67166, + "brotli": 20812 }, "files": { "components/class-counter.marko": 1043, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-nested-attr-tags-class-to-tags/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-nested-attr-tags-class-to-tags/sizes.json index fb988757b6d..fa86689f3c5 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-nested-attr-tags-class-to-tags/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-nested-attr-tags-class-to-tags/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 66107, - "brotli": 20382 + "min": 66078, + "brotli": 20371 }, "files": { "components/tags-layout.marko": 912, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-nested-class-to-tags/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-nested-class-to-tags/sizes.json index 6de5f307076..82b24bc9c77 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-nested-class-to-tags/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-nested-class-to-tags/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 65777, - "brotli": 20245 + "min": 65750, + "brotli": 20186 }, "files": { "components/tags-layout.marko": 758, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-nested-tags-to-class/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-nested-tags-to-class/sizes.json index d222fa01942..2ccd02f4fb2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-nested-tags-to-class/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-nested-tags-to-class/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 67655, - "brotli": 21011 + "min": 67644, + "brotli": 20983 }, "files": { "components/class-layout.marko": 1227, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-stateless-tags-to-class/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-stateless-tags-to-class/sizes.json index 040626d8c7a..7fa8b17e371 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-stateless-tags-to-class/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-stateless-tags-to-class/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 66972, - "brotli": 20691 + "min": 66950, + "brotli": 20708 }, "files": { "components/my-button/component-browser.js": 457, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-tag-params-class-to-tags/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-tag-params-class-to-tags/sizes.json index f5280c00f6d..34337886fc8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-tag-params-class-to-tags/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-tag-params-class-to-tags/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 66135, - "brotli": 20397 + "min": 66109, + "brotli": 20394 }, "files": { "components/tags-layout.marko": 922, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-tag-params-tags-to-class/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-tag-params-tags-to-class/sizes.json index 024cfd19dbf..14f93465292 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/interop-tag-params-tags-to-class/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/interop-tag-params-tags-to-class/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 68010, - "brotli": 21162 + "min": 67999, + "brotli": 21146 }, "files": { "components/class-layout.marko": 1245, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-event/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-event/sizes.json index 95af7be43c1..125e79facd6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-event/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-event/sizes.json @@ -2,7 +2,7 @@ "dom": { "template.marko.page.mjs": { "min": 1983, - "brotli": 942 + "brotli": 945 }, "child.mjs": { "min": 366, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-idle/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-idle/sizes.json index 36ba46a114e..ef672e0892a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-idle/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-idle/sizes.json @@ -2,7 +2,7 @@ "dom": { "template.marko.page.mjs": { "min": 1937, - "brotli": 928 + "brotli": 929 }, "child.mjs": { "min": 366, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-ssr-toggle/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-ssr-toggle/sizes.json index 82761587e2a..0072c3ddd41 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-ssr-toggle/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-ssr-toggle/sizes.json @@ -2,7 +2,7 @@ "dom": { "template.marko.page.mjs": { "min": 50468, - "brotli": 14924 + "brotli": 14941 }, "child.mjs": { "min": 321, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-ssr/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-ssr/sizes.json index 3189148f650..80c8fe5e7f0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-ssr/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-ssr/sizes.json @@ -2,7 +2,7 @@ "dom": { "template.marko.page.mjs": { "min": 50451, - "brotli": 14925 + "brotli": 14964 }, "child.mjs": { "min": 321, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-unmount-before-load/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-unmount-before-load/sizes.json index d5efe2ec273..dbb588de4d4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-unmount-before-load/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-unmount-before-load/sizes.json @@ -2,7 +2,7 @@ "dom": { "template.marko.page.mjs": { "min": 50468, - "brotli": 14924 + "brotli": 14930 }, "child.mjs": { "min": 321, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-visible/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-visible/sizes.json index dd4ae6cb462..daa63c4c550 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-visible/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/lazy-class-child-visible/sizes.json @@ -2,7 +2,7 @@ "dom": { "template.marko.page.mjs": { "min": 50797, - "brotli": 15038 + "brotli": 15055 }, "child.mjs": { "min": 321, diff --git a/packages/runtime-tags/src/__tests__/fixtures-interop/let/sizes.json b/packages/runtime-tags/src/__tests__/fixtures-interop/let/sizes.json index 4f8ebc4e04c..3d813d0678b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures-interop/let/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures-interop/let/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 3259, - "brotli": 1579 + "min": 3239, + "brotli": 1571 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/assign-to-owner-closure/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/assign-to-owner-closure/sizes.json index 1475fe93d77..746c3796324 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/assign-to-owner-closure/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/assign-to-owner-closure/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 5888, - "brotli": 2681 + "min": 5860, + "brotli": 2673 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/dom.bundle.debug.js index a7be511bd65..99306709599 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/dom.bundle.debug.js @@ -1,17 +1,17 @@ // template.marko const $template = "
"; const $walks = " b b b"; -const $d__OR__more__OR__obj__OR__k = /* @__PURE__ */ _or(9, ($scope) => _attr_class($scope["#div/1"], [ +const $d__OR__more__OR__obj = /* @__PURE__ */ _or(8, ($scope) => _attr_class($scope["#div/1"], [ "a", ["b", $scope.d], ...$scope.more, ...["n1", $scope.d], { - [$scope.k]: $scope.d, + ["computed"]: $scope.d, ...$scope.obj, "q": $scope.d } -]), 3); +]), 2); const $d__OR__moreStyles = /* @__PURE__ */ _or(6, ($scope) => _attr_style($scope["#div/2"], [ "color:red", ["margin:0", $scope.d && "padding:0"], @@ -21,19 +21,17 @@ const $d__script = _script("__tests__/template.marko_0_d", ($scope) => _on($scop $d($scope, $scope.d + "2"); })); const $d = /* @__PURE__ */ _let("d/3", ($scope) => { - $d__OR__more__OR__obj__OR__k($scope); + $d__OR__more__OR__obj($scope); $d__OR__moreStyles($scope); $d__script($scope); }); -const $more = /* @__PURE__ */ _const("more", $d__OR__more__OR__obj__OR__k); +const $more = /* @__PURE__ */ _const("more", $d__OR__more__OR__obj); const $moreStyles = /* @__PURE__ */ _const("moreStyles", $d__OR__moreStyles); -const $obj = /* @__PURE__ */ _const("obj", $d__OR__more__OR__obj__OR__k); -const $k = /* @__PURE__ */ _const("k", $d__OR__more__OR__obj__OR__k); +const $obj = /* @__PURE__ */ _const("obj", $d__OR__more__OR__obj); function $setup($scope) { $d($scope, "dyn"); $more($scope, ["m1"]); $moreStyles($scope, ["display:block"]); $obj($scope, { o: true }); - $k($scope, "computed"); } var template_default = /* @__PURE__ */ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/dom.bundle.js index f3eb4836ba9..900ab1090f4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/dom.bundle.js @@ -1,15 +1,15 @@ // template.marko -const $d__OR__more__OR__obj__OR__k = /* @__PURE__ */ _or(9, ($scope) => _attr_class($scope.b, [ +const $d__OR__more__OR__obj = /* @__PURE__ */ _or(8, ($scope) => _attr_class($scope.b, [ "a", ["b", $scope.d], ...$scope.e, ...["n1", $scope.d], { - [$scope.i]: $scope.d, + ["computed"]: $scope.d, ...$scope.h, "q": $scope.d } -]), 3); +]), 2); const $d__OR__moreStyles = /* @__PURE__ */ _or(6, ($scope) => _attr_style($scope.c, [ "color:red", ["margin:0", $scope.d && "padding:0"], @@ -19,7 +19,7 @@ const $d__script = _script("a0", ($scope) => _on($scope.a, "click", function() { $d($scope, $scope.d + "2"); })); const $d = /* @__PURE__ */ _let(3, ($scope) => { - $d__OR__more__OR__obj__OR__k($scope); + $d__OR__more__OR__obj($scope); $d__OR__moreStyles($scope); $d__script($scope); }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/html.bundle.debug.js index 21982cec15d..c20e487687b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/html.bundle.debug.js @@ -6,14 +6,13 @@ var template_default = _template("__tests__/template.marko", (input) => { const more = ["m1"]; const moreStyles = ["display:block"]; const obj = { o: true }; - const k = "computed"; _html(`${_el_resume($scope0_id, "#button/0")} { d, more, moreStyles, - obj, - k + obj }, "__tests__/template.marko", 0, { d: "1:6", more: "2:8", moreStyles: "3:8", - obj: "4:8", - k: "5:8" + obj: "4:8" }); _resume_branch($scope0_id); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/html.bundle.js index c8b85171e2c..534819e2467 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/html.bundle.js @@ -6,14 +6,13 @@ var template_default = _template("a", (input) => { const more = ["m1"]; const moreStyles = ["display:block"]; const obj = { o: true }; - const k = "computed"; _html(`${_el_resume($scope0_id, "a")} { d, e: more, f: moreStyles, - h: obj, - i: k + h: obj }); _resume_branch($scope0_id); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/writes.debug.html index cce8037e7f9..84eeb49de39 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/writes.debug.html @@ -9,8 +9,7 @@ moreStyles: ["display:block"], obj: { o: !0 - }, - k: "computed" + } }], "packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/template.marko_0_d 1" ]; diff --git a/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/writes.html index d6db37d7889..527b40cb61d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/writes.html +++ b/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/__snapshots__/writes.html @@ -9,8 +9,7 @@ f: ["display:block"], h: { o: !0 - }, - i: "computed" + } }], "a0 1"]; M._.w() diff --git a/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/sizes.json index 78cc68843d6..b414edb973d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/attr-class-delimited-shapes/sizes.json @@ -1,12 +1,12 @@ { "dom": { "template.marko.page.mjs": { - "min": 3313, - "brotli": 1631 + "min": 3316, + "brotli": 1633 } }, "html": { - "min": 532, - "brotli": 321 + "min": 519, + "brotli": 318 } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-unused-ref/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/basic-unused-ref/__snapshots__/dom.bundle.debug.js index bdd80e7aa15..1e284d8406d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-unused-ref/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-unused-ref/__snapshots__/dom.bundle.debug.js @@ -10,7 +10,6 @@ const $clickCount = /* @__PURE__ */ _let("clickCount/2", ($scope) => { }); function $setup($scope) { 123; - 456; $clickCount($scope, 0); } var template_default = /* @__PURE__ */ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/basic-unused-ref/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/basic-unused-ref/__snapshots__/html.bundle.debug.js index 4f97353ad27..0f0a2d0c705 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/basic-unused-ref/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/basic-unused-ref/__snapshots__/html.bundle.debug.js @@ -3,7 +3,6 @@ var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); const $scope0_id = _scope_id(); let unused_1 = 123; - const unused_2 = 456; let clickCount = 0; _html(`
${_el_resume($scope0_id, "#button/0")}
`); _script($scope0_id, "__tests__/template.marko_0_clickCount"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/dom.bundle.debug.js index 572216cc1ad..eb0bc30109f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/dom.bundle.debug.js @@ -1,27 +1,32 @@ // template.marko const $template = "
v=|wrong=
"; const $walks = "Db%c%l b"; -const $key__OR__state = /* @__PURE__ */ _or(7, ($scope) => _attr_input_value($scope, "#input/2", $scope.state[$scope.key], $scope.state[$scope.key + "Change"])); -const $state = /* @__PURE__ */ _const("state", $key__OR__state); +const $state3 = /* @__PURE__ */ _const("state", ($scope) => _attr_input_value($scope, "#input/2", $scope.state["v"], $scope.state["v" + "Change"])); const $v = /* @__PURE__ */ _let("v/3", ($scope) => { _text($scope["#text/0"], $scope.v); - $state($scope, { + $state3($scope, { v: $scope.v, - vChange(x) { - $v($scope, x); - }, - keyChange(x) { - $wrong($scope, x); - } + vChange: $state($scope), + keyChange: $state2($scope) }); }); const $wrong = /* @__PURE__ */ _let("wrong/4", ($scope) => _text($scope["#text/1"], $scope.wrong)); -const $key = /* @__PURE__ */ _const("key", $key__OR__state); const $setup__script = _script("__tests__/template.marko_0", ($scope) => _attr_input_value_script($scope, "#input/2")); function $setup($scope) { $v($scope, "v1"); $wrong($scope, ""); - $key($scope, "v"); $setup__script($scope); } +function $state2($scope) { + return function(x) { + $wrong($scope, x); + }; +} +function $state($scope) { + return function(x) { + $v($scope, x); + }; +} +_resume("__tests__/template.marko_0/state2", $state2); +_resume("__tests__/template.marko_0/state", $state); var template_default = /* @__PURE__ */ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/dom.bundle.js index c3cf8ef1489..62e6efbe1e6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/dom.bundle.js @@ -1,2 +1,24 @@ // template.marko -const $setup__script = _script("a0", ($scope) => _attr_input_value_script($scope, "c")); +const $state3 = /* @__PURE__ */ _const(6, ($scope) => _attr_input_value($scope, "c", $scope.g["v"], $scope.g["vChange"])); +const $v = /* @__PURE__ */ _let(3, ($scope) => { + _text($scope.a, $scope.d); + $state3($scope, { + v: $scope.d, + vChange: $state($scope), + keyChange: $state2($scope) + }); +}); +const $wrong = /* @__PURE__ */ _let(4, ($scope) => _text($scope.b, $scope.e)); +const $setup__script = _script("a2", ($scope) => _attr_input_value_script($scope, "c")); +function $state2($scope) { + return function(x) { + $wrong($scope, x); + }; +} +function $state($scope) { + return function(x) { + $v($scope, x); + }; +} +_resume("a1", $state2); +_resume("a0", $state); diff --git a/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/html.bundle.debug.js index 8ada2f29bfd..23d0a81ba81 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/html.bundle.debug.js @@ -4,18 +4,17 @@ var template_default = _template("__tests__/template.marko", (input) => { const $scope0_id = _scope_id(); let v = "v1"; let wrong = ""; - const key = "v"; const state = { v, - vChange(x) { + vChange: _resume(function(x) { v = x; - }, - keyChange(x) { + }, "__tests__/template.marko_0/state", $scope0_id), + keyChange: _resume(function(x) { wrong = x; - } + }, "__tests__/template.marko_0/state2", $scope0_id) }; - _html(`
v=${_escape(v)}${_el_resume($scope0_id, "#text/0")}|wrong=${_escape(wrong)}${_el_resume($scope0_id, "#text/1")}
${_el_resume($scope0_id, "#input/2")}`); + _html(`
v=${_escape(v)}${_el_resume($scope0_id, "#text/0")}|wrong=${_escape(wrong)}${_el_resume($scope0_id, "#text/1")}
${_el_resume($scope0_id, "#input/2")}`); _script($scope0_id, "__tests__/template.marko_0"); - writeScope($scope0_id, { key }, "__tests__/template.marko", 0, { key: "5:8" }); + writeScope($scope0_id, { state }, "__tests__/template.marko", 0, { state: "6:8" }); _resume_branch($scope0_id); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/html.bundle.js index 56bd538846f..ebb32fd8125 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/__snapshots__/html.bundle.js @@ -4,18 +4,17 @@ var template_default = _template("a", (input) => { const $scope0_id = _scope_id(); let v = "v1"; let wrong = ""; - const key = "v"; const state = { v, - vChange(x) { + vChange: _resume(function(x) { v = x; - }, - keyChange(x) { + }, "a0", $scope0_id), + keyChange: _resume(function(x) { wrong = x; - } + }, "a1", $scope0_id) }; - _html(`
v=${_escape(v)}${_el_resume($scope0_id, "a")}|wrong=${_escape(wrong)}${_el_resume($scope0_id, "b")}
${_el_resume($scope0_id, "c")}`); - _script($scope0_id, "a0"); - writeScope($scope0_id, { f: key }); + _html(`
v=${_escape(v)}${_el_resume($scope0_id, "a")}|wrong=${_escape(wrong)}${_el_resume($scope0_id, "b")}
${_el_resume($scope0_id, "c")}`); + _script($scope0_id, "a2"); + writeScope($scope0_id, { g: state }); _resume_branch($scope0_id); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/sizes.json index 655e909c8b5..dcb73bd11f6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/bound-attr-computed-key/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2831, - "brotli": 1356 + "min": 4152, + "brotli": 1915 } } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..171900cc50a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,26 @@ +// template.marko +const $template = "
step: /
 18446744073709551616 Infinity 
"; +const $walks = " b Db%c%lD%e%l"; +const $count__script = _script("__tests__/template.marko_0_count", ($scope) => _on($scope["#button/0"], "click", function() { + $count($scope, $scope.count + 2); +})); +const $count = /* @__PURE__ */ _let("count/6", ($scope) => { + _text($scope["#text/2"], $scope.count); + _text($scope["#text/5"], void 0 ?? $scope.count); + $count__script($scope); +}); +const $info = ($scope, info) => $info_total($scope, info.total); +const $total = /* @__PURE__ */ _const("total", ($scope) => { + _attr($scope["#div/1"], "data-total", $scope.total); + _text($scope["#text/3"], $scope.total); + $info($scope, { + label: "step", + total: $scope.total + }); +}); +function $setup($scope) { + $count($scope, 0); + $total($scope, 2 + 3); +} +const $info_total = ($scope, info_total) => _text($scope["#text/4"], info_total); +var template_default = /* @__PURE__ */ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..6fab8d9772f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/dom.bundle.js @@ -0,0 +1,9 @@ +// template.marko +const $count__script = _script("a0", ($scope) => _on($scope.a, "click", function() { + $count($scope, $scope.g + 2); +})); +const $count = /* @__PURE__ */ _let(6, ($scope) => { + _text($scope.c, $scope.g); + _text($scope.f, $scope.g); + $count__script($scope); +}); diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..e46bdad5872 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/html.bundle.debug.js @@ -0,0 +1,21 @@ +// template.marko +var template_default = _template("__tests__/template.marko", (input) => { + _scope_reason(); + const $scope0_id = _scope_id(); + let count = 0; + const total = 2 + 3; + const info = { + label: "step", + total + }; + _html(`${_el_resume($scope0_id, "#button/0")}
step: ${_escape(count)}${_el_resume($scope0_id, "#text/2")} / ${_escape(total)}
${_escape(info.total)} 18446744073709551616 Infinity ${_escape(void 0 ?? count)}${_el_resume($scope0_id, "#text/5")}
`); + _script($scope0_id, "__tests__/template.marko_0_count"); + writeScope($scope0_id, { + count, + total + }, "__tests__/template.marko", 0, { + count: "1:6", + total: "4:8" + }); + _resume_branch($scope0_id); +}, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..03c6b384c11 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/html.bundle.js @@ -0,0 +1,18 @@ +// template.marko +var template_default = _template("a", (input) => { + _scope_reason(); + const $scope0_id = _scope_id(); + let count = 0; + const total = 5; + const info = { + label: "step", + total + }; + _html(`${_el_resume($scope0_id, "a")}
step: ${_escape(count)}${_el_resume($scope0_id, "c")} / ${_escape(total)}
${_escape(info.total)} 18446744073709551616 Infinity ${_escape(count)}${_el_resume($scope0_id, "f")}
`); + _script($scope0_id, "a0"); + writeScope($scope0_id, { + g: count, + k: total + }); + _resume_branch($scope0_id); +}, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/render.debug.md new file mode 100644 index 00000000000..02dc0ff01a5 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/render.debug.md @@ -0,0 +1,39 @@ +# Render +```html + +
+ step: 0 / 5 +
+
+  5 18446744073709551616 Infinity 0
+
+``` + +# Update +```js +container.querySelector("button").click(); +``` +```html + +
+ step: 2 / 5 +
+
+  5 18446744073709551616 Infinity 2
+
+``` +## Change +``` +UPDATE: .step::text@6 "0" => "2" +UPDATE: pre::text@32 "0" => "2" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/render.md new file mode 100644 index 00000000000..02dc0ff01a5 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/render.md @@ -0,0 +1,39 @@ +# Render +```html + +
+ step: 0 / 5 +
+
+  5 18446744073709551616 Infinity 0
+
+``` + +# Update +```js +container.querySelector("button").click(); +``` +```html + +
+ step: 2 / 5 +
+
+  5 18446744073709551616 Infinity 2
+
+``` +## Change +``` +UPDATE: .step::text@6 "0" => "2" +UPDATE: pre::text@32 "0" => "2" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..803926db976 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/writes.debug.html @@ -0,0 +1,13 @@ + +
step: 0 / 5
+
5 18446744073709551616 Infinity 0
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/writes.html new file mode 100644 index 00000000000..35a014a14ed --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/__snapshots__/writes.html @@ -0,0 +1,11 @@ + +
step: 0 / 5
+
5 18446744073709551616 Infinity 0
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/sizes.json new file mode 100644 index 00000000000..4929713b163 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/sizes.json @@ -0,0 +1,12 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 2704, + "brotli": 1367 + } + }, + "html": { + "min": 466, + "brotli": 312 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/template.marko b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/template.marko new file mode 100644 index 00000000000..e3962e64681 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/template.marko @@ -0,0 +1,14 @@ + + + + + + + + + + +
+ ${label}: ${count} / ${total} +
+
${info.total} ${big} ${ratio} ${missing ?? count}
diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/test.ts b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/test.ts new file mode 100644 index 00000000000..9c40e6466e2 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag-fold/test.ts @@ -0,0 +1,9 @@ +import type { TestConfig } from "../../main.test"; + +export const config: TestConfig = { + steps: [ + {}, + (container: Element) => + container.querySelector("button")!.click(), + ], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag-hoist-error/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/const-tag-hoist-error/__snapshots__/html.bundle.debug.js index 0d8b57c09c6..d85c73c3fba 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/const-tag-hoist-error/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag-hoist-error/__snapshots__/html.bundle.debug.js @@ -3,9 +3,8 @@ var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); const $scope0_id = _scope_id(); const $y_getter = _hoist($scope0_id, "__tests__/template.marko_0_y/hoist"); - const x = 1; const y = 1; - _html(`
${_escape(x)}
${_escape($y_getter)}`); + _html(`
1
${_escape($y_getter)}`); writeScope($scope0_id, { y }, "__tests__/template.marko", 0, { y: "3:10" }); _assert_hoist(y); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/dom.bundle.debug.js index 696dda5c517..c6db43a3726 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/dom.bundle.debug.js @@ -1,15 +1,13 @@ // template.marko -const $template = "
"; -const $walks = "D%b%l%b"; +const $template = "
1
"; +const $walks = "Db%l%b"; const $y_getter = _hoist_resume("__tests__/template.marko_0_y/hoist", "y"); -const $x = ($scope, x) => _text($scope["#text/0"], x); const $y2 = /* @__PURE__ */ _const("y", ($scope) => { - _text($scope["#text/1"], $scope.y()); + _text($scope["#text/0"], $scope.y()); _assert_hoist($scope.y); }); function $setup($scope) { - _text($scope["#text/2"], typeof $y_getter($scope)); - $x($scope, 1); + _text($scope["#text/1"], typeof $y_getter($scope)); $y2($scope, $y); } function $y() { diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/dom.bundle.js index 53b94049dae..a1e016945d2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/dom.bundle.js @@ -1,5 +1,5 @@ // template.marko -const $y_getter = _hoist_resume("a1", 4); +const $y_getter = _hoist_resume("a1", 3); function $y() { return 1; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/html.bundle.debug.js index 8b436e1831b..0a2b74cad25 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/html.bundle.debug.js @@ -3,9 +3,8 @@ var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); const $scope0_id = _scope_id(); const $y_getter = _hoist($scope0_id, "__tests__/template.marko_0_y/hoist"); - const x = 1; const y = _resume(() => 1, "__tests__/template.marko_0/y"); - _html(`
${_escape(x)}${_escape(y())}
${_escape(typeof $y_getter)}`); + _html(`
1${_escape(y())}
${_escape(typeof $y_getter)}`); writeScope($scope0_id, { y }, "__tests__/template.marko", 0, { y: "3:10" }); _assert_hoist(y); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/html.bundle.js index 0e8b802fc03..9c7acd56de9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/html.bundle.js @@ -3,8 +3,7 @@ var template_default = _template("a", (input) => { _scope_reason(); const $scope0_id = _scope_id(); const $y_getter = _hoist($scope0_id, "a1"); - const x = 1; const y = _resume(() => 1, "a0"); - _html(`
${_escape(x)}${_escape(y())}
${_escape(typeof $y_getter)}`); - writeScope($scope0_id, { e: y }); + _html(`
1${_escape(y())}
${_escape(typeof $y_getter)}`); + writeScope($scope0_id, { d: y }); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/writes.html index 97ff6ea041f..e4ad4977d17 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/writes.html +++ b/packages/runtime-tags/src/__tests__/fixtures/const-tag/__snapshots__/writes.html @@ -1,6 +1,6 @@
11
function diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/dom.bundle.debug.js index 723bd47cfbe..934e685c1e9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/dom.bundle.debug.js @@ -15,18 +15,15 @@ const $tagselect_content__setup = ($scope) => { }; const $tagselect_content = _content_resume("__tests__/template.marko_1_content", "", " b b b", $tagselect_content__setup); const $dynamicTag = /* @__PURE__ */ _dynamic_tag("#text/0", $tagselect_content); -const $value__OR__tag = /* @__PURE__ */ _or(4, ($scope) => $dynamicTag($scope, $scope.tag ? "select" : {}, () => ({ - value: $scope.value, - valueChange: $valueChange($scope) -}))); const $value = /* @__PURE__ */ _let("value/2", ($scope) => { _text($scope["#text/1"], $scope.value); - $value__OR__tag($scope); + $dynamicTag($scope, "select" ? "select" : {}, () => ({ + value: $scope.value, + valueChange: $valueChange($scope) + })); }); -const $tag = /* @__PURE__ */ _const("tag", $value__OR__tag); function $setup($scope) { $value($scope, "b"); - $tag($scope, "select"); } function $valueChange($scope) { return function(v) { diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/dom.bundle.js index 9f6c4a1169a..ad4e664eca1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/dom.bundle.js @@ -12,13 +12,12 @@ const $tagselect_content__setup = ($scope) => { $tagselect_content__setup__script($scope); }; const $dynamicTag = /* @__PURE__ */ _dynamic_tag(0, _content_resume("a1", "", " b b b", $tagselect_content__setup)); -const $value__OR__tag = /* @__PURE__ */ _or(4, ($scope) => $dynamicTag($scope, $scope.d ? "select" : {}, () => ({ - value: $scope.c, - valueChange: $valueChange($scope) -}))); const $value = /* @__PURE__ */ _let(2, ($scope) => { _text($scope.b, $scope.c); - $value__OR__tag($scope); + $dynamicTag($scope, "select", () => ({ + value: $scope.c, + valueChange: $valueChange($scope) + })); }); function $valueChange($scope) { return function(v) { diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/html.bundle.debug.js index e2b1a8a088e..859f7f4b716 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/html.bundle.debug.js @@ -3,8 +3,7 @@ var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); const $scope0_id = _scope_id(); let value = "b"; - const tag = "select"; - _dynamic_tag($scope0_id, "#text/0", tag ? "select" : {}, { + _dynamic_tag($scope0_id, "#text/0", "select" ? "select" : {}, { value, valueChange: _resume(function(v) { value = v; @@ -17,6 +16,6 @@ var template_default = _template("__tests__/template.marko", (input) => { writeScope($scope1_id, {}, "__tests__/template.marko", "3:4"); }, $scope0_id)); _html(`${_escape(value)}${_el_resume($scope0_id, "#text/1")}`); - writeScope($scope0_id, { tag }, "__tests__/template.marko", 0, { tag: "2:8" }); + writeScope($scope0_id, { value }, "__tests__/template.marko", 0, { value: "1:6" }); _resume_branch($scope0_id); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/html.bundle.js index 459ac56b8b4..a181cb4f927 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/html.bundle.js @@ -3,7 +3,6 @@ var template_default = _template("a", (input) => { _scope_reason(); const $scope0_id = _scope_id(); let value = "b"; - const tag = "select"; _dynamic_tag($scope0_id, "a", "select", { value, valueChange: _resume(function(v) { @@ -17,6 +16,6 @@ var template_default = _template("a", (input) => { writeScope($scope1_id, {}); }, $scope0_id)); _html(`${_escape(value)}${_el_resume($scope0_id, "b")}`); - writeScope($scope0_id, { d: tag }); + writeScope($scope0_id, { c: value }); _resume_branch($scope0_id); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/writes.debug.html index 6453f2f098b..348c53ac97f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/writes.debug.html @@ -7,7 +7,7 @@ WALKER_RUNTIME("M")("_"); M._.r = [_ => [1, { "ConditionalRenderer:#text/0": "select", - tag: "select" + value: "b" }, { "ControlledType:#select/0": 3, "ControlledHandler:#select/0": _(1, diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/writes.html index d269a2f0e58..a1682c92cf4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/writes.html +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/__snapshots__/writes.html @@ -7,7 +7,7 @@ WALKER_RUNTIME("M")("_"); M._.r = [_ => [1, { Da: "select", - d: "select" + c: "b" }, { Fa: 3, Ea: _(1, "a0"), diff --git a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/sizes.json index 8788f143a01..c46965b4162 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/controllable-select-dynamic-spread/sizes.json @@ -1,12 +1,12 @@ { "dom": { "template.marko.page.mjs": { - "min": 13526, - "brotli": 5165 + "min": 13392, + "brotli": 5104 } }, "html": { - "min": 547, - "brotli": 332 + "min": 542, + "brotli": 321 } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/dom.bundle.debug.js index 2c797aa4801..d6a22a3115b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/dom.bundle.debug.js @@ -1,19 +1,14 @@ // template.marko const $template = ""; const $walks = ""; -const $x__OR__y__script = _script("__tests__/template.marko_0_x_y", ($scope) => console.log($scope.x, $scope.y)); -const $x__OR__y = /* @__PURE__ */ _or(2, $x__OR__y__script); -const $x = /* @__PURE__ */ _const("x", ($scope) => { - debugger; - $x__OR__y($scope); -}); +const $y__script = _script("__tests__/template.marko_0_y", ($scope) => console.log(0, $scope.y)); const $y = /* @__PURE__ */ _let("y/1", ($scope) => { debugger; - $x__OR__y($scope); + $y__script($scope); }); function $setup($scope) { debugger; - $x($scope, 0); + debugger; $y($scope, 0); } var template_default = /* @__PURE__ */ _template("__tests__/template.marko", "", "", $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/dom.bundle.js index 8e9d8b1057a..434be5241df 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/dom.bundle.js @@ -1,2 +1,2 @@ // template.marko -const $x__OR__y = /* @__PURE__ */ _or(2, _script("a0", ($scope) => console.log($scope.a, $scope.b))); +const $y__script = _script("a0", ($scope) => console.log(0, $scope.b)); diff --git a/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/html.bundle.debug.js index de4427c5489..bcbd1c7d319 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/html.bundle.debug.js @@ -3,17 +3,10 @@ var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); const $scope0_id = _scope_id(); debugger; - const x = 0; debugger; let y = 0; debugger; - _script($scope0_id, "__tests__/template.marko_0_x_y"); - writeScope($scope0_id, { - x, - y - }, "__tests__/template.marko", 0, { - x: "2:8", - y: "4:6" - }); + _script($scope0_id, "__tests__/template.marko_0_y"); + writeScope($scope0_id, { y }, "__tests__/template.marko", 0, { y: "4:6" }); _resume_branch($scope0_id); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/html.bundle.js index 3acca79c136..4b6e88ed334 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/debug-tag/__snapshots__/html.bundle.js @@ -3,14 +3,10 @@ var template_default = _template("a", (input) => { _scope_reason(); const $scope0_id = _scope_id(); debugger; - const x = 0; debugger; let y = 0; debugger; _script($scope0_id, "a0"); - writeScope($scope0_id, { - a: x, - b: y - }); + writeScope($scope0_id, { b: y }); _resume_branch($scope0_id); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/debug-tag/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/debug-tag/sizes.json index 9db62adb253..f6f40f42980 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/debug-tag/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/debug-tag/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 1632, - "brotli": 871 + "min": 1630, + "brotli": 868 } } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-input/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-input/__snapshots__/dom.bundle.debug.js index d4569be5bb4..81f188cae5a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-input/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-input/__snapshots__/dom.bundle.debug.js @@ -19,13 +19,9 @@ var child_default = /* @__PURE__ */ _template("__tests__/tags/child.marko", $tem // template.marko const $template = $template$1; const $walks = /* @__PURE__ */ ((_w0) => `/${_w0}&`)($walks$1); -const $child_content__value = /* @__PURE__ */ _closure_get("value", ($scope) => _text($scope["#text/0"], $scope._.value)); -const $child_content__setup = $child_content__value; -const $child_content = /* @__PURE__ */ _content("__tests__/template.marko_1_content", " ", " b", $child_content__setup); -const $value = /* @__PURE__ */ _const("value"); +const $child_content = /* @__PURE__ */ _content("__tests__/template.marko_1_content", "1", "b"); function $setup($scope) { /* @__PURE__ */ $setup$1($scope["#childScope/0"]); $input($scope["#childScope/0"], { content: $child_content($scope) }); - $value($scope, 1); } var template_default = /* @__PURE__ */ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-input/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-input/__snapshots__/html.bundle.debug.js index 6902955c63b..ac9783adcd0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-input/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-input/__snapshots__/html.bundle.debug.js @@ -14,11 +14,9 @@ var child_default = _template("__tests__/tags/child.marko", (input) => { var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); const $scope0_id = _scope_id(); - const value = 1; child_default({ content: _content("__tests__/template.marko_1_content", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(_escape(value)); - _resume_branch($scope1_id); + _html("1"); }) }); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-input/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-input/__snapshots__/html.bundle.js index e6b1e7d2c4c..1e60a9af954 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-input/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-input/__snapshots__/html.bundle.js @@ -14,11 +14,9 @@ var child_default = _template("b", (input) => { var template_default = _template("a", (input) => { _scope_reason(); _scope_id(); - const value = 1; child_default({ content: _content("a0", () => { _scope_reason(); - const $scope1_id = _scope_id(); - _html(_escape(value)); - _resume_branch($scope1_id); + _scope_id(); + _html("1"); }) }); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-unprovided-input/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-unprovided-input/__snapshots__/dom.bundle.debug.js index a14af008e65..98800ddfbd8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-unprovided-input/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-unprovided-input/__snapshots__/dom.bundle.debug.js @@ -20,13 +20,9 @@ var child_default = /* @__PURE__ */ _template("__tests__/tags/child.marko", $tem // template.marko const $template = $template$1; const $walks = /* @__PURE__ */ ((_w0) => `/${_w0}&`)($walks$1); -const $child_content__value = /* @__PURE__ */ _closure_get("value", ($scope) => _text($scope["#text/0"], $scope._.value)); -const $child_content__setup = $child_content__value; -const $child_content = /* @__PURE__ */ _content("__tests__/template.marko_1_content", " ", " b", $child_content__setup); -const $value = /* @__PURE__ */ _const("value"); +const $child_content = /* @__PURE__ */ _content("__tests__/template.marko_1_content", "1", "b"); function $setup($scope) { /* @__PURE__ */ $setup$1($scope["#childScope/0"]); $input($scope["#childScope/0"], { content: $child_content($scope) }); - $value($scope, 1); } var template_default = /* @__PURE__ */ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-unprovided-input/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-unprovided-input/__snapshots__/html.bundle.debug.js index 0178b7fe77e..2bbc6086deb 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-unprovided-input/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-unprovided-input/__snapshots__/html.bundle.debug.js @@ -14,11 +14,9 @@ var child_default = _template("__tests__/tags/child.marko", (input) => { var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); const $scope0_id = _scope_id(); - const value = 1; child_default({ content: _content("__tests__/template.marko_1_content", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(_escape(value)); - _resume_branch($scope1_id); + _html("1"); }) }); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-unprovided-input/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-unprovided-input/__snapshots__/html.bundle.js index bb490f621b8..a34539e58d8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-unprovided-input/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/destructure-and-reference-unprovided-input/__snapshots__/html.bundle.js @@ -14,11 +14,9 @@ var child_default = _template("b", (input) => { var template_default = _template("a", (input) => { _scope_reason(); _scope_id(); - const value = 1; child_default({ content: _content("a0", () => { _scope_reason(); - const $scope1_id = _scope_id(); - _html(_escape(value)); - _resume_branch($scope1_id); + _scope_id(); + _html("1"); }) }); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/destructure-input/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/destructure-input/__snapshots__/dom.bundle.debug.js index a26af93e85d..59abd8b8daa 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/destructure-input/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/destructure-input/__snapshots__/dom.bundle.debug.js @@ -18,14 +18,10 @@ var child_default = /* @__PURE__ */ _template("__tests__/tags/child.marko", $tem // template.marko const $template = $template$1; const $walks = /* @__PURE__ */ ((_w0) => `/${_w0}&`)($walks$1); -const $child_content__value = /* @__PURE__ */ _closure_get("value", ($scope) => _text($scope["#text/0"], $scope._.value)); -const $child_content__setup = $child_content__value; -const $child_content = /* @__PURE__ */ _content("__tests__/template.marko_1_content", " ", " b", $child_content__setup); -const $value = /* @__PURE__ */ _const("value"); +const $child_content = /* @__PURE__ */ _content("__tests__/template.marko_1_content", "1", "b"); function $setup($scope) { /* @__PURE__ */ $setup$1($scope["#childScope/0"]); $content($scope["#childScope/0"], $child_content($scope)); $rest($scope["#childScope/0"], {}); - $value($scope, 1); } var template_default = /* @__PURE__ */ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/destructure-input/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/destructure-input/__snapshots__/html.bundle.debug.js index 26f761babf5..264de004949 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/destructure-input/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/destructure-input/__snapshots__/html.bundle.debug.js @@ -14,11 +14,9 @@ var child_default = _template("__tests__/tags/child.marko", (input) => { var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); const $scope0_id = _scope_id(); - const value = 1; child_default({ content: _content("__tests__/template.marko_1_content", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(_escape(value)); - _resume_branch($scope1_id); + _html("1"); }) }); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/destructure-input/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/destructure-input/__snapshots__/html.bundle.js index ad83c8f7f97..2dbbe847b4d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/destructure-input/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/destructure-input/__snapshots__/html.bundle.js @@ -14,11 +14,9 @@ var child_default = _template("b", (input) => { var template_default = _template("a", (input) => { _scope_reason(); _scope_id(); - const value = 1; child_default({ content: _content("a0", () => { _scope_reason(); - const $scope1_id = _scope_id(); - _html(_escape(value)); - _resume_branch($scope1_id); + _scope_id(); + _html("1"); }) }); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/dom.bundle.debug.js index 3d0a3694eda..18dd12654c4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/dom.bundle.debug.js @@ -2,20 +2,11 @@ const $template = ""; const $walks = "b%c"; const $setup = () => {}; -const $if_content2__bar__OR__foo = /* @__PURE__ */ _or(1, ($scope) => _text($scope["#text/0"], $scope._._.bar($scope._.foo))); -const $if_content2__bar = /* @__PURE__ */ _closure_get("bar", $if_content2__bar__OR__foo, ($scope) => $scope._._); -const $if_content2__setup = ($scope) => { - $if_content2__bar($scope); - $if_content2__foo._($scope); -}; -const $if_content2__foo = /* @__PURE__ */ _if_closure("#text/0", 0, $if_content2__bar__OR__foo); +const $if_content2__bar = /* @__PURE__ */ _closure_get("bar", ($scope) => _text($scope["#text/0"], $scope._._.bar("foo")), ($scope) => $scope._._); +const $if_content2__setup = $if_content2__bar; const $if_content__if = /* @__PURE__ */ _if("#text/0", "
", "D l", $if_content2__setup); const $if_content__input_b = /* @__PURE__ */ _if_closure("#text/0", 0, ($scope) => $if_content__if($scope, $scope._.input_b ? 0 : 1)); -const $if_content__foo = /* @__PURE__ */ _const("foo"); -const $if_content__setup = ($scope) => { - $if_content__input_b._($scope); - $if_content__foo($scope, "foo"); -}; +const $if_content__setup = $if_content__input_b; const $bar2__closure = /* @__PURE__ */ _closure($if_content2__bar); const $bar2 = /* @__PURE__ */ _const("bar", $bar2__closure); const $input_c = /* @__PURE__ */ _const("input_c", ($scope) => $bar2($scope, $bar($scope))); diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/html.bundle.debug.js index d8f887614b4..7a7c972418a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/html.bundle.debug.js @@ -1,6 +1,6 @@ // template.marko var template_default = _template("__tests__/template.marko", (input) => { - const $scope0_reason = _scope_reason(), $sg__input_b = _serialize_guard($scope0_reason, 5), $si__input_c__OR__input_a__OR__input_b = _serialize_if($scope0_reason, 2), $sg__input_a = _serialize_guard($scope0_reason, 4), $si__input_a__OR__input_b = _serialize_if($scope0_reason, 1), $si__input_c = _serialize_if($scope0_reason, 3); + const $scope0_reason = _scope_reason(), $sg__input_b = _serialize_guard($scope0_reason, 3), $sg__input_a = _serialize_guard($scope0_reason, 2), $si__input_c = _serialize_if($scope0_reason, 1); const $scope0_id = _scope_id(); const $bar2__closures = new Set(); const bar = _resume(function(test) { @@ -9,26 +9,22 @@ var template_default = _template("__tests__/template.marko", (input) => { _if(() => { if (input.a) { const $scope1_id = _scope_id(); - const foo = "foo"; _if(() => { if (input.b) { const $scope2_id = _scope_id(); - _html(`
${_escape(bar(foo))}${_el_resume($scope2_id, "#text/0", _serialize_guard($scope0_reason, 3))}
`); - $si__input_c__OR__input_a__OR__input_b && _subscribe($si__input_c && $bar2__closures, writeScope($scope2_id, { _: _scope_with_id($scope1_id) }, "__tests__/template.marko", "6:3")); + _html(`
${_escape(bar("foo"))}${_el_resume($scope2_id, "#text/0", _serialize_guard($scope0_reason, 1))}
`); + _subscribe($si__input_c && $bar2__closures, writeScope($scope2_id, { _: _scope_with_id($scope1_id) }, "__tests__/template.marko", "6:3")); return 0; } }, $scope1_id, "#text/0", $sg__input_b, $sg__input_b, $sg__input_b, 0, 1); - $si__input_c__OR__input_a__OR__input_b && writeScope($scope1_id, { - foo: _serialize_if($scope0_reason, 0) && foo, - _: _scope_with_id($scope0_id) - }, "__tests__/template.marko", "3:1", { foo: "4:9" }); + writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:1"); return 0; } - }, $scope0_id, "#text/0", _serialize_guard($scope0_reason, 1), $sg__input_a, $sg__input_a); - $si__input_c__OR__input_a__OR__input_b && writeScope($scope0_id, { - input_c: $si__input_a__OR__input_b && input.c, - input_b: _serialize_if($scope0_reason, 4) && input.b, - bar: $si__input_a__OR__input_b && bar, + }, $scope0_id, "#text/0", _serialize_guard($scope0_reason, 0), $sg__input_a, $sg__input_a); + writeScope($scope0_id, { + input_c: input.c, + input_b: _serialize_if($scope0_reason, 2) && input.b, + bar, "ClosureScopes:bar": $si__input_c && $bar2__closures }, "__tests__/template.marko", 0, { input_c: ["input.c"], diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/html.bundle.js index fb521085949..fec0b90fa53 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/html.bundle.js @@ -1,6 +1,6 @@ // template.marko var template_default = _template("a", (input) => { - const $scope0_reason = _scope_reason(), $sg__input_b = _serialize_guard($scope0_reason, 5), $si__input_c__OR__input_a__OR__input_b = _serialize_if($scope0_reason, 2), $sg__input_a = _serialize_guard($scope0_reason, 4), $si__input_a__OR__input_b = _serialize_if($scope0_reason, 1), $si__input_c = _serialize_if($scope0_reason, 3); + const $scope0_reason = _scope_reason(), $sg__input_b = _serialize_guard($scope0_reason, 3), $sg__input_a = _serialize_guard($scope0_reason, 2), $si__input_c = _serialize_if($scope0_reason, 1); const $scope0_id = _scope_id(); const $bar2__closures = /* @__PURE__ */ new Set(); const bar = _resume(function(test) { @@ -9,26 +9,22 @@ var template_default = _template("a", (input) => { _if(() => { if (input.a) { const $scope1_id = _scope_id(); - const foo = "foo"; _if(() => { if (input.b) { const $scope2_id = _scope_id(); - _html(`
${_escape(bar(foo))}${_el_resume($scope2_id, "a", _serialize_guard($scope0_reason, 3))}
`); - $si__input_c__OR__input_a__OR__input_b && _subscribe($si__input_c && $bar2__closures, writeScope($scope2_id, { _: _scope_with_id($scope1_id) })); + _html(`
${_escape(bar("foo"))}${_el_resume($scope2_id, "a", _serialize_guard($scope0_reason, 1))}
`); + _subscribe($si__input_c && $bar2__closures, writeScope($scope2_id, { _: _scope_with_id($scope1_id) })); return 0; } }, $scope1_id, "a", $sg__input_b, $sg__input_b, $sg__input_b, 0, 1); - $si__input_c__OR__input_a__OR__input_b && writeScope($scope1_id, { - b: _serialize_if($scope0_reason, 0) && foo, - _: _scope_with_id($scope0_id) - }); + writeScope($scope1_id, { _: _scope_with_id($scope0_id) }); return 0; } - }, $scope0_id, "a", _serialize_guard($scope0_reason, 1), $sg__input_a, $sg__input_a); - $si__input_c__OR__input_a__OR__input_b && writeScope($scope0_id, { - d: $si__input_a__OR__input_b && input.c, - f: _serialize_if($scope0_reason, 4) && input.b, - g: $si__input_a__OR__input_b && bar, + }, $scope0_id, "a", _serialize_guard($scope0_reason, 0), $sg__input_a, $sg__input_a); + writeScope($scope0_id, { + d: input.c, + f: _serialize_if($scope0_reason, 2) && input.b, + g: bar, Bg: $si__input_c && $bar2__closures }); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/writes.debug.html index 92fdb541b33..8c8738e2e9a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/writes.debug.html @@ -1 +1,14 @@
cfoo
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/writes.html index 92fdb541b33..d166618a1d0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/writes.html +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/__snapshots__/writes.html @@ -1 +1,12 @@
cfoo
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/sizes.json index 6cc34a9c99a..bf7c4170aec 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closure-with-function/sizes.json @@ -6,7 +6,7 @@ } }, "html": { - "min": 15, - "brotli": 19 + "min": 340, + "brotli": 246 } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/dom.bundle.debug.js index 8472f61e614..8a32d386636 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/dom.bundle.debug.js @@ -11,24 +11,19 @@ var custom_tag_default = /* @__PURE__ */ _template("__tests__/tags/custom-tag.ma const $template = /* @__PURE__ */ ((_w0) => `${_w0}
`)($template$1); const $walks = /* @__PURE__ */ ((_w0) => ` b/${_w0}& b`)("D%l"); const a = 1; -const $if_content2__b = /* @__PURE__ */ _closure_get("b", ($scope) => _text($scope["#text/1"], $scope._._.b), ($scope) => $scope._._); +const $if_content2__c = /* @__PURE__ */ _closure_get("c", ($scope) => _text($scope["#text/1"], $scope._._.c), ($scope) => $scope._._); const $if_content2__setup = ($scope) => { - $if_content2__b($scope); $if_content2__c($scope); _text($scope["#text/0"], a); }; -const $if_content2__c = /* @__PURE__ */ _closure_get("c", ($scope) => _text($scope["#text/2"], $scope._._.c), ($scope) => $scope._._); -const $if_content__if = /* @__PURE__ */ _if("#text/0", " ", "%c%c%b", $if_content2__setup); +const $if_content__if = /* @__PURE__ */ _if("#text/0", " 2 ", "%d%b", $if_content2__setup); const $if_content__setup = ($scope) => $if_content__if($scope, Math.random() ? 0 : 1); -const $customtag_content__b = /* @__PURE__ */ _closure_get("b", ($scope) => _text($scope["#text/1"], $scope._.b)); +const $customtag_content__c = /* @__PURE__ */ _closure_get("c", ($scope) => _text($scope["#text/1"], $scope._.c)); const $customtag_content__setup = ($scope) => { - $customtag_content__b($scope); $customtag_content__c($scope); _text($scope["#text/0"], a); }; -const $customtag_content__c = /* @__PURE__ */ _closure_get("c", ($scope) => _text($scope["#text/2"], $scope._.c)); -const $customtag_content = /* @__PURE__ */ _content("__tests__/template.marko_1_content", " ", "%c%c%b", $customtag_content__setup); -const $b = /* @__PURE__ */ _const("b"); +const $customtag_content = /* @__PURE__ */ _content("__tests__/template.marko_1_content", " 2 ", "%d%b", $customtag_content__setup); const $c__closure = /* @__PURE__ */ _closure($customtag_content__c, $if_content2__c); const $c = /* @__PURE__ */ _let("c/4", $c__closure); const $if = /* @__PURE__ */ _if("#div/2", "", "b%c", $if_content__setup); @@ -38,7 +33,6 @@ const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($sc function $setup($scope) { /* @__PURE__ */ $setup$1($scope["#childScope/1"]); $input_content($scope["#childScope/1"], $customtag_content($scope)); - $b($scope, 2); $c($scope, 3); $if($scope, Math.random() ? 0 : 1); $setup__script($scope); diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/dom.bundle.js index 5bcc93e1e71..142a1ecef6e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/dom.bundle.js @@ -1,6 +1,6 @@ // template.marko -const $if_content2__c = /* @__PURE__ */ _closure_get(4, ($scope) => _text($scope.c, $scope._._.e), ($scope) => $scope._._); -const $customtag_content__c = /* @__PURE__ */ _closure_get(4, ($scope) => _text($scope.c, $scope._.e)); +const $if_content2__c = /* @__PURE__ */ _closure_get(4, ($scope) => _text($scope.b, $scope._._.e), ($scope) => $scope._._); +const $customtag_content__c = /* @__PURE__ */ _closure_get(4, ($scope) => _text($scope.b, $scope._.e)); const $c = /* @__PURE__ */ _let(4, /* @__PURE__ */ _closure($customtag_content__c, $if_content2__c)); const $setup__script = _script("a1", ($scope) => _on($scope.a, "click", function() { $c($scope, 4); diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/html.bundle.debug.js index 45a826b59c3..17bcb14146a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/html.bundle.debug.js @@ -14,13 +14,12 @@ var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); const $scope0_id = _scope_id(); const $c__closures = new Set(); - const b = 2; let c = 3; _html(`${_el_resume($scope0_id, "#button/0")}`); custom_tag_default({ content: _content("__tests__/template.marko_1_content", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(a)} ${_escape(b)} ${_escape(c)}${_el_resume($scope1_id, "#text/2")}`); + _html(`${_escape(a)} 2 ${_escape(c)}${_el_resume($scope1_id, "#text/1")}`); _subscribe($c__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "6:2")); _resume_branch($scope1_id); }) }); @@ -29,7 +28,7 @@ var template_default = _template("__tests__/template.marko", (input) => { const $scope2_id = _scope_id(); if (Math.random()) { const $scope3_id = _scope_id(); - _html(`${_escape(a)} ${_escape(b)} ${_escape(c)}${_el_resume($scope3_id, "#text/2")}`); + _html(`${_escape(a)} 2 ${_escape(c)}${_el_resume($scope3_id, "#text/1")}`); _subscribe($c__closures, writeScope($scope3_id, { _: _scope_with_id($scope2_id), "ClosureSignalIndex:c": 1 diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/html.bundle.js index 233e3f9228a..d478c94a584 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/html.bundle.js @@ -14,13 +14,12 @@ var template_default = _template("a", (input) => { _scope_reason(); const $scope0_id = _scope_id(); const $c__closures = /* @__PURE__ */ new Set(); - const b = 2; let c = 3; _html(`${_el_resume($scope0_id, "a")}`); custom_tag_default({ content: _content("a0", () => { _scope_reason(); const $scope1_id = _scope_id(); - _html(`${_escape(a)} ${_escape(b)} ${_escape(c)}${_el_resume($scope1_id, "c")}`); + _html(`${_escape(a)} 2 ${_escape(c)}${_el_resume($scope1_id, "b")}`); _subscribe($c__closures, writeScope($scope1_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope1_id); }) }); @@ -29,7 +28,7 @@ var template_default = _template("a", (input) => { const $scope2_id = _scope_id(); if (Math.random()) { const $scope3_id = _scope_id(); - _html(`${_escape(a)} ${_escape(b)} ${_escape(c)}${_el_resume($scope3_id, "c")}`); + _html(`${_escape(a)} 2 ${_escape(c)}${_el_resume($scope3_id, "b")}`); _subscribe($c__closures, writeScope($scope3_id, { _: _scope_with_id($scope2_id), Ce: 1 diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/writes.debug.html index ef9098534f5..283064666a0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-closures/__snapshots__/writes.debug.html @@ -1,6 +1,6 @@ -
1 2 3
-
1 2 3
+
1 2 3
+
1 2 3
diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-tag-name/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/dynamic-tag-name/__snapshots__/writes.html index ce0a8cd006a..cdb27ed2133 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-tag-name/__snapshots__/writes.html +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-tag-name/__snapshots__/writes.html @@ -8,3 +8,6 @@

+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-tag-name/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/dynamic-tag-name/sizes.json index 9fff315adcd..ba127b839fd 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-tag-name/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/dynamic-tag-name/sizes.json @@ -1,7 +1,7 @@ { "dom": {}, "html": { - "min": 260, - "brotli": 89 + "min": 532, + "brotli": 264 } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/hoist-only/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/hoist-only/__snapshots__/dom.bundle.debug.js index 37d7097a67f..44d51ffd516 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/hoist-only/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/hoist-only/__snapshots__/dom.bundle.debug.js @@ -12,7 +12,6 @@ const $if_content__input_value = /* @__PURE__ */ _if_closure("#text/0", 0, ($sco const $if_content__if = /* @__PURE__ */ _if("#text/0", 0, 0, $if_content2__setup); const $if_content__setup = ($scope) => { $if_content__input_value._($scope); - 2; $if_content__if($scope, 1 ? 0 : 1); }; const $hoist1_getter = _hoist_resume("__tests__/template.marko_0_hoist1/hoist", "hoist1"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/hoist-only/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/hoist-only/__snapshots__/html.bundle.debug.js index 412d24da4f2..888e26c1913 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/hoist-only/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/hoist-only/__snapshots__/html.bundle.debug.js @@ -9,7 +9,6 @@ var template_default = _template("__tests__/template.marko", (input) => { _if(() => { if (1) { const $scope1_id = _scope_id(); - const y = 2; const hoist2 = () => input.value; _if(() => { if (1) { diff --git a/packages/runtime-tags/src/__tests__/fixtures/import-types/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/import-types/__snapshots__/html.bundle.debug.js index d74be462d7e..553499ceb30 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/import-types/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/import-types/__snapshots__/html.bundle.debug.js @@ -2,7 +2,5 @@ var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); const $scope0_id = _scope_id(); - const foo = true; - const bar = true; - _html(`
${_escape(String(foo))}${_escape(String(bar))}
`); + _html(`
${_escape(String(true))}${_escape(String(true))}
`); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/dom.bundle.debug.js index 010824e6919..5439af90664 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/dom.bundle.debug.js @@ -2,17 +2,12 @@ const $Tag_content__walks = "b%c", $Tag_content__template = ""; const $template$1 = /* @__PURE__ */ ((_w0) => `${_w0}`)($Tag_content__template); const $walks$1 = /* @__PURE__ */ ((_w0) => `b/${_w0}&b`)($Tag_content__walks); -const $if_content__count = /* @__PURE__ */ _closure_get("count", ($scope) => _text($scope["#text/0"], $scope._._.count), ($scope) => $scope._._); -const $if_content__setup$1 = $if_content__count; -const $Tag_content__if = /* @__PURE__ */ _if("#text/0", "
", "D l", $if_content__setup$1); +const $Tag_content__if = /* @__PURE__ */ _if("#text/0", "
123
", "b"); const $Tag_content__input_x = ($scope, input_x) => $Tag_content__if($scope, input_x ? 0 : 1); const $Tag_content__$params = ($scope, $params2) => $Tag_content__input($scope, $params2[0]); const $Tag_content__input = ($scope, input) => $Tag_content__input_x($scope, input.x); -const $count = /* @__PURE__ */ _const("count"); function $setup$1($scope) { - $scope["#childScope/0"]._ = $scope; $Tag_content__input_x($scope["#childScope/0"], 1); - $count($scope, 123); } var test_default = /* @__PURE__ */ _template("__tests__/tags/test.marko", $template$1, $walks$1, $setup$1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/dom.bundle.js index 07e32255354..9f61c982f9d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/dom.bundle.js @@ -2,13 +2,10 @@ const $Tag_content__walks = "b%c", $Tag_content__template = ""; const $template = /* @__PURE__ */ ((_w0) => `${_w0}`)($Tag_content__template); const $walks = /* @__PURE__ */ ((_w0) => `b/${_w0}&b`)($Tag_content__walks); -const $Tag_content__if = /* @__PURE__ */ _if(0, "
", "D l", /* @__PURE__ */ _closure_get(1, ($scope) => _text($scope.a, $scope._._.b), ($scope) => $scope._._)); +const $Tag_content__if = /* @__PURE__ */ _if(0, "
123
", "b"); const $Tag_content__input_x = ($scope, input_x) => $Tag_content__if($scope, input_x ? 0 : 1); -const $count = /* @__PURE__ */ _const(1); function $setup($scope) { - $scope.a._ = $scope; $Tag_content__input_x($scope.a, 1); - $count($scope, 123); } // template.marko diff --git a/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/html.bundle.debug.js index c42832ab750..47b356176be 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/html.bundle.debug.js @@ -1,23 +1,21 @@ // tags/test.marko var test_default = _template("__tests__/tags/test.marko", (input) => { - const $scope0_reason = _scope_reason(); + _scope_reason(); const $scope0_id = _scope_id(); - const count = 123; const Tag = { content: _content("__tests__/tags/test.marko_1_content", (input) => { const $scope1_id = _scope_id(); const $scope1_reason = _scope_reason(), $sg__input_x = _serialize_guard($scope1_reason, 0), $si__input_x = _serialize_if($scope1_reason, 0); _if(() => { if (input.x) { const $scope2_id = _scope_id(); - _html(`
${_escape(count)}
`); - $si__input_x && writeScope($scope2_id, { _: _scope_with_id($scope1_id) }, "__tests__/tags/test.marko", "3:4"); + _html("
123
"); + $si__input_x && writeScope($scope2_id, {}, "__tests__/tags/test.marko", "3:4"); return 0; } }, $scope1_id, "#text/0", $sg__input_x, $sg__input_x, $sg__input_x, 0, 1); - $si__input_x && writeScope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/tags/test.marko", "2:2"); + $si__input_x && writeScope($scope1_id, {}, "__tests__/tags/test.marko", "2:2"); }) }; Tag.content({ x: 1 }); - writeScope($scope0_id, { count }, "__tests__/tags/test.marko", 0, { count: "1:8" }); }); // template.marko diff --git a/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/html.bundle.js index b8bcf09b0d7..f6e07bcb618 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/html.bundle.js @@ -1,22 +1,20 @@ // tags/test.marko var test_default = _template("b", (input) => { _scope_reason(); - const $scope0_id = _scope_id(); - const count = 123; + _scope_id(); ({ content: _content("b0", (input) => { const $scope1_id = _scope_id(); const $scope1_reason = _scope_reason(), $sg__input_x = _serialize_guard($scope1_reason, 0), $si__input_x = _serialize_if($scope1_reason, 0); _if(() => { if (input.x) { const $scope2_id = _scope_id(); - _html(`
${_escape(count)}
`); - $si__input_x && writeScope($scope2_id, { _: _scope_with_id($scope1_id) }); + _html("
123
"); + $si__input_x && writeScope($scope2_id, {}); return 0; } }, $scope1_id, "a", $sg__input_x, $sg__input_x, $sg__input_x, 0, 1); - $si__input_x && writeScope($scope1_id, { _: _scope_with_id($scope0_id) }); + $si__input_x && writeScope($scope1_id, {}); }) }).content({ x: 1 }); - writeScope($scope0_id, { b: count }); }); // template.marko diff --git a/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/render.debug.md index ac25eec1aff..046ef292039 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/render.debug.md +++ b/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/render.debug.md @@ -14,5 +14,4 @@ ## Change ``` INSERT: div > div -UPDATE: div > div::text " " => "123" ``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/render.md index ac25eec1aff..046ef292039 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/render.md +++ b/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/__snapshots__/render.md @@ -14,5 +14,4 @@ ## Change ``` INSERT: div > div -UPDATE: div > div::text " " => "123" ``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/sizes.json index 86dc8eb8993..e0a72430ab7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/known-define-tag-empty-section-closure/sizes.json @@ -2,11 +2,11 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 6257, - "brotli": 2828 + "min": 5693, + "brotli": 2611 }, "files": { - "tags/test.marko": 691, + "tags/test.marko": 505, "template.marko": 404 } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/html.bundle.debug.js index def513f1924..aebde5e92b1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/html.bundle.debug.js @@ -4,7 +4,6 @@ var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); const $scope0_id = _scope_id(); console.log("identifier"); - const tagVar = "tag var"; - console.log(tagVar); + console.log("tag var"); console.log(staticVar); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/render-csr.debug.md b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/render-csr.debug.md index e8f6b9a6385..da8b5964524 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/render-csr.debug.md +++ b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/render-csr.debug.md @@ -2,6 +2,6 @@ ## Console ``` LOG "identifier" -LOG "static var" LOG "tag var" +LOG "static var" ``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/render-csr.md b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/render-csr.md index e8f6b9a6385..da8b5964524 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/render-csr.md +++ b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/render-csr.md @@ -2,6 +2,6 @@ ## Console ``` LOG "identifier" -LOG "static var" LOG "tag var" +LOG "static var" ``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/dom.bundle.debug.js index 60d21c013c0..755584855d0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/dom.bundle.debug.js @@ -13,18 +13,15 @@ var my_button_default = /* @__PURE__ */ _template("__tests__/tags/my-button.mark const $template = $template$1; const $walks = /* @__PURE__ */ ((_w0) => `/${_w0}&`)(" b"); const $mybutton_content = /* @__PURE__ */ _content("__tests__/template.marko_1_content", "Click", "b"); -const $test = /* @__PURE__ */ _const("test", ($scope) => $input($scope["#childScope/0"], { - onClick: $onClick($scope), - content: $mybutton_content($scope) -})); function $setup($scope) { /* @__PURE__ */ $setup$1($scope["#childScope/0"]); - $test($scope, "foo"); + $input($scope["#childScope/0"], { + onClick: $onClick, + content: $mybutton_content($scope) + }); } -function $onClick($scope) { - return function() { - console.log($scope.test); - }; +function $onClick() { + console.log("foo"); } _resume("__tests__/template.marko_0/onClick", $onClick); var template_default = /* @__PURE__ */ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/dom.bundle.js index 78bfb6edf40..9d5d699c092 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/dom.bundle.js @@ -2,9 +2,7 @@ const $input__script = _script("b0", ($scope) => _attrs_script($scope, "a")); // template.marko -function $onClick($scope) { - return function() { - console.log($scope.b); - }; +function $onClick() { + console.log("foo"); } _resume("a0", $onClick); diff --git a/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/html.bundle.debug.js index ea5f53cc19b..1f36e1fc51c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/html.bundle.debug.js @@ -13,16 +13,14 @@ var my_button_default = _template("__tests__/tags/my-button.marko", (input) => { var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); const $scope0_id = _scope_id(); - const test = "foo"; my_button_default({ onClick: _resume(function() { - console.log(test); - }, "__tests__/template.marko_0/onClick", $scope0_id), + console.log("foo"); + }, "__tests__/template.marko_0/onClick"), content: _content("__tests__/template.marko_1_content", () => { _scope_reason(); const $scope1_id = _scope_id(); _html("Click"); }) }); - writeScope($scope0_id, { test }, "__tests__/template.marko", 0, { test: "1:7" }); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/html.bundle.js index 15716663573..442e35d3fb2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/html.bundle.js @@ -12,17 +12,15 @@ var my_button_default = _template("b", (input) => { // template.marko var template_default = _template("a", (input) => { _scope_reason(); - const $scope0_id = _scope_id(); - const test = "foo"; + _scope_id(); my_button_default({ onClick: _resume(function() { - console.log(test); - }, "a0", $scope0_id), + console.log("foo"); + }, "a0"), content: _content("a1", () => { _scope_reason(); _scope_id(); _html("Click"); }) }); - writeScope($scope0_id, { b: test }); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/writes.debug.html index 5b422c28948..5a8364a5cbd 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/pure-signal-resume-function/__snapshots__/writes.debug.html @@ -1,13 +1,11 @@ diff --git a/packages/runtime-tags/src/__tests__/fixtures/tag-param-if-closure/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/tag-param-if-closure/sizes.json index 2e6aae18cad..243731d66d1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/tag-param-if-closure/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/tag-param-if-closure/sizes.json @@ -1,12 +1,12 @@ { "dom": { "template.marko.page.mjs": { - "min": 13751, - "brotli": 5295 + "min": 13510, + "brotli": 5201 } }, "html": { - "min": 431, - "brotli": 295 + "min": 414, + "brotli": 283 } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-tag-closure/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/try-tag-closure/__snapshots__/html.bundle.debug.js index d21d58b07da..1b85c94c86d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-tag-closure/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/try-tag-closure/__snapshots__/html.bundle.debug.js @@ -2,11 +2,9 @@ var template_default = _template("__tests__/template.marko", (input) => { _scope_reason(); const $scope0_id = _scope_id(); - const value = "Hello"; _try($scope0_id, "#text/0", _content_resume("__tests__/template.marko_1_content", () => { const $scope1_id = _scope_id(); _scope_reason(); - _html(_escape(value)); - _resume_branch($scope1_id); + _html("Hello"); }, $scope0_id), {}); }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-tag-closure/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/try-tag-closure/__snapshots__/html.bundle.js index 3e429026ecf..e22bbf21361 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-tag-closure/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/try-tag-closure/__snapshots__/html.bundle.js @@ -2,11 +2,9 @@ var template_default = _template("a", (input) => { _scope_reason(); const $scope0_id = _scope_id(); - const value = "Hello"; _try($scope0_id, "a", _content_resume("a0", () => { - const $scope1_id = _scope_id(); + _scope_id(); _scope_reason(); - _html(_escape(value)); - _resume_branch($scope1_id); + _html("Hello"); }, $scope0_id), {}); }, 1); diff --git a/packages/runtime-tags/src/translator/core/const.ts b/packages/runtime-tags/src/translator/core/const.ts index 836bdf99f13..c384bfba8b0 100644 --- a/packages/runtime-tags/src/translator/core/const.ts +++ b/packages/runtime-tags/src/translator/core/const.ts @@ -11,6 +11,7 @@ import { isOutputDOM } from "../util/marko-config"; import { BindingType, dropNodes, + isReferenceHoisted, setBindingDownstream, trackVarReferences, } from "../util/references"; @@ -67,23 +68,47 @@ export default { const binding = trackVarReferences(tag, BindingType.derived, upstreamAlias); if (binding) { - if (node.var!.type === "Identifier") { - const constantViolations = tag.scope.getBinding( - node.var.name, - )?.constantViolations; - if (constantViolations?.length) { - for (const assignment of constantViolations) { - if (assignment.type !== "MarkoTag") { - // Ignore duplicate declaration violations. - throw assignment.buildCodeFrameError( - `${node.var.name} is readonly and cannot be mutated.`, - ); - } + if (!valueExtra.nullable) binding.nullable = false; + + const babelBinding = + node.var.type === "Identifier" + ? tag.scope.getBinding(node.var.name) + : undefined; + + if (babelBinding?.constantViolations.length) { + for (const assignment of babelBinding.constantViolations) { + if (assignment.type !== "MarkoTag") { + // Ignore duplicate declaration violations. + throw assignment.buildCodeFrameError( + `${(node.var as t.Identifier).name} is readonly and cannot be mutated.`, + ); } } } - if (!valueExtra.nullable) binding.nullable = false; - if (!upstreamAlias) setBindingDownstream(binding, valueExtra); + + if ( + babelBinding && + !upstreamAlias && + !binding.aliases.size && + !binding.propertyAliases.size && + valueExtra.confident && + canInlineValue(valueExtra.computed) && + !babelBinding.referencePaths.some((ref) => + isReferenceHoisted(babelBinding.path, ref), + ) + ) { + binding.type = BindingType.constant; + binding.constValue = valueExtra.computed; + + for (const ref of babelBinding.referencePaths) { + const refExtra = (ref.node.extra ??= {}); + refExtra.confident = true; + refExtra.computed = valueExtra.computed; + refExtra.nullable = valueExtra.nullable; + } + } else if (!upstreamAlias) { + setBindingDownstream(binding, valueExtra); + } } }, translate: { @@ -91,17 +116,23 @@ export default { const { node } = tag; const [valueAttr] = node.attributes; const { value } = valueAttr; + const varBinding = node.var!.extra?.binding; - if (isOutputDOM()) { - const section = getSection(tag); - const varBinding = node.var!.extra?.binding; - - if (varBinding && !varBinding.upstreamAlias) { - const derivation = initValue(varBinding)!; - addValue(section, value.extra?.referencedBindings, derivation, value); + if (varBinding?.type !== BindingType.constant) { + if (isOutputDOM()) { + const section = getSection(tag); + if (varBinding && !varBinding.upstreamAlias) { + const derivation = initValue(varBinding)!; + addValue( + section, + value.extra?.referencedBindings, + derivation, + value, + ); + } + } else { + translateVar(tag, value); } - } else { - translateVar(tag, value); } tag.remove(); @@ -119,3 +150,16 @@ export default { ], types: runtimeInfo.name + "/tags/const.d.marko", } as Tag; + +function canInlineValue(value: unknown) { + switch (typeof value) { + case "string": + case "number": + case "boolean": + case "bigint": + case "undefined": + return true; + default: + return value === null; + } +} diff --git a/packages/runtime-tags/src/translator/util/references.ts b/packages/runtime-tags/src/translator/util/references.ts index 80a87d96ac7..6d5d2aec3eb 100644 --- a/packages/runtime-tags/src/translator/util/references.ts +++ b/packages/runtime-tags/src/translator/util/references.ts @@ -110,6 +110,7 @@ export interface Binding { restOffset: number | undefined; scopeOffset: Binding | undefined; scopeAccessor: string | undefined; + constValue: unknown; export: string | undefined; declared: boolean; nullable: boolean; @@ -219,6 +220,7 @@ export function createBinding( restOffset: undefined, scopeOffset: undefined, scopeAccessor: undefined, + constValue: undefined, export: undefined, nullable: !sameSection || excludeProperties === undefined, pruned: undefined, @@ -1008,7 +1010,10 @@ export function finalizeReferences() { section.referencedLocalClosures, binding, ); - } else if (binding.type !== BindingType.dom) { + } else if ( + binding.type !== BindingType.dom && + !isInlinedConstant(binding) + ) { const canonicalUpstreamAlias = getCanonicalBinding(binding); canonicalUpstreamAlias.closureSections = sectionUtil.add( canonicalUpstreamAlias.closureSections, @@ -1774,14 +1779,17 @@ export function getReadReplacement( if (read) { const readBinding = read.binding; + const constValueNode = isInlinedConstant(readBinding) + ? constValueToNode(readBinding.constValue) + : undefined; let replacement: t.Expression | undefined; if (read.props === undefined) { - if (read.getter?.invoked) { + if (constValueNode) { + replacement = constValueNode; + } else if (read.getter?.invoked) { return; - } - - if (isOutputDOM()) { + } else if (isOutputDOM()) { if ( signal?.referencedBindings === readBinding && !signal.hasSideEffect @@ -1906,6 +1914,18 @@ export function getReadReplacement( } } +export function isInlinedConstant(binding: Binding) { + return ( + binding.type === BindingType.constant && binding.scopeAccessor === undefined + ); +} + +function constValueToNode(value: unknown): t.Expression { + return value === undefined + ? t.unaryExpression("void", t.numericLiteral(0)) + : t.valueToNode(value); +} + export function hasNonConstantPropertyAlias(ref: Binding) { for (const alias of ref.propertyAliases.values()) { if (alias.type !== BindingType.constant) { diff --git a/packages/runtime-tags/src/translator/util/serialize-reasons.ts b/packages/runtime-tags/src/translator/util/serialize-reasons.ts index 47650b58573..fa0f7eeb2c2 100644 --- a/packages/runtime-tags/src/translator/util/serialize-reasons.ts +++ b/packages/runtime-tags/src/translator/util/serialize-reasons.ts @@ -12,6 +12,7 @@ import { compareSources, getCanonicalBinding, type InputBinding, + isInlinedConstant, isReferencedExtra, mergeSources, type ParamBinding, @@ -65,6 +66,9 @@ export function addSerializeReason( prefix?: AccessorPrefix | symbol, ) { if (reason) { + if (typeof prop === "object" && isInlinedConstant(prop)) { + return; + } if (prop) { const key = getPropKey(section, prop, prefix); const curReason = section.serializeReasons.get(key);