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>
import { fade, fly } from 'svelte/transition';
let visible = $state(true);
</script>

<label>
<input type="checkbox" bind:checked={visible} />
visible
</label>

{#if visible}
<p in:fly={{ y: 200, duration: 2000 }} out:fade>Flies in, fades out</p>
{/if}

Error compiling component

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

var root_1 = $.template(`<p>Flies in, fades out</p>`);
var root = $.template(`<label><input type="checkbox"> visible</label> <!>`, 1);

export default function App($$anchor) {
let visible = $.state(true);
var fragment = root();
var label = $.first_child(fragment);
var input = $.child(label);

$.remove_input_defaults(input);
$.next();
$.reset(label);

var node = $.sibling(label, 2);

{
var consequent = ($$anchor) => {
var p = root_1();

$.transition(1, p, () => fly, () => ({ y: 200, duration: 2000 }));
$.transition(2, p, () => fade);
$.append($$anchor, p);
};

$.if(node, ($$render) => {
if ($.get(visible)) $$render(consequent);
});
}

$.bind_checked(input, () => $.get(visible), ($$value) => $.set(visible, $$value));
$.append($$anchor, fragment);
}
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • Root {
    • css: null
    • js: []
    • start: 97
    • end: 266
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (4)
        • Text {...}
          • type: "Text"
          • start: 95
          • end: 97
          • raw: "\n\n"
          • data: "\n\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 97
          • end: 172
          • name: "label"
          • attributes: []
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (3)
              • Text {...}
                • type: "Text"
                • start: 104
                • end: 106
                • raw: "\n\t"
                • data: "\n\t"
                }
              • RegularElement {...}
                • type: "RegularElement"
                • start: 106
                • end: 154
                • name: "input"
                • attributes: [...] (2)
                  • Attribute {...}
                    • type: "Attribute"
                    • start: 113
                    • end: 128
                    • name: "type"
                    • value: [...] (1)
                      • Text {...}
                        • start: 119
                        • end: 127
                        • type: "Text"
                        • raw: "checkbox"
                        • data: "checkbox"
                        }
                      ]
                    }
                  • BindDirective {...}
                    • start: 129
                    • end: 151
                    • type: "BindDirective"
                    • name: "checked"
                    • expression: Identifier {...}
                      • type: "Identifier"
                      • start: 143
                      • end: 150
                      • loc: {...}
                        • start: {...}
                          • line: 7
                          • column: 38
                          }
                        • end: {...}
                          • line: 7
                          • column: 45
                          }
                        }
                      • name: "visible"
                      }
                    • modifiers: []
                    }
                  ]
                • fragment: Fragment {...}
                  • type: "Fragment"
                  • nodes: []
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 154
                • end: 164
                • raw: " visible"
                • data: " visible"
                }
              ]
            }
          }
        • Text {...}
          • type: "Text"
          • start: 172
          • end: 174
          • raw: " "
          • data: " "
          }
        • IfBlock {...}
          • type: "IfBlock"
          • elseif: false
          • start: 174
          • end: 266
          • test: Identifier {...}
            • type: "Identifier"
            • start: 179
            • end: 186
            • loc: {...}
              • start: {...}
                • line: 11
                • column: 5
                }
              • end: {...}
                • line: 11
                • column: 12
                }
              }
            • name: "visible"
            }
          • consequent: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (3)
              • Text {...}
                • type: "Text"
                • start: 187
                • end: 189
                • raw: "\n\t"
                • data: "\n\t"
                }
              • RegularElement {...}
                • type: "RegularElement"
                • start: 189
                • end: 260
                • name: "p"
                • attributes: [...] (2)
                  • TransitionDirective {...}
                    • start: 192
                    • end: 227
                    • type: "TransitionDirective"
                    • name: "fly"
                    • expression: ObjectExpression {...}
                      • type: "ObjectExpression"
                      • start: 200
                      • end: 226
                      • loc: {...}
                        • start: {...}
                          • line: 12
                          • column: 12
                          }
                        • end: {...}
                          • line: 12
                          • column: 38
                          }
                        }
                      • properties: [...] (2)
                        • Property {...}
                          • type: "Property"
                          • start: 202
                          • end: 208
                          • loc: {...}
                            • start: {...}
                              • line: 12
                              • column: 14
                              }
                            • end: {...}
                              • line: 12
                              • column: 20
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 202
                            • end: 203
                            • loc: {...}
                              • start: {...}
                                • line: 12
                                • column: 14
                                }
                              • end: {...}
                                • line: 12
                                • column: 15
                                }
                              }
                            • name: "y"
                            }
                          • value: Literal {...}
                            • type: "Literal"
                            • start: 205
                            • end: 208
                            • loc: {...}
                              • start: {...}
                                • line: 12
                                • column: 17
                                }
                              • end: {...}
                                • line: 12
                                • column: 20
                                }
                              }
                            • value: 200
                            • raw: "200"
                            }
                          • kind: "init"
                          }
                        • Property {...}
                          • type: "Property"
                          • start: 210
                          • end: 224
                          • loc: {...}
                            • start: {...}
                              • line: 12
                              • column: 22
                              }
                            • end: {...}
                              • line: 12
                              • column: 36
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 210
                            • end: 218
                            • loc: {...}
                              • start: {...}
                                • line: 12
                                • column: 22
                                }
                              • end: {...}
                                • line: 12
                                • column: 30
                                }
                              }
                            • name: "duration"
                            }
                          • value: Literal {...}
                            • type: "Literal"
                            • start: 220
                            • end: 224
                            • loc: {...}
                              • start: {...}
                                • line: 12
                                • column: 32
                                }
                              • end: {...}
                                • line: 12
                                • column: 36
                                }
                              }
                            • value: 2000
                            • raw: "2000"
                            }
                          • kind: "init"
                          }
                        ]
                      }
                    • modifiers: []
                    • intro: true
                    • outro: false
                    }
                  • TransitionDirective {...}
                    • start: 228
                    • end: 236
                    • type: "TransitionDirective"
                    • name: "fade"
                    • expression: null
                    • modifiers: []
                    • intro: false
                    • outro: true
                    }
                  ]
                • fragment: Fragment {...}
                  • type: "Fragment"
                  • nodes: [...] (1)
                    • Text {...}
                      • type: "Text"
                      • start: 237
                      • end: 256
                      • raw: "Flies in, fades out"
                      • data: "Flies in, fades out"
                      }
                    ]
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 260
                • end: 261
                • raw: "\n"
                • data: "\n"
                }
              ]
            }
          • alternate: null
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 95
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 86
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 4
            • column: 0
            }
          }
        • body: [...] (2)
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 10
            • end: 56
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 47
                }
              }
            • specifiers: [...] (2)
              • ImportSpecifier {...}
                • type: "ImportSpecifier"
                • start: 19
                • end: 23
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 10
                    }
                  • end: {...}
                    • line: 2
                    • column: 14
                    }
                  }
                • imported: Identifier {...}
                  • type: "Identifier"
                  • start: 19
                  • end: 23
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 10
                      }
                    • end: {...}
                      • line: 2
                      • column: 14
                      }
                    }
                  • name: "fade"
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 19
                  • end: 23
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 10
                      }
                    • end: {...}
                      • line: 2
                      • column: 14
                      }
                    }
                  • name: "fade"
                  }
                }
              • ImportSpecifier {...}
                • type: "ImportSpecifier"
                • start: 25
                • end: 28
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 16
                    }
                  • end: {...}
                    • line: 2
                    • column: 19
                    }
                  }
                • imported: Identifier {...}
                  • type: "Identifier"
                  • start: 25
                  • end: 28
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 16
                      }
                    • end: {...}
                      • line: 2
                      • column: 19
                      }
                    }
                  • name: "fly"
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 25
                  • end: 28
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 16
                      }
                    • end: {...}
                      • line: 2
                      • column: 19
                      }
                    }
                  • name: "fly"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 36
              • end: 55
              • loc: {...}
                • start: {...}
                  • line: 2
                  • column: 27
                  }
                • end: {...}
                  • line: 2
                  • column: 46
                  }
                }
              • value: "svelte/transition"
              • raw: "'svelte/transition'"
              }
            }
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 58
            • end: 85
            • loc: {...}
              • start: {...}
                • line: 3
                • column: 1
                }
              • end: {...}
                • line: 3
                • column: 28
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 62
                • end: 84
                • loc: {...}
                  • start: {...}
                    • line: 3
                    • column: 5
                    }
                  • end: {...}
                    • line: 3
                    • column: 27
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 62
                  • end: 69
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 5
                      }
                    • end: {...}
                      • line: 3
                      • column: 12
                      }
                    }
                  • name: "visible"
                  }
                • init: CallExpression {...}
                  • type: "CallExpression"
                  • start: 72
                  • end: 84
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 15
                      }
                    • end: {...}
                      • line: 3
                      • column: 27
                      }
                    }
                  • callee: Identifier {...}
                    • type: "Identifier"
                    • start: 72
                    • end: 78
                    • loc: {...}
                      • start: {...}
                        • line: 3
                        • column: 15
                        }
                      • end: {...}
                        • line: 3
                        • column: 21
                        }
                      }
                    • name: "$state"
                    }
                  • arguments: [...] (1)
                    • Literal {...}
                      • type: "Literal"
                      • start: 79
                      • end: 83
                      • loc: {...}
                        • start: {...}
                          • line: 3
                          • column: 22
                          }
                        • end: {...}
                          • line: 3
                          • column: 26
                          }
                        }
                      • value: true
                      • raw: "true"
                      }
                    ]
                  • optional: false
                  }
                }
              ]
            • kind: "let"
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
In and out • Playground • Svelte