Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
<!-- https://eugenkiss.github.io/7guis/tasks#counter -->
<script>
let count = $state(0);
</script>

<input type="number" bind:value={count} />
<button onclick={() => (count += 1)}>count</button>

Error compiling component

WebAssembly.instantiateStreaming(): value type opcode @+13
import 'svelte/internal/disclose-version';
import * as $ from 'svelte/internal/client';

var on_click = (_, count) => $.set(count, $.get(count) + 1);
var root = $.template(`<input type="number"> <button>count</button>`, 1);

export default function App($$anchor) {
let count = $.state(0);
var fragment = root();
var input = $.first_child(fragment);

$.remove_input_defaults(input);

var button = $.sibling(input, 2);

button.__click = [on_click, count];
$.bind_value(input, () => $.get(count), ($$value) => $.set(count, $$value));
$.append($$anchor, fragment);
}

$.delegate(['click']);
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • Root {
    • css: null
    • js: []
    • start: 0
    • end: 195
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (6)
        • Comment {...}
          • type: "Comment"
          • start: 0
          • end: 56
          • data: " https://eugenkiss.github.io/7guis/tasks#counter "
          }
        • Text {...}
          • type: "Text"
          • start: 56
          • end: 57
          • raw: "\n"
          • data: "\n"
          }
        • Text {...}
          • type: "Text"
          • start: 99
          • end: 101
          • raw: "\n\n"
          • data: "\n\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 101
          • end: 143
          • name: "input"
          • attributes: [...] (2)
            • Attribute {...}
              • type: "Attribute"
              • start: 108
              • end: 121
              • name: "type"
              • value: [...] (1)
                • Text {...}
                  • start: 114
                  • end: 120
                  • type: "Text"
                  • raw: "number"
                  • data: "number"
                  }
                ]
              }
            • BindDirective {...}
              • start: 122
              • end: 140
              • type: "BindDirective"
              • name: "value"
              • expression: Identifier {...}
                • type: "Identifier"
                • start: 134
                • end: 139
                • loc: {...}
                  • start: {...}
                    • line: 6
                    • column: 33
                    }
                  • end: {...}
                    • line: 6
                    • column: 38
                    }
                  }
                • name: "count"
                }
              • modifiers: []
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: []
            }
          }
        • Text {...}
          • type: "Text"
          • start: 143
          • end: 144
          • raw: " "
          • data: " "
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 144
          • end: 195
          • name: "button"
          • attributes: [...] (1)
            • Attribute {...}
              • type: "Attribute"
              • start: 152
              • end: 180
              • name: "onclick"
              • value: ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 160
                • end: 180
                • expression: ArrowFunctionExpression {...}
                  • type: "ArrowFunctionExpression"
                  • start: 161
                  • end: 179
                  • loc: {...}
                    • start: {...}
                      • line: 7
                      • column: 17
                      }
                    • end: {...}
                      • line: 7
                      • column: 35
                      }
                    }
                  • id: null
                  • expression: true
                  • generator: false
                  • async: false
                  • params: []
                  • body: AssignmentExpression {...}
                    • type: "AssignmentExpression"
                    • start: 168
                    • end: 178
                    • loc: {...}
                      • start: {...}
                        • line: 7
                        • column: 24
                        }
                      • end: {...}
                        • line: 7
                        • column: 34
                        }
                      }
                    • operator: "+="
                    • left: Identifier {...}
                      • type: "Identifier"
                      • start: 168
                      • end: 173
                      • loc: {...}
                        • start: {...}
                          • line: 7
                          • column: 24
                          }
                        • end: {...}
                          • line: 7
                          • column: 29
                          }
                        }
                      • name: "count"
                      }
                    • right: Literal {...}
                      • type: "Literal"
                      • start: 177
                      • end: 178
                      • loc: {...}
                        • start: {...}
                          • line: 7
                          • column: 33
                          }
                        • end: {...}
                          • line: 7
                          • column: 34
                          }
                        }
                      • value: 1
                      • raw: "1"
                      }
                    }
                  }
                }
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (1)
              • Text {...}
                • type: "Text"
                • start: 181
                • end: 186
                • raw: "count"
                • data: "count"
                }
              ]
            }
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 57
      • end: 99
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 65
        • end: 90
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 4
            • column: 0
            }
          }
        • body: [...] (1)
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 67
            • end: 89
            • loc: {...}
              • start: {...}
                • line: 3
                • column: 1
                }
              • end: {...}
                • line: 3
                • column: 23
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 71
                • end: 88
                • loc: {...}
                  • start: {...}
                    • line: 3
                    • column: 5
                    }
                  • end: {...}
                    • line: 3
                    • column: 22
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 71
                  • end: 76
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 5
                      }
                    • end: {...}
                      • line: 3
                      • column: 10
                      }
                    }
                  • name: "count"
                  }
                • init: CallExpression {...}
                  • type: "CallExpression"
                  • start: 79
                  • end: 88
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 13
                      }
                    • end: {...}
                      • line: 3
                      • column: 22
                      }
                    }
                  • callee: Identifier {...}
                    • type: "Identifier"
                    • start: 79
                    • end: 85
                    • loc: {...}
                      • start: {...}
                        • line: 3
                        • column: 13
                        }
                      • end: {...}
                        • line: 3
                        • column: 19
                        }
                      }
                    • name: "$state"
                    }
                  • arguments: [...] (1)
                    • Literal {...}
                      • type: "Literal"
                      • start: 86
                      • end: 87
                      • loc: {...}
                        • start: {...}
                          • line: 3
                          • column: 20
                          }
                        • end: {...}
                          • line: 3
                          • column: 21
                          }
                        }
                      • value: 0
                      • raw: "0"
                      }
                    ]
                  • optional: false
                  }
                }
              ]
            • kind: "let"
            }
          ]
        • sourceType: "module"
        • leadingComments: [...] (1)
          • Line {...}
            • type: "Line"
            • value: " https://eugenkiss.github.io/7guis/tasks#counter "
            }
          ]
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
Counter • Playground • Svelte