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
CustomButton.svelte
<script>
import CustomButton from './CustomButton.svelte';

function handleClick() {
alert('clicked');
}
</script>

<CustomButton onclick={handleClick} />

Error compiling component

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

export default function App($$anchor) {
function handleClick() {
alert('clicked');
}

CustomButton($$anchor, { onclick: handleClick });
}
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • Root {
    • css: null
    • js: []
    • start: 121
    • end: 159
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (2)
        • Text {...}
          • type: "Text"
          • start: 119
          • end: 121
          • raw: "\n\n"
          • data: "\n\n"
          }
        • Component {...}
          • type: "Component"
          • start: 121
          • end: 159
          • name: "CustomButton"
          • attributes: [...] (1)
            • Attribute {...}
              • type: "Attribute"
              • start: 135
              • end: 156
              • name: "onclick"
              • value: ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 143
                • end: 156
                • expression: Identifier {...}
                  • type: "Identifier"
                  • start: 144
                  • end: 155
                  • loc: {...}
                    • start: {...}
                      • line: 9
                      • column: 23
                      }
                    • end: {...}
                      • line: 9
                      • column: 34
                      }
                    }
                  • name: "handleClick"
                  }
                }
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: []
            }
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 119
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 110
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 7
            • column: 0
            }
          }
        • body: [...] (2)
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 10
            • end: 59
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 50
                }
              }
            • specifiers: [...] (1)
              • ImportDefaultSpecifier {...}
                • type: "ImportDefaultSpecifier"
                • start: 17
                • end: 29
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 8
                    }
                  • end: {...}
                    • line: 2
                    • column: 20
                    }
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 17
                  • end: 29
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 8
                      }
                    • end: {...}
                      • line: 2
                      • column: 20
                      }
                    }
                  • name: "CustomButton"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 35
              • end: 58
              • loc: {...}
                • start: {...}
                  • line: 2
                  • column: 26
                  }
                • end: {...}
                  • line: 2
                  • column: 49
                  }
                }
              • value: "./CustomButton.svelte"
              • raw: "'./CustomButton.svelte'"
              }
            }
          • FunctionDeclaration {...}
            • type: "FunctionDeclaration"
            • start: 62
            • end: 109
            • loc: {...}
              • start: {...}
                • line: 4
                • column: 1
                }
              • end: {...}
                • line: 6
                • column: 2
                }
              }
            • id: Identifier {...}
              • type: "Identifier"
              • start: 71
              • end: 82
              • loc: {...}
                • start: {...}
                  • line: 4
                  • column: 10
                  }
                • end: {...}
                  • line: 4
                  • column: 21
                  }
                }
              • name: "handleClick"
              }
            • expression: false
            • generator: false
            • async: false
            • params: []
            • body: BlockStatement {...}
              • type: "BlockStatement"
              • start: 85
              • end: 109
              • loc: {...}
                • start: {...}
                  • line: 4
                  • column: 24
                  }
                • end: {...}
                  • line: 6
                  • column: 2
                  }
                }
              • body: [...] (1)
                • ExpressionStatement {...}
                  • type: "ExpressionStatement"
                  • start: 89
                  • end: 106
                  • loc: {...}
                    • start: {...}
                      • line: 5
                      • column: 2
                      }
                    • end: {...}
                      • line: 5
                      • column: 19
                      }
                    }
                  • expression: CallExpression {...}
                    • type: "CallExpression"
                    • start: 89
                    • end: 105
                    • loc: {...}
                      • start: {...}
                        • line: 5
                        • column: 2
                        }
                      • end: {...}
                        • line: 5
                        • column: 18
                        }
                      }
                    • callee: Identifier {...}
                      • type: "Identifier"
                      • start: 89
                      • end: 94
                      • loc: {...}
                        • start: {...}
                          • line: 5
                          • column: 2
                          }
                        • end: {...}
                          • line: 5
                          • column: 7
                          }
                        }
                      • name: "alert"
                      }
                    • arguments: [...] (1)
                      • Literal {...}
                        • type: "Literal"
                        • start: 95
                        • end: 104
                        • loc: {...}
                          • start: {...}
                            • line: 5
                            • column: 8
                            }
                          • end: {...}
                            • line: 5
                            • column: 17
                            }
                          }
                        • value: "clicked"
                        • raw: "'clicked'"
                        }
                      ]
                    • optional: false
                    }
                  }
                ]
              }
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
DOM event forwarding • Playground • Svelte