Skip to content

Commit 3e178a3

Browse files
committed
tidy up
1 parent 9823f91 commit 3e178a3

File tree

1 file changed

+11
-15
lines changed
  • packages/svelte/src/compiler/phases/3-transform

1 file changed

+11
-15
lines changed

packages/svelte/src/compiler/phases/3-transform/utils.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ function sort_const_tags(nodes, state) {
3535
/**
3636
* @typedef {{
3737
* node: import('#compiler').ConstTag;
38-
* ids: import('#compiler').Binding[];
3938
* deps: Set<import('#compiler').Binding>;
4039
* }} Tag
4140
*/
@@ -51,19 +50,12 @@ function sort_const_tags(nodes, state) {
5150
if (node.type === 'ConstTag') {
5251
const declaration = node.declaration.declarations[0];
5352

54-
/** @type {Tag} */
55-
const tag = {
56-
node,
57-
ids: extract_identifiers(declaration.id).map((id) => {
58-
return /** @type {import('#compiler').Binding} */ (state.scope.get(id.name));
59-
}),
60-
/** @type {Set<import('#compiler').Binding>} */
61-
deps: new Set()
62-
};
63-
64-
for (const id of tag.ids) {
65-
tags.set(id, tag);
66-
}
53+
const bindings = extract_identifiers(declaration.id).map((id) => {
54+
return /** @type {import('#compiler').Binding} */ (state.scope.get(id.name));
55+
});
56+
57+
/** @type {Set<import('#compiler').Binding>} */
58+
const deps = new Set();
6759

6860
walk(declaration.init, state, {
6961
_,
@@ -72,10 +64,14 @@ function sort_const_tags(nodes, state) {
7264

7365
if (is_reference(node, parent)) {
7466
const binding = context.state.scope.get(node.name);
75-
if (binding) tag.deps.add(binding);
67+
if (binding) deps.add(binding);
7668
}
7769
}
7870
});
71+
72+
for (const binding of bindings) {
73+
tags.set(binding, { node, deps });
74+
}
7975
} else {
8076
other.push(node);
8177
}

0 commit comments

Comments
 (0)