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 name = $state('');
</script>

<input bind:value={name} placeholder="enter your name" />
<p>Hello {name || 'stranger'}!</p>

Error compiling component

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

var root = $.template(`<input placeholder="enter your name"> <p> </p>`, 1);

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

$.remove_input_defaults(input);

var p = $.sibling(input, 2);
var text = $.child(p);

$.reset(p);
$.template_effect(() => $.set_text(text, `Hello ${$.get(name) || 'stranger'}!`));
$.bind_value(input, () => $.get(name), ($$value) => $.set(name, $$value));
$.append($$anchor, fragment);
}
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • Root {
    • css: null
    • js: []
    • start: 44
    • end: 136
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (4)
        • Text {...}
          • type: "Text"
          • start: 42
          • end: 44
          • raw: "\n\n"
          • data: "\n\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 44
          • end: 101
          • name: "input"
          • attributes: [...] (2)
            • BindDirective {...}
              • start: 51
              • end: 68
              • type: "BindDirective"
              • name: "value"
              • expression: Identifier {...}
                • type: "Identifier"
                • start: 63
                • end: 67
                • loc: {...}
                  • start: {...}
                    • line: 5
                    • column: 19
                    }
                  • end: {...}
                    • line: 5
                    • column: 23
                    }
                  }
                • name: "name"
                }
              • modifiers: []
              }
            • Attribute {...}
              • type: "Attribute"
              • start: 69
              • end: 98
              • name: "placeholder"
              • value: [...] (1)
                • Text {...}
                  • start: 82
                  • end: 97
                  • type: "Text"
                  • raw: "enter your name"
                  • data: "enter your name"
                  }
                ]
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: []
            }
          }
        • Text {...}
          • type: "Text"
          • start: 101
          • end: 102
          • raw: " "
          • data: " "
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 102
          • end: 136
          • name: "p"
          • attributes: []
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (3)
              • Text {...}
                • type: "Text"
                • start: 105
                • end: 111
                • raw: "Hello "
                • data: "Hello "
                }
              • ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 111
                • end: 131
                • expression: LogicalExpression {...}
                  • type: "LogicalExpression"
                  • start: 112
                  • end: 130
                  • loc: {...}
                    • start: {...}
                      • line: 6
                      • column: 10
                      }
                    • end: {...}
                      • line: 6
                      • column: 28
                      }
                    }
                  • left: Identifier {...}
                    • type: "Identifier"
                    • start: 112
                    • end: 116
                    • loc: {...}
                      • start: {...}
                        • line: 6
                        • column: 10
                        }
                      • end: {...}
                        • line: 6
                        • column: 14
                        }
                      }
                    • name: "name"
                    }
                  • operator: "||"
                  • right: Literal {...}
                    • type: "Literal"
                    • start: 120
                    • end: 130
                    • loc: {...}
                      • start: {...}
                        • line: 6
                        • column: 18
                        }
                      • end: {...}
                        • line: 6
                        • column: 28
                        }
                      }
                    • value: "stranger"
                    • raw: "'stranger'"
                    }
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 131
                • end: 132
                • raw: "!"
                • data: "!"
                }
              ]
            }
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 42
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 33
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 3
            • column: 0
            }
          }
        • body: [...] (1)
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 10
            • end: 32
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 23
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 14
                • end: 31
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 5
                    }
                  • end: {...}
                    • line: 2
                    • column: 22
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 14
                  • end: 18
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 5
                      }
                    • end: {...}
                      • line: 2
                      • column: 9
                      }
                    }
                  • name: "name"
                  }
                • init: CallExpression {...}
                  • type: "CallExpression"
                  • start: 21
                  • end: 31
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 12
                      }
                    • end: {...}
                      • line: 2
                      • column: 22
                      }
                    }
                  • callee: Identifier {...}
                    • type: "Identifier"
                    • start: 21
                    • end: 27
                    • loc: {...}
                      • start: {...}
                        • line: 2
                        • column: 12
                        }
                      • end: {...}
                        • line: 2
                        • column: 18
                        }
                      }
                    • name: "$state"
                    }
                  • arguments: [...] (1)
                    • Literal {...}
                      • type: "Literal"
                      • start: 28
                      • end: 30
                      • loc: {...}
                        • start: {...}
                          • line: 2
                          • column: 19
                          }
                        • end: {...}
                          • line: 2
                          • column: 21
                          }
                        }
                      • value: ""
                      • raw: "''"
                      }
                    ]
                  • optional: false
                  }
                }
              ]
            • kind: "let"
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
Text inputs • Playground • Svelte