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
<script>
let user = $state({
firstname: 'Ada',
lastname: 'Lovelace'
});
</script>

<input bind:value={user.firstname} />
<input bind:value={user.lastname} />

{@debug user}

<h1>Hello {user.firstname}!</h1>

Error compiling component

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

var root = $.template(`<input> <input> <h1> </h1>`, 1);

export default function App($$anchor) {
let user = $.proxy({ firstname: 'Ada', lastname: 'Lovelace' });
var fragment = root();

$.template_effect(() => {
console.log({ user: $.snapshot(user) });
debugger;
});

var input = $.first_child(fragment);

$.remove_input_defaults(input);

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

$.remove_input_defaults(input_1);

var h1 = $.sibling(input_1, 2);
var text = $.child(h1);

$.reset(h1);
$.template_effect(() => $.set_text(text, `Hello ${user.firstname ?? ''}!`));
$.bind_value(input, () => user.firstname, ($$value) => user.firstname = $$value);
$.bind_value(input_1, () => user.lastname, ($$value) => user.lastname = $$value);
$.append($$anchor, fragment);
}
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • Root {
    • css: null
    • js: []
    • start: 89
    • end: 212
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (8)
        • Text {...}
          • type: "Text"
          • start: 87
          • end: 89
          • raw: "\n\n"
          • data: "\n\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 89
          • end: 126
          • name: "input"
          • attributes: [...] (1)
            • BindDirective {...}
              • start: 96
              • end: 123
              • type: "BindDirective"
              • name: "value"
              • expression: MemberExpression {...}
                • type: "MemberExpression"
                • start: 108
                • end: 122
                • loc: {...}
                  • start: {...}
                    • line: 8
                    • column: 19
                    }
                  • end: {...}
                    • line: 8
                    • column: 33
                    }
                  }
                • object: Identifier {...}
                  • type: "Identifier"
                  • start: 108
                  • end: 112
                  • loc: {...}
                    • start: {...}
                      • line: 8
                      • column: 19
                      }
                    • end: {...}
                      • line: 8
                      • column: 23
                      }
                    }
                  • name: "user"
                  }
                • property: Identifier {...}
                  • type: "Identifier"
                  • start: 113
                  • end: 122
                  • loc: {...}
                    • start: {...}
                      • line: 8
                      • column: 24
                      }
                    • end: {...}
                      • line: 8
                      • column: 33
                      }
                    }
                  • name: "firstname"
                  }
                • computed: false
                • optional: false
                }
              • modifiers: []
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: []
            }
          }
        • Text {...}
          • type: "Text"
          • start: 126
          • end: 127
          • raw: " "
          • data: " "
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 127
          • end: 163
          • name: "input"
          • attributes: [...] (1)
            • BindDirective {...}
              • start: 134
              • end: 160
              • type: "BindDirective"
              • name: "value"
              • expression: MemberExpression {...}
                • type: "MemberExpression"
                • start: 146
                • end: 159
                • loc: {...}
                  • start: {...}
                    • line: 9
                    • column: 19
                    }
                  • end: {...}
                    • line: 9
                    • column: 32
                    }
                  }
                • object: Identifier {...}
                  • type: "Identifier"
                  • start: 146
                  • end: 150
                  • loc: {...}
                    • start: {...}
                      • line: 9
                      • column: 19
                      }
                    • end: {...}
                      • line: 9
                      • column: 23
                      }
                    }
                  • name: "user"
                  }
                • property: Identifier {...}
                  • type: "Identifier"
                  • start: 151
                  • end: 159
                  • loc: {...}
                    • start: {...}
                      • line: 9
                      • column: 24
                      }
                    • end: {...}
                      • line: 9
                      • column: 32
                      }
                    }
                  • name: "lastname"
                  }
                • computed: false
                • optional: false
                }
              • modifiers: []
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: []
            }
          }
        • Text {...}
          • type: "Text"
          • start: 163
          • end: 165
          • raw: " "
          • data: " "
          }
        • DebugTag {...}
          • type: "DebugTag"
          • start: 165
          • end: 178
          • identifiers: [...] (1)
            • Identifier {...}
              • type: "Identifier"
              • start: 173
              • end: 177
              • loc: {...}
                • start: {...}
                  • line: 11
                  • column: 8
                  }
                • end: {...}
                  • line: 11
                  • column: 12
                  }
                }
              • name: "user"
              }
            ]
          }
        • Text {...}
          • type: "Text"
          • start: 178
          • end: 180
          • raw: ""
          • data: ""
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 180
          • end: 212
          • name: "h1"
          • attributes: []
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (3)
              • Text {...}
                • type: "Text"
                • start: 184
                • end: 190
                • raw: "Hello "
                • data: "Hello "
                }
              • ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 190
                • end: 206
                • expression: MemberExpression {...}
                  • type: "MemberExpression"
                  • start: 191
                  • end: 205
                  • loc: {...}
                    • start: {...}
                      • line: 13
                      • column: 11
                      }
                    • end: {...}
                      • line: 13
                      • column: 25
                      }
                    }
                  • object: Identifier {...}
                    • type: "Identifier"
                    • start: 191
                    • end: 195
                    • loc: {...}
                      • start: {...}
                        • line: 13
                        • column: 11
                        }
                      • end: {...}
                        • line: 13
                        • column: 15
                        }
                      }
                    • name: "user"
                    }
                  • property: Identifier {...}
                    • type: "Identifier"
                    • start: 196
                    • end: 205
                    • loc: {...}
                      • start: {...}
                        • line: 13
                        • column: 16
                        }
                      • end: {...}
                        • line: 13
                        • column: 25
                        }
                      }
                    • name: "firstname"
                    }
                  • computed: false
                  • optional: false
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 206
                • end: 207
                • raw: "!"
                • data: "!"
                }
              ]
            }
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 87
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 78
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 6
            • column: 0
            }
          }
        • body: [...] (1)
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 10
            • end: 77
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 5
                • column: 4
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 14
                • end: 76
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 5
                    }
                  • end: {...}
                    • line: 5
                    • column: 3
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 14
                  • end: 18
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 5
                      }
                    • end: {...}
                      • line: 2
                      • column: 9
                      }
                    }
                  • name: "user"
                  }
                • init: CallExpression {...}
                  • type: "CallExpression"
                  • start: 21
                  • end: 76
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 12
                      }
                    • end: {...}
                      • line: 5
                      • column: 3
                      }
                    }
                  • callee: Identifier {...}
                    • type: "Identifier"
                    • start: 21
                    • end: 27
                    • loc: {...}
                      • start: {...}
                        • line: 2
                        • column: 12
                        }
                      • end: {...}
                        • line: 2
                        • column: 18
                        }
                      }
                    • name: "$state"
                    }
                  • arguments: [...] (1)
                    • ObjectExpression {...}
                      • type: "ObjectExpression"
                      • start: 28
                      • end: 75
                      • loc: {...}
                        • start: {...}
                          • line: 2
                          • column: 19
                          }
                        • end: {...}
                          • line: 5
                          • column: 2
                          }
                        }
                      • properties: [...] (2)
                        • Property {...}
                          • type: "Property"
                          • start: 32
                          • end: 48
                          • loc: {...}
                            • start: {...}
                              • line: 3
                              • column: 2
                              }
                            • end: {...}
                              • line: 3
                              • column: 18
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 32
                            • end: 41
                            • loc: {...}
                              • start: {...}
                                • line: 3
                                • column: 2
                                }
                              • end: {...}
                                • line: 3
                                • column: 11
                                }
                              }
                            • name: "firstname"
                            }
                          • value: Literal {...}
                            • type: "Literal"
                            • start: 43
                            • end: 48
                            • loc: {...}
                              • start: {...}
                                • line: 3
                                • column: 13
                                }
                              • end: {...}
                                • line: 3
                                • column: 18
                                }
                              }
                            • value: "Ada"
                            • raw: "'Ada'"
                            }
                          • kind: "init"
                          }
                        • Property {...}
                          • type: "Property"
                          • start: 52
                          • end: 72
                          • loc: {...}
                            • start: {...}
                              • line: 4
                              • column: 2
                              }
                            • end: {...}
                              • line: 4
                              • column: 22
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 52
                            • end: 60
                            • loc: {...}
                              • start: {...}
                                • line: 4
                                • column: 2
                                }
                              • end: {...}
                                • line: 4
                                • column: 10
                                }
                              }
                            • name: "lastname"
                            }
                          • value: Literal {...}
                            • type: "Literal"
                            • start: 62
                            • end: 72
                            • loc: {...}
                              • start: {...}
                                • line: 4
                                • column: 12
                                }
                              • end: {...}
                                • line: 4
                                • column: 22
                                }
                              }
                            • value: "Lovelace"
                            • raw: "'Lovelace'"
                            }
                          • kind: "init"
                          }
                        ]
                      }
                    ]
                  • optional: false
                  }
                }
              ]
            • kind: "let"
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
The @debug tag • Playground • Svelte