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 m = $state({ x: 0, y: 0 });
</script>

<!-- svelte-ignore a11y_no_static_element_interactions -->
<div onmousemove={(e) => (m = { x: e.clientX, y: e.clientY })}>
The mouse position is {m.x} x {m.y}
</div>

<style>
div {
width: 100%;
height: 100%;
}
</style>

Error compiling component

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

var on_mousemove = (e, m) => $.set(m, $.proxy({ x: e.clientX, y: e.clientY }));
var root = $.template(`<div class="svelte-1c44y5p"> </div>`);

export default function App($$anchor) {
let m = $.state($.proxy({ x: 0, y: 0 }));
var div = root();

div.__mousemove = [on_mousemove, m];

var text = $.child(div);

$.reset(div);
$.template_effect(() => $.set_text(text, `The mouse position is ${$.get(m).x ?? ''} x ${$.get(m).y ?? ''}`));
$.append($$anchor, div);
}

$.delegate(['mousemove']);
result = svelte.compile(source, {
generate: ,
});

div.svelte-1c44y5p {
width: 100%;
height: 100%;
}

		
			
				
  • Root {
    • css: StyleSheet {...}
      • type: "StyleSheet"
      • start: 221
      • end: 278
      • attributes: []
      • children: [...] (1)
        • Rule {...}
          • type: "Rule"
          • prelude: SelectorList {...}
            • type: "SelectorList"
            • start: 230
            • end: 233
            • children: [...] (1)
              • ComplexSelector {...}
                • type: "ComplexSelector"
                • start: 230
                • end: 233
                • children: [...] (1)
                  • RelativeSelector {...}
                    • type: "RelativeSelector"
                    • combinator: null
                    • selectors: [...] (1)
                      • TypeSelector {...}
                        • type: "TypeSelector"
                        • name: "div"
                        • start: 230
                        • end: 233
                        }
                      ]
                    • start: 230
                    • end: 233
                    }
                  ]
                }
              ]
            }
          • block: Block {...}
            • type: "Block"
            • start: 234
            • end: 269
            • children: [...] (2)
              • Declaration {...}
                • type: "Declaration"
                • start: 238
                • end: 249
                • property: "width"
                • value: "100%"
                }
              • Declaration {...}
                • type: "Declaration"
                • start: 253
                • end: 265
                • property: "height"
                • value: "100%"
                }
              ]
            }
          • start: 230
          • end: 269
          }
        ]
      • content: {...}
        • start: 228
        • end: 270
        • styles: "\n\tdiv {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t}\n"
        • comment: null
        }
      }
    • js: []
    • start: 53
    • end: 219
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (5)
        • Text {...}
          • type: "Text"
          • start: 51
          • end: 53
          • raw: "\n\n"
          • data: "\n\n"
          }
        • Comment {...}
          • type: "Comment"
          • start: 53
          • end: 111
          • data: " svelte-ignore a11y_no_static_element_interactions "
          }
        • Text {...}
          • type: "Text"
          • start: 111
          • end: 112
          • raw: "\n"
          • data: "\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 112
          • end: 219
          • name: "div"
          • attributes: [...] (2)
            • Attribute {...}
              • type: "Attribute"
              • start: 117
              • end: 174
              • name: "onmousemove"
              • value: ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 129
                • end: 174
                • expression: ArrowFunctionExpression {...}
                  • type: "ArrowFunctionExpression"
                  • start: 130
                  • end: 173
                  • loc: {...}
                    • start: {...}
                      • line: 6
                      • column: 18
                      }
                    • end: {...}
                      • line: 6
                      • column: 61
                      }
                    }
                  • id: null
                  • expression: true
                  • generator: false
                  • async: false
                  • params: [...] (1)
                    • Identifier {...}
                      • type: "Identifier"
                      • start: 131
                      • end: 132
                      • loc: {...}
                        • start: {...}
                          • line: 6
                          • column: 19
                          }
                        • end: {...}
                          • line: 6
                          • column: 20
                          }
                        }
                      • name: "e"
                      }
                    ]
                  • body: AssignmentExpression {...}
                    • type: "AssignmentExpression"
                    • start: 138
                    • end: 172
                    • loc: {...}
                      • start: {...}
                        • line: 6
                        • column: 26
                        }
                      • end: {...}
                        • line: 6
                        • column: 60
                        }
                      }
                    • operator: "="
                    • left: Identifier {...}
                      • type: "Identifier"
                      • start: 138
                      • end: 139
                      • loc: {...}
                        • start: {...}
                          • line: 6
                          • column: 26
                          }
                        • end: {...}
                          • line: 6
                          • column: 27
                          }
                        }
                      • name: "m"
                      }
                    • right: ObjectExpression {...}
                      • type: "ObjectExpression"
                      • start: 142
                      • end: 172
                      • loc: {...}
                        • start: {...}
                          • line: 6
                          • column: 30
                          }
                        • end: {...}
                          • line: 6
                          • column: 60
                          }
                        }
                      • properties: [...] (2)
                        • Property {...}
                          • type: "Property"
                          • start: 144
                          • end: 156
                          • loc: {...}
                            • start: {...}
                              • line: 6
                              • column: 32
                              }
                            • end: {...}
                              • line: 6
                              • column: 44
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 144
                            • end: 145
                            • loc: {...}
                              • start: {...}
                                • line: 6
                                • column: 32
                                }
                              • end: {...}
                                • line: 6
                                • column: 33
                                }
                              }
                            • name: "x"
                            }
                          • value: MemberExpression {...}
                            • type: "MemberExpression"
                            • start: 147
                            • end: 156
                            • loc: {...}
                              • start: {...}
                                • line: 6
                                • column: 35
                                }
                              • end: {...}
                                • line: 6
                                • column: 44
                                }
                              }
                            • object: Identifier {...}
                              • type: "Identifier"
                              • start: 147
                              • end: 148
                              • loc: {...}
                                • start: {...}
                                  • line: 6
                                  • column: 35
                                  }
                                • end: {...}
                                  • line: 6
                                  • column: 36
                                  }
                                }
                              • name: "e"
                              }
                            • property: Identifier {...}
                              • type: "Identifier"
                              • start: 149
                              • end: 156
                              • loc: {...}
                                • start: {...}
                                  • line: 6
                                  • column: 37
                                  }
                                • end: {...}
                                  • line: 6
                                  • column: 44
                                  }
                                }
                              • name: "clientX"
                              }
                            • computed: false
                            • optional: false
                            }
                          • kind: "init"
                          }
                        • Property {...}
                          • type: "Property"
                          • start: 158
                          • end: 170
                          • loc: {...}
                            • start: {...}
                              • line: 6
                              • column: 46
                              }
                            • end: {...}
                              • line: 6
                              • column: 58
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 158
                            • end: 159
                            • loc: {...}
                              • start: {...}
                                • line: 6
                                • column: 46
                                }
                              • end: {...}
                                • line: 6
                                • column: 47
                                }
                              }
                            • name: "y"
                            }
                          • value: MemberExpression {...}
                            • type: "MemberExpression"
                            • start: 161
                            • end: 170
                            • loc: {...}
                              • start: {...}
                                • line: 6
                                • column: 49
                                }
                              • end: {...}
                                • line: 6
                                • column: 58
                                }
                              }
                            • object: Identifier {...}
                              • type: "Identifier"
                              • start: 161
                              • end: 162
                              • loc: {...}
                                • start: {...}
                                  • line: 6
                                  • column: 49
                                  }
                                • end: {...}
                                  • line: 6
                                  • column: 50
                                  }
                                }
                              • name: "e"
                              }
                            • property: Identifier {...}
                              • type: "Identifier"
                              • start: 163
                              • end: 170
                              • loc: {...}
                                • start: {...}
                                  • line: 6
                                  • column: 51
                                  }
                                • end: {...}
                                  • line: 6
                                  • column: 58
                                  }
                                }
                              • name: "clientY"
                              }
                            • computed: false
                            • optional: false
                            }
                          • kind: "init"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            • Attribute {...}
              • type: "Attribute"
              • start: -1
              • end: -1
              • name: "class"
              • value: [...] (1)
                • Text {...}
                  • type: "Text"
                  • data: "svelte-1c44y5p"
                  • raw: "svelte-1c44y5p"
                  • start: -1
                  • end: -1
                  }
                ]
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (5)
              • Text {...}
                • type: "Text"
                • start: 175
                • end: 199
                • raw: "The mouse position is "
                • data: "The mouse position is "
                }
              • ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 199
                • end: 204
                • expression: MemberExpression {...}
                  • type: "MemberExpression"
                  • start: 200
                  • end: 203
                  • loc: {...}
                    • start: {...}
                      • line: 7
                      • column: 24
                      }
                    • end: {...}
                      • line: 7
                      • column: 27
                      }
                    }
                  • object: Identifier {...}
                    • type: "Identifier"
                    • start: 200
                    • end: 201
                    • loc: {...}
                      • start: {...}
                        • line: 7
                        • column: 24
                        }
                      • end: {...}
                        • line: 7
                        • column: 25
                        }
                      }
                    • name: "m"
                    }
                  • property: Identifier {...}
                    • type: "Identifier"
                    • start: 202
                    • end: 203
                    • loc: {...}
                      • start: {...}
                        • line: 7
                        • column: 26
                        }
                      • end: {...}
                        • line: 7
                        • column: 27
                        }
                      }
                    • name: "x"
                    }
                  • computed: false
                  • optional: false
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 204
                • end: 207
                • raw: " x "
                • data: " x "
                }
              • ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 207
                • end: 212
                • expression: MemberExpression {...}
                  • type: "MemberExpression"
                  • start: 208
                  • end: 211
                  • loc: {...}
                    • start: {...}
                      • line: 7
                      • column: 32
                      }
                    • end: {...}
                      • line: 7
                      • column: 35
                      }
                    }
                  • object: Identifier {...}
                    • type: "Identifier"
                    • start: 208
                    • end: 209
                    • loc: {...}
                      • start: {...}
                        • line: 7
                        • column: 32
                        }
                      • end: {...}
                        • line: 7
                        • column: 33
                        }
                      }
                    • name: "m"
                    }
                  • property: Identifier {...}
                    • type: "Identifier"
                    • start: 210
                    • end: 211
                    • loc: {...}
                      • start: {...}
                        • line: 7
                        • column: 34
                        }
                      • end: {...}
                        • line: 7
                        • column: 35
                        }
                      }
                    • name: "y"
                    }
                  • computed: false
                  • optional: false
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 212
                • end: 213
                • raw: "\n"
                • data: "\n"
                }
              ]
            }
          }
        • Text {...}
          • type: "Text"
          • start: 219
          • end: 221
          • raw: "\n\n"
          • data: "\n\n"
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 51
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 42
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 3
            • column: 0
            }
          }
        • body: [...] (1)
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 10
            • end: 41
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 32
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 14
                • end: 40
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 5
                    }
                  • end: {...}
                    • line: 2
                    • column: 31
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 14
                  • end: 15
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 5
                      }
                    • end: {...}
                      • line: 2
                      • column: 6
                      }
                    }
                  • name: "m"
                  }
                • init: CallExpression {...}
                  • type: "CallExpression"
                  • start: 18
                  • end: 40
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 9
                      }
                    • end: {...}
                      • line: 2
                      • column: 31
                      }
                    }
                  • callee: Identifier {...}
                    • type: "Identifier"
                    • start: 18
                    • end: 24
                    • loc: {...}
                      • start: {...}
                        • line: 2
                        • column: 9
                        }
                      • end: {...}
                        • line: 2
                        • column: 15
                        }
                      }
                    • name: "$state"
                    }
                  • arguments: [...] (1)
                    • ObjectExpression {...}
                      • type: "ObjectExpression"
                      • start: 25
                      • end: 39
                      • loc: {...}
                        • start: {...}
                          • line: 2
                          • column: 16
                          }
                        • end: {...}
                          • line: 2
                          • column: 30
                          }
                        }
                      • properties: [...] (2)
                        • Property {...}
                          • type: "Property"
                          • start: 27
                          • end: 31
                          • loc: {...}
                            • start: {...}
                              • line: 2
                              • column: 18
                              }
                            • end: {...}
                              • line: 2
                              • column: 22
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 27
                            • end: 28
                            • loc: {...}
                              • start: {...}
                                • line: 2
                                • column: 18
                                }
                              • end: {...}
                                • line: 2
                                • column: 19
                                }
                              }
                            • name: "x"
                            }
                          • value: Literal {...}
                            • type: "Literal"
                            • start: 30
                            • end: 31
                            • loc: {...}
                              • start: {...}
                                • line: 2
                                • column: 21
                                }
                              • end: {...}
                                • line: 2
                                • column: 22
                                }
                              }
                            • value: 0
                            • raw: "0"
                            }
                          • kind: "init"
                          }
                        • Property {...}
                          • type: "Property"
                          • start: 33
                          • end: 37
                          • loc: {...}
                            • start: {...}
                              • line: 2
                              • column: 24
                              }
                            • end: {...}
                              • line: 2
                              • column: 28
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 33
                            • end: 34
                            • loc: {...}
                              • start: {...}
                                • line: 2
                                • column: 24
                                }
                              • end: {...}
                                • line: 2
                                • column: 25
                                }
                              }
                            • name: "y"
                            }
                          • value: Literal {...}
                            • type: "Literal"
                            • start: 36
                            • end: 37
                            • loc: {...}
                              • start: {...}
                                • line: 2
                                • column: 27
                                }
                              • end: {...}
                                • line: 2
                                • column: 28
                                }
                              }
                            • value: 0
                            • raw: "0"
                            }
                          • kind: "init"
                          }
                        ]
                      }
                    ]
                  • optional: false
                  }
                }
              ]
            • kind: "let"
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
Inline handlers • Playground • Svelte