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

function handleMessage(payload) {
alert(payload.text);
}
</script>

<Inner onMessage={handleMessage} />

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 Inner from './Inner.svelte';

export default function App($$anchor) {
function handleMessage(payload) {
alert(payload.text);
}

Inner($$anchor, { onMessage: handleMessage });
}
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • Root {
    • css: null
    • js: []
    • start: 119
    • end: 154
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (2)
        • Text {...}
          • type: "Text"
          • start: 117
          • end: 119
          • raw: "\n\n"
          • data: "\n\n"
          }
        • Component {...}
          • type: "Component"
          • start: 119
          • end: 154
          • name: "Inner"
          • attributes: [...] (1)
            • Attribute {...}
              • type: "Attribute"
              • start: 126
              • end: 151
              • name: "onMessage"
              • value: ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 136
                • end: 151
                • expression: Identifier {...}
                  • type: "Identifier"
                  • start: 137
                  • end: 150
                  • loc: {...}
                    • start: {...}
                      • line: 9
                      • column: 18
                      }
                    • end: {...}
                      • line: 9
                      • column: 31
                      }
                    }
                  • name: "handleMessage"
                  }
                }
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: []
            }
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 117
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 108
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 7
            • column: 0
            }
          }
        • body: [...] (2)
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 10
            • end: 45
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 36
                }
              }
            • specifiers: [...] (1)
              • ImportDefaultSpecifier {...}
                • type: "ImportDefaultSpecifier"
                • start: 17
                • end: 22
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 8
                    }
                  • end: {...}
                    • line: 2
                    • column: 13
                    }
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 17
                  • end: 22
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 8
                      }
                    • end: {...}
                      • line: 2
                      • column: 13
                      }
                    }
                  • name: "Inner"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 28
              • end: 44
              • loc: {...}
                • start: {...}
                  • line: 2
                  • column: 19
                  }
                • end: {...}
                  • line: 2
                  • column: 35
                  }
                }
              • value: "./Inner.svelte"
              • raw: "'./Inner.svelte'"
              }
            }
          • FunctionDeclaration {...}
            • type: "FunctionDeclaration"
            • start: 48
            • end: 107
            • loc: {...}
              • start: {...}
                • line: 4
                • column: 1
                }
              • end: {...}
                • line: 6
                • column: 2
                }
              }
            • id: Identifier {...}
              • type: "Identifier"
              • start: 57
              • end: 70
              • loc: {...}
                • start: {...}
                  • line: 4
                  • column: 10
                  }
                • end: {...}
                  • line: 4
                  • column: 23
                  }
                }
              • name: "handleMessage"
              }
            • expression: false
            • generator: false
            • async: false
            • params: [...] (1)
              • Identifier {...}
                • type: "Identifier"
                • start: 71
                • end: 78
                • loc: {...}
                  • start: {...}
                    • line: 4
                    • column: 24
                    }
                  • end: {...}
                    • line: 4
                    • column: 31
                    }
                  }
                • name: "payload"
                }
              ]
            • body: BlockStatement {...}
              • type: "BlockStatement"
              • start: 80
              • end: 107
              • loc: {...}
                • start: {...}
                  • line: 4
                  • column: 33
                  }
                • end: {...}
                  • line: 6
                  • column: 2
                  }
                }
              • body: [...] (1)
                • ExpressionStatement {...}
                  • type: "ExpressionStatement"
                  • start: 84
                  • end: 104
                  • loc: {...}
                    • start: {...}
                      • line: 5
                      • column: 2
                      }
                    • end: {...}
                      • line: 5
                      • column: 22
                      }
                    }
                  • expression: CallExpression {...}
                    • type: "CallExpression"
                    • start: 84
                    • end: 103
                    • loc: {...}
                      • start: {...}
                        • line: 5
                        • column: 2
                        }
                      • end: {...}
                        • line: 5
                        • column: 21
                        }
                      }
                    • callee: Identifier {...}
                      • type: "Identifier"
                      • start: 84
                      • end: 89
                      • loc: {...}
                        • start: {...}
                          • line: 5
                          • column: 2
                          }
                        • end: {...}
                          • line: 5
                          • column: 7
                          }
                        }
                      • name: "alert"
                      }
                    • arguments: [...] (1)
                      • MemberExpression {...}
                        • type: "MemberExpression"
                        • start: 90
                        • end: 102
                        • loc: {...}
                          • start: {...}
                            • line: 5
                            • column: 8
                            }
                          • end: {...}
                            • line: 5
                            • column: 20
                            }
                          }
                        • object: Identifier {...}
                          • type: "Identifier"
                          • start: 90
                          • end: 97
                          • loc: {...}
                            • start: {...}
                              • line: 5
                              • column: 8
                              }
                            • end: {...}
                              • line: 5
                              • column: 15
                              }
                            }
                          • name: "payload"
                          }
                        • property: Identifier {...}
                          • type: "Identifier"
                          • start: 98
                          • end: 102
                          • loc: {...}
                            • start: {...}
                              • line: 5
                              • column: 16
                              }
                            • end: {...}
                              • line: 5
                              • column: 20
                              }
                            }
                          • name: "text"
                          }
                        • computed: false
                        • optional: false
                        }
                      ]
                    • optional: false
                    }
                  }
                ]
              }
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
Component events • Playground • Svelte