Skip to content

Commit d5224b0

Browse files
authored
fix: optimize param serialization, optimize define tag
1 parent e5bd85c commit d5224b0

File tree

313 files changed

+4323
-2752
lines changed

Some content is hidden

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

313 files changed

+4323
-2752
lines changed

.changeset/few-pianos-shop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@marko/runtime-tags": patch
3+
---
4+
5+
Guard param serialize reasons and avoid registering body content for stateless attribute tags

.sizes.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
{
88
"name": "*",
99
"total": {
10-
"min": 19254,
11-
"brotli": 7298
10+
"min": 19308,
11+
"brotli": 7346
1212
}
1313
},
1414
{
@@ -44,16 +44,16 @@
4444
{
4545
"name": "comments",
4646
"user": {
47-
"min": 890,
48-
"brotli": 457
47+
"min": 809,
48+
"brotli": 431
4949
},
5050
"runtime": {
5151
"min": 6990,
5252
"brotli": 2989
5353
},
5454
"total": {
55-
"min": 7880,
56-
"brotli": 3446
55+
"min": 7799,
56+
"brotli": 3420
5757
}
5858
},
5959
{

.sizes/comments.csr/entry.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
1-
// size: 890 (min) 457 (brotli)
1+
// size: 809 (min) 431 (brotli)
22
const $if_content__setup = ($scope) => {
33
($scope[0],
44
$if_content__comment_comments._($scope),
55
$if_content__id._($scope));
66
},
7-
$if_content__comment_comments__OR__id = _or(1, ($scope) => {
8-
let {
9-
_: { 8: comment_comments, 11: id },
10-
} = $scope;
11-
$input$1($scope[0], { comments: comment_comments, path: id });
12-
}),
137
$if_content__comment_comments = _if_closure(
148
8,
159
4,
1610
0,
17-
$if_content__comment_comments__OR__id,
11+
($scope, comment_comments) => $input_comments($scope[0], comment_comments),
1812
),
19-
$if_content__id = _if_closure(
20-
11,
21-
4,
22-
0,
23-
$if_content__comment_comments__OR__id,
13+
$if_content__id = _if_closure(11, 4, 0, ($scope, id) =>
14+
$input_path($scope[0], id),
2415
),
2516
$if_content = _content_branch("<ul></ul>", "/ b&", $if_content__setup),
2617
$for_content__id = _const(11, ($scope, id) => {
@@ -80,9 +71,6 @@ const $if_content__setup = ($scope) => {
8071
$input_comments = _const(3, ($scope, input_comments) =>
8172
$for($scope, [input_comments]),
8273
),
83-
$input$1 = _const(2, ($scope, input) => {
84-
($input_comments($scope, input.comments), $input_path($scope, input.path));
85-
}),
8674
$input_path = _const(4, $for_content__input_path);
8775
function $setup($scope) {
8876
$scope[0];

.sizes/dom.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// size: 19254 (min) 7298 (brotli)
1+
// size: 19308 (min) 7346 (brotli)
22
var empty = [],
33
rest = Symbol();
44
function attrTag(attrs) {
@@ -732,6 +732,14 @@ function closure(valueAccessor, fn, getOwnerScope) {
732732
fn(scope, (getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]);
733733
};
734734
}
735+
function _child_setup(setup) {
736+
return (
737+
(setup._ = (scope, owner) => {
738+
((scope._ = owner), queueRender(scope, setup, -1));
739+
}),
740+
setup
741+
);
742+
}
735743
function _var(scope, childAccessor, signal) {
736744
scope[childAccessor].e = (value) => signal(scope, value);
737745
}

.sizes/name-cache.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"vars":{"props":{"$empty":"e","$rest":"t","$attrTag":"n","$attrTags":"r","$attrTagIterator":"l","$forIn":"o","$forOf":"i","$forTo":"u","$stringifyClassObject":"f","$stringifyStyleObject":"a","$toDelimitedString":"c","$isEventHandler":"s","$getEventHandlerName":"d","$normalizeDynamicRenderer":"h","$defaultDelegator":"g","$_on":"p","$createDelegator":"v","$handleDelegated":"b","$stripSpacesAndPunctuation":"m","$createScope":"y","$skipScope":"k","$findBranchWithKey":"C","$destroyBranch":"N","$destroyNestedBranches":"w","$removeAndDestroyBranch":"_","$insertBranchBefore":"A","$tempDetachBranch":"S","$walker":"x","$walk":"M","$walkInternal":"I","$branchesEnabled":"$","$isResuming":"j","$registeredValues":"E","$enableBranches":"T","$init":"L","$_resume":"O","$_var_resume":"R","$_el":"q","$_attr_input_checked":"B","$_attr_input_checked_script":"D","$_attr_input_checkedValue":"V","$_attr_input_checkedValue_script":"F","$_attr_input_value":"U","$_attr_input_value_script":"W","$_attr_select_value":"z","$_attr_select_value_script":"G","$setSelectOptions":"P","$_attr_details_or_dialog_open":"H","$_attr_details_or_dialog_open_script":"J","$inputType":"K","$setValueAndUpdateSelection":"X","$setCheckboxValue":"Z","$controllableDelegate":"Q","$syncControllable":"Y","$handleChange":"ee","$handleFormReset":"te","$hasValueChanged":"ne","$hasCheckboxChanged":"re","$hasSelectChanged":"le","$hasFormElementChanged":"oe","$normalizeStrProp":"ie","$normalizeBoolProp":"ue","$toValueProp":"fe","$isScheduled":"ae","$channel":"ce","$parsers":"se","$parseHTML":"de","$schedule":"he","$flushAndWaitFrame":"ge","$triggerMacroTask":"pe","$_let":"ve","$_const":"be","$_or":"me","$_for_closure":"ye","$_if_closure":"ke","$subscribeToScopeSet":"Ce","$_closure":"Ne","$_closure_get":"we","$closure":"_e","$_var":"Ae","$_return":"Se","$_return_change":"xe","$_var_change":"Me","$tagIdsByGlobal":"Ie","$_id":"$e","$_script":"je","$traverseAllHoisted":"Ee","$_hoist":"Te","$createBranch":"Le","$createAndSetupBranch":"Oe","$setupBranch":"Re","$_content":"qe","$_content_resume":"Be","$_content_closures":"De","$_content_branch":"Ve","$cloneCache":"Fe","$_attr":"Ue","$setAttribute":"We","$_attr_class":"ze","$_attr_class_items":"Ge","$_attr_class_item":"Pe","$_attr_style":"He","$_attr_style_items":"Je","$_attr_style_item":"Ke","$_text":"Xe","$_text_content":"Ze","$_attrs":"Qe","$_attrs_content":"Ye","$hasAttrAlias":"et","$_attrs_partial":"tt","$_attrs_partial_content":"nt","$attrsInternal":"rt","$_attr_content":"lt","$_attrs_script":"ot","$_html":"it","$normalizeAttrValue":"ut","$normalizeString":"ft","$_lifecycle":"at","$removeChildNodes":"ct","$insertChildNodes":"st","$toInsertNode":"dt","$_await":"ht","$_try":"gt","$renderCatch":"pt","$_if":"vt","$_dynamic_tag":"bt","$setConditionalRenderer":"mt","$_for_of":"yt","$_for_in":"kt","$_for_to":"Ct","$loop":"Nt","$createBranchWithTagNameOrRenderer":"wt","$bySecondArg":"_t","$byFirstArg":"At","$rendering":"St","$pendingRenders":"xt","$pendingRendersLookup":"Mt","$caughtError":"It","$placeholderShown":"$t","$pendingEffects":"jt","$pendingScopes":"Et","$scopeKeyOffset":"Tt","$queueRender":"Lt","$queueEffect":"Ot","$run":"Rt","$prepareEffects":"qt","$runEffects":"Bt","$runRenders":"Dt","$runRender":"Vt","$_enable_catch":"Ft","$$signalReset":"Ut","$$signal":"Wt","$abort":"zt","$classIdToBranch":"Gt","$compat":"Pt","$_template":"Ht","$mount":"Jt","$$clickCount__script":"Xt","$$clickCount":"Kt","$$setup":"Qt","$$if_content__setup":"ss","$$if_content__comment_comments__OR__id":"ts","$$if_content__comment_comments":"as","$$if_content__id":"ns","$$if_content":"ls","$$for_content__id":"os","$$for_content__input_path__OR__i":"cs","$$for_content__input_path":"ms","$$for_content__i":"is","$$for_content__open__script":"es","$$for_content__open":"us","$$for_content__setup":"bs","$$for_content__comment_text":"hs","$$for_content__if":"ps","$$for_content__comment_comments":"_s","$$for_content__$params":"ds","$$for_content__comment":"fs","$$for":"rs","$$input_comments":"gs","$$input$1":"js","$$input_path":"ks","$forUntil":"Zt","$_for_until":"Yt"}}}
1+
{"vars":{"props":{"$empty":"e","$rest":"t","$attrTag":"n","$attrTags":"r","$attrTagIterator":"l","$forIn":"o","$forOf":"i","$forTo":"u","$stringifyClassObject":"f","$stringifyStyleObject":"a","$toDelimitedString":"c","$isEventHandler":"s","$getEventHandlerName":"d","$normalizeDynamicRenderer":"h","$defaultDelegator":"g","$_on":"p","$createDelegator":"v","$handleDelegated":"b","$stripSpacesAndPunctuation":"m","$createScope":"y","$skipScope":"k","$findBranchWithKey":"C","$destroyBranch":"N","$destroyNestedBranches":"w","$removeAndDestroyBranch":"_","$insertBranchBefore":"A","$tempDetachBranch":"S","$walker":"x","$walk":"M","$walkInternal":"I","$branchesEnabled":"$","$isResuming":"j","$registeredValues":"E","$enableBranches":"T","$init":"L","$_resume":"O","$_var_resume":"R","$_el":"q","$_attr_input_checked":"B","$_attr_input_checked_script":"D","$_attr_input_checkedValue":"V","$_attr_input_checkedValue_script":"F","$_attr_input_value":"U","$_attr_input_value_script":"W","$_attr_select_value":"z","$_attr_select_value_script":"G","$setSelectOptions":"P","$_attr_details_or_dialog_open":"H","$_attr_details_or_dialog_open_script":"J","$inputType":"K","$setValueAndUpdateSelection":"X","$setCheckboxValue":"Z","$controllableDelegate":"Q","$syncControllable":"Y","$handleChange":"ee","$handleFormReset":"te","$hasValueChanged":"ne","$hasCheckboxChanged":"re","$hasSelectChanged":"le","$hasFormElementChanged":"oe","$normalizeStrProp":"ie","$normalizeBoolProp":"ue","$toValueProp":"fe","$isScheduled":"ae","$channel":"ce","$parsers":"se","$parseHTML":"de","$schedule":"he","$flushAndWaitFrame":"ge","$triggerMacroTask":"pe","$_let":"ve","$_const":"be","$_or":"me","$_for_closure":"ye","$_if_closure":"ke","$subscribeToScopeSet":"Ce","$_closure":"Ne","$_closure_get":"we","$closure":"_e","$_var":"Ae","$_return":"Se","$_return_change":"xe","$_var_change":"Me","$tagIdsByGlobal":"Ie","$_id":"$e","$_script":"je","$traverseAllHoisted":"Ee","$_hoist":"Te","$createBranch":"Le","$createAndSetupBranch":"Oe","$setupBranch":"Re","$_content":"qe","$_content_resume":"Be","$_content_closures":"De","$_content_branch":"Ve","$cloneCache":"Fe","$_attr":"Ue","$setAttribute":"We","$_attr_class":"ze","$_attr_class_items":"Ge","$_attr_class_item":"Pe","$_attr_style":"He","$_attr_style_items":"Je","$_attr_style_item":"Ke","$_text":"Xe","$_text_content":"Ze","$_attrs":"Qe","$_attrs_content":"Ye","$hasAttrAlias":"et","$_attrs_partial":"tt","$_attrs_partial_content":"nt","$attrsInternal":"rt","$_attr_content":"lt","$_attrs_script":"ot","$_html":"it","$normalizeAttrValue":"ut","$normalizeString":"ft","$_lifecycle":"at","$removeChildNodes":"ct","$insertChildNodes":"st","$toInsertNode":"dt","$_await":"ht","$_try":"gt","$renderCatch":"pt","$_if":"vt","$_dynamic_tag":"bt","$setConditionalRenderer":"mt","$_for_of":"yt","$_for_in":"kt","$_for_to":"Ct","$loop":"Nt","$createBranchWithTagNameOrRenderer":"wt","$bySecondArg":"_t","$byFirstArg":"At","$rendering":"St","$pendingRenders":"xt","$pendingRendersLookup":"Mt","$caughtError":"It","$placeholderShown":"$t","$pendingEffects":"jt","$pendingScopes":"Et","$scopeKeyOffset":"Tt","$queueRender":"Lt","$queueEffect":"Ot","$run":"Rt","$prepareEffects":"qt","$runEffects":"Bt","$runRenders":"Dt","$runRender":"Vt","$_enable_catch":"Ft","$$signalReset":"Ut","$$signal":"Wt","$abort":"zt","$classIdToBranch":"Gt","$compat":"Pt","$_template":"Ht","$mount":"Jt","$$clickCount__script":"Xt","$$clickCount":"Kt","$$setup":"Qt","$$if_content__setup":"ss","$$if_content__comment_comments__OR__id":"ts","$$if_content__comment_comments":"as","$$if_content__id":"ns","$$if_content":"ls","$$for_content__id":"os","$$for_content__input_path__OR__i":"cs","$$for_content__input_path":"ms","$$for_content__i":"is","$$for_content__open__script":"es","$$for_content__open":"us","$$for_content__setup":"bs","$$for_content__comment_text":"hs","$$for_content__if":"ps","$$for_content__comment_comments":"_s","$$for_content__$params":"ds","$$for_content__comment":"fs","$$for":"rs","$$input_comments":"gs","$$input$1":"js","$$input_path":"ks","$forUntil":"Zt","$_for_until":"Yt","$_child_setup":"en"}}}

packages/compiler/src/babel-utils/imports.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ export function importStar(file, request, nameHint) {
127127
}
128128

129129
function getImports(file) {
130+
if (file.___compileStage !== "translate") {
131+
throw new Error("Unable to add an import outside of translate");
132+
}
130133
let imports = file.metadata.marko[IMPORTS_KEY];
131134

132135
if (!imports) {

packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/dom.expected/tags/recurse.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@ export const $template = "<!><!><!>";
22
export const $walks = /* over(1), replace, over(2) */"b%c";
33
export const $setup = () => {};
44
import * as _ from "@marko/runtime-tags/debug/dom";
5-
import { $template as _recurse_template, $walks as _recurse_walks } from "./recurse.marko";
65
_._enable_catch();
76
const $placeholder_content = _._content_resume("__tests__/tags/recurse.marko_4_content", "LOADING...", /* over(1) */"b");
87
const $await_content__setup = $scope => {
98
$setup($scope["#childScope/0"]);
109
$await_content__input_level($scope);
1110
};
12-
const $await_content__input_level = /* @__PURE__ */_._closure_get("input_level", ($scope, input_level) => $input($scope["#childScope/0"], {
13-
level: input_level - 1
14-
}), $scope => $scope._._._);
15-
const $await_content = /* @__PURE__ */_._content_branch(`<!>${_recurse_template}<!>`, /* over(1), beginChild, _recurse_walks, endChild, over(1) */`b/${_recurse_walks}&b`, $await_content__setup);
11+
const $await_content__input_level = /* @__PURE__ */_._closure_get("input_level", ($scope, input_level) => $input_level($scope["#childScope/0"], input_level - 1), $scope => $scope._._._);
12+
const $await_content = /* @__PURE__ */_._content_branch(`<!>${$template}<!>`, /* over(1), beginChild, $walks, endChild, over(1) */`b/${$walks}&b`, $await_content__setup);
1613
const $try_content__await = /* @__PURE__ */_._await("#text/0", $await_content);
1714
const $try_content__setup = $scope => {
1815
$try_content__await($scope, new Promise(setImmediate));

packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/html.expected/tags/recurse.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as _ from "@marko/runtime-tags/debug/html";
2-
const $content = (input, $serialize) => {
2+
const $content = input => {
3+
const $serialize = _._get_serialize_reason();
34
const $scope0_id = _._scope_id();
45
const $input_level__closures = new Set();
56
_._if(() => {
@@ -8,9 +9,11 @@ const $content = (input, $serialize) => {
89
_._html(`<div${_._attr("data-level", input.level)}>`);
910
_._try($scope1_id, "#text/1", _._content_resume("__tests__/tags/recurse.marko_2_content", () => {
1011
const $scope2_id = _._scope_id();
12+
const $serialize2 = _._get_serialize_reason();
1113
_._await($scope2_id, "#text/0", new Promise(setImmediate), () => {
1214
const $scope3_id = _._scope_id();
1315
const $childScope = _._peek_scope_id();
16+
_._set_serialize_reason(_._serialize_guard($serialize, /* input.level */0));
1417
$content({
1518
level: input.level - 1
1619
});

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as _ from "@marko/runtime-tags/debug/html";
2-
export default _._template("__tests__/tags/custom-tag/index.marko", (input, $serialize) => {
2+
export default _._template("__tests__/tags/custom-tag/index.marko", input => {
3+
const $serialize = _._get_serialize_reason();
34
const $scope0_id = _._scope_id();
45
const {
56
thing: {

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as _ from "@marko/runtime-tags/debug/html";
22
import _customTag from "./tags/custom-tag/index.marko";
3-
export default _._template("__tests__/template.marko", (input, $serialize) => {
3+
export default _._template("__tests__/template.marko", input => {
4+
const $serialize = _._get_serialize_reason();
45
const $scope0_id = _._scope_id();
56
const {
67
x
@@ -24,14 +25,15 @@ export default _._template("__tests__/template.marko", (input, $serialize) => {
2425
}, $scope0_id)
2526
});
2627
}
27-
_customTag({
28-
thing: $thing
29-
}, {
28+
_._set_serialize_reason({
3029
/* input.thing.x, input.thing.content */0: _._serialize_guard($serialize, /* x */0),
3130
/* input.thing.x */1: _._serialize_guard($serialize, /* x */0),
3231
/* input.thing.content */2: _._serialize_guard($serialize, /* x */0)
3332
});
33+
_customTag({
34+
thing: $thing
35+
});
3436
_._serialize_guard($serialize, /* x */0) && _._scope($scope0_id, {
35-
"#childScope/0": _._serialize_if($serialize, /* input.x */0) && _._existing_scope($childScope)
37+
"#childScope/0": _._serialize_if($serialize, /* x */0) && _._existing_scope($childScope)
3638
}, "__tests__/template.marko", 0);
3739
});

0 commit comments

Comments
 (0)