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
stores.js
<script>
import { count } from './stores.js';
</script>

<h1>The count is {$count}</h1>

<button onclick={count.increment}>+</button>
<button onclick={count.decrement}>-</button>
<button onclick={count.reset}>reset</button>

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 { count } from './stores.js';

var root = $.template(`<h1> </h1> <button>+</button> <button>-</button> <button>reset</button>`, 1);

export default function App($$anchor, $$props) {
$.push($$props, false);

const [$$stores, $$cleanup] = $.setup_stores();
const $count = () => $.store_get(count, '$count', $$stores);

$.init();

var fragment = root();
var h1 = $.first_child(fragment);
var text = $.child(h1);

$.reset(h1);

var button = $.sibling(h1, 2);

button.__click = function (...$$args) {
count.increment?.apply(this, $$args);
};

var button_1 = $.sibling(button, 2);

button_1.__click = function (...$$args) {
count.decrement?.apply(this, $$args);
};

var button_2 = $.sibling(button_1, 2);

button_2.__click = function (...$$args) {
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • Root {
    • css: null
    • js: []
    • start: 58
    • end: 224
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (8)
        • Text {...}
          • type: "Text"
          • start: 56
          • end: 58
          • raw: "\n\n"
          • data: "\n\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 58
          • end: 88
          • name: "h1"
          • attributes: []
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (2)
              • Text {...}
                • type: "Text"
                • start: 62
                • end: 75
                • raw: "The count is "
                • data: "The count is "
                }
              • ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 75
                • end: 83
                • expression: Identifier {...}
                  • type: "Identifier"
                  • start: 76
                  • end: 82
                  • loc: {...}
                    • start: {...}
                      • line: 5
                      • column: 18
                      }
                    • end: {...}
                      • line: 5
                      • column: 24
                      }
                    }
                  • name: "$count"
                  }
                }
              ]
            }
          }
        • Text {...}
          • type: "Text"
          • start: 88
          • end: 90
          • raw: " "
          • data: " "
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 90
          • end: 134
          • name: "button"
          • attributes: [...] (1)
            • Attribute {...}
              • type: "Attribute"
              • start: 98
              • end: 123
              • name: "onclick"
              • value: ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 106
                • end: 123
                • expression: MemberExpression {...}
                  • type: "MemberExpression"
                  • start: 107
                  • end: 122
                  • loc: {...}
                    • start: {...}
                      • line: 7
                      • column: 17
                      }
                    • end: {...}
                      • line: 7
                      • column: 32
                      }
                    }
                  • object: Identifier {...}
                    • type: "Identifier"
                    • start: 107
                    • end: 112
                    • loc: {...}
                      • start: {...}
                        • line: 7
                        • column: 17
                        }
                      • end: {...}
                        • line: 7
                        • column: 22
                        }
                      }
                    • name: "count"
                    }
                  • property: Identifier {...}
                    • type: "Identifier"
                    • start: 113
                    • end: 122
                    • loc: {...}
                      • start: {...}
                        • line: 7
                        • column: 23
                        }
                      • end: {...}
                        • line: 7
                        • column: 32
                        }
                      }
                    • name: "increment"
                    }
                  • computed: false
                  • optional: false
                  }
                }
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (1)
              • Text {...}
                • type: "Text"
                • start: 124
                • end: 125
                • raw: "+"
                • data: "+"
                }
              ]
            }
          }
        • Text {...}
          • type: "Text"
          • start: 134
          • end: 135
          • raw: " "
          • data: " "
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 135
          • end: 179
          • name: "button"
          • attributes: [...] (1)
            • Attribute {...}
              • type: "Attribute"
              • start: 143
              • end: 168
              • name: "onclick"
              • value: ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 151
                • end: 168
                • expression: MemberExpression {...}
                  • type: "MemberExpression"
                  • start: 152
                  • end: 167
                  • loc: {...}
                    • start: {...}
                      • line: 8
                      • column: 17
                      }
                    • end: {...}
                      • line: 8
                      • column: 32
                      }
                    }
                  • object: Identifier {...}
                    • type: "Identifier"
                    • start: 152
                    • end: 157
                    • loc: {...}
                      • start: {...}
                        • line: 8
                        • column: 17
                        }
                      • end: {...}
                        • line: 8
                        • column: 22
                        }
                      }
                    • name: "count"
                    }
                  • property: Identifier {...}
                    • type: "Identifier"
                    • start: 158
                    • end: 167
                    • loc: {...}
                      • start: {...}
                        • line: 8
                        • column: 23
                        }
                      • end: {...}
                        • line: 8
                        • column: 32
                        }
                      }
                    • name: "decrement"
                    }
                  • computed: false
                  • optional: false
                  }
                }
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (1)
              • Text {...}
                • type: "Text"
                • start: 169
                • end: 170
                • raw: "-"
                • data: "-"
                }
              ]
            }
          }
        • Text {...}
          • type: "Text"
          • start: 179
          • end: 180
          • raw: " "
          • data: " "
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 180
          • end: 224
          • name: "button"
          • attributes: [...] (1)
            • Attribute {...}
              • type: "Attribute"
              • start: 188
              • end: 209
              • name: "onclick"
              • value: ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 196
                • end: 209
                • expression: MemberExpression {...}
                  • type: "MemberExpression"
                  • start: 197
                  • end: 208
                  • loc: {...}
                    • start: {...}
                      • line: 9
                      • column: 17
                      }
                    • end: {...}
                      • line: 9
                      • column: 28
                      }
                    }
                  • object: Identifier {...}
                    • type: "Identifier"
                    • start: 197
                    • end: 202
                    • loc: {...}
                      • start: {...}
                        • line: 9
                        • column: 17
                        }
                      • end: {...}
                        • line: 9
                        • column: 22
                        }
                      }
                    • name: "count"
                    }
                  • property: Identifier {...}
                    • type: "Identifier"
                    • start: 203
                    • end: 208
                    • loc: {...}
                      • start: {...}
                        • line: 9
                        • column: 23
                        }
                      • end: {...}
                        • line: 9
                        • column: 28
                        }
                      }
                    • name: "reset"
                    }
                  • computed: false
                  • optional: false
                  }
                }
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (1)
              • Text {...}
                • type: "Text"
                • start: 210
                • end: 215
                • raw: "reset"
                • data: "reset"
                }
              ]
            }
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 56
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 47
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 3
            • column: 0
            }
          }
        • body: [...] (1)
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 10
            • end: 46
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 37
                }
              }
            • specifiers: [...] (1)
              • ImportSpecifier {...}
                • type: "ImportSpecifier"
                • start: 19
                • end: 24
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 10
                    }
                  • end: {...}
                    • line: 2
                    • column: 15
                    }
                  }
                • imported: Identifier {...}
                  • type: "Identifier"
                  • start: 19
                  • end: 24
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 10
                      }
                    • end: {...}
                      • line: 2
                      • column: 15
                      }
                    }
                  • name: "count"
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 19
                  • end: 24
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 10
                      }
                    • end: {...}
                      • line: 2
                      • column: 15
                      }
                    }
                  • name: "count"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 32
              • end: 45
              • loc: {...}
                • start: {...}
                  • line: 2
                  • column: 23
                  }
                • end: {...}
                  • line: 2
                  • column: 36
                  }
                }
              • value: "./stores.js"
              • raw: "'./stores.js'"
              }
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
Custom stores • Playground • Svelte