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

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

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

Error compiling component

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

var root_1 = $.template(`<p>Flies in and 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(3, p, () => fly, () => ({ y: 200, duration: 2000 }));
$.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: 91
    • end: 256
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (4)
        • Text {...}
          • type: "Text"
          • start: 89
          • end: 91
          • raw: "\n\n"
          • data: "\n\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 91
          • end: 166
          • name: "label"
          • attributes: []
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (3)
              • Text {...}
                • type: "Text"
                • start: 98
                • end: 100
                • raw: "\n\t"
                • data: "\n\t"
                }
              • RegularElement {...}
                • type: "RegularElement"
                • start: 100
                • end: 148
                • name: "input"
                • attributes: [...] (2)
                  • Attribute {...}
                    • type: "Attribute"
                    • start: 107
                    • end: 122
                    • name: "type"
                    • value: [...] (1)
                      • Text {...}
                        • start: 113
                        • end: 121
                        • type: "Text"
                        • raw: "checkbox"
                        • data: "checkbox"
                        }
                      ]
                    }
                  • BindDirective {...}
                    • start: 123
                    • end: 145
                    • type: "BindDirective"
                    • name: "checked"
                    • expression: Identifier {...}
                      • type: "Identifier"
                      • start: 137
                      • end: 144
                      • loc: {...}
                        • start: {...}
                          • line: 7
                          • column: 38
                          }
                        • end: {...}
                          • line: 7
                          • column: 45
                          }
                        }
                      • name: "visible"
                      }
                    • modifiers: []
                    }
                  ]
                • fragment: Fragment {...}
                  • type: "Fragment"
                  • nodes: []
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 148
                • end: 158
                • raw: " visible"
                • data: " visible"
                }
              ]
            }
          }
        • Text {...}
          • type: "Text"
          • start: 166
          • end: 168
          • raw: " "
          • data: " "
          }
        • IfBlock {...}
          • type: "IfBlock"
          • elseif: false
          • start: 168
          • end: 256
          • test: Identifier {...}
            • type: "Identifier"
            • start: 173
            • end: 180
            • loc: {...}
              • start: {...}
                • line: 11
                • column: 5
                }
              • end: {...}
                • line: 11
                • column: 12
                }
              }
            • name: "visible"
            }
          • consequent: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (3)
              • Text {...}
                • type: "Text"
                • start: 181
                • end: 183
                • raw: "\n\t"
                • data: "\n\t"
                }
              • RegularElement {...}
                • type: "RegularElement"
                • start: 183
                • end: 250
                • name: "p"
                • attributes: [...] (1)
                  • TransitionDirective {...}
                    • start: 186
                    • end: 229
                    • type: "TransitionDirective"
                    • name: "fly"
                    • expression: ObjectExpression {...}
                      • type: "ObjectExpression"
                      • start: 202
                      • end: 228
                      • loc: {...}
                        • start: {...}
                          • line: 12
                          • column: 20
                          }
                        • end: {...}
                          • line: 12
                          • column: 46
                          }
                        }
                      • properties: [...] (2)
                        • Property {...}
                          • type: "Property"
                          • start: 204
                          • end: 210
                          • loc: {...}
                            • start: {...}
                              • line: 12
                              • column: 22
                              }
                            • end: {...}
                              • line: 12
                              • column: 28
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 204
                            • end: 205
                            • loc: {...}
                              • start: {...}
                                • line: 12
                                • column: 22
                                }
                              • end: {...}
                                • line: 12
                                • column: 23
                                }
                              }
                            • name: "y"
                            }
                          • value: Literal {...}
                            • type: "Literal"
                            • start: 207
                            • end: 210
                            • loc: {...}
                              • start: {...}
                                • line: 12
                                • column: 25
                                }
                              • end: {...}
                                • line: 12
                                • column: 28
                                }
                              }
                            • value: 200
                            • raw: "200"
                            }
                          • kind: "init"
                          }
                        • Property {...}
                          • type: "Property"
                          • start: 212
                          • end: 226
                          • loc: {...}
                            • start: {...}
                              • line: 12
                              • column: 30
                              }
                            • end: {...}
                              • line: 12
                              • column: 44
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 212
                            • end: 220
                            • loc: {...}
                              • start: {...}
                                • line: 12
                                • column: 30
                                }
                              • end: {...}
                                • line: 12
                                • column: 38
                                }
                              }
                            • name: "duration"
                            }
                          • value: Literal {...}
                            • type: "Literal"
                            • start: 222
                            • end: 226
                            • loc: {...}
                              • start: {...}
                                • line: 12
                                • column: 40
                                }
                              • end: {...}
                                • line: 12
                                • column: 44
                                }
                              }
                            • value: 2000
                            • raw: "2000"
                            }
                          • kind: "init"
                          }
                        ]
                      }
                    • modifiers: []
                    • intro: true
                    • outro: true
                    }
                  ]
                • fragment: Fragment {...}
                  • type: "Fragment"
                  • nodes: [...] (1)
                    • Text {...}
                      • type: "Text"
                      • start: 230
                      • end: 246
                      • raw: "Flies in and out"
                      • data: "Flies in and out"
                      }
                    ]
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 250
                • end: 251
                • raw: "\n"
                • data: "\n"
                }
              ]
            }
          • alternate: null
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 89
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 80
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 4
            • column: 0
            }
          }
        • body: [...] (2)
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 10
            • end: 50
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 41
                }
              }
            • specifiers: [...] (1)
              • ImportSpecifier {...}
                • type: "ImportSpecifier"
                • start: 19
                • end: 22
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 10
                    }
                  • end: {...}
                    • line: 2
                    • column: 13
                    }
                  }
                • imported: Identifier {...}
                  • type: "Identifier"
                  • start: 19
                  • end: 22
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 10
                      }
                    • end: {...}
                      • line: 2
                      • column: 13
                      }
                    }
                  • name: "fly"
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 19
                  • end: 22
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 10
                      }
                    • end: {...}
                      • line: 2
                      • column: 13
                      }
                    }
                  • name: "fly"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 30
              • end: 49
              • loc: {...}
                • start: {...}
                  • line: 2
                  • column: 21
                  }
                • end: {...}
                  • line: 2
                  • column: 40
                  }
                }
              • value: "svelte/transition"
              • raw: "'svelte/transition'"
              }
            }
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 52
            • end: 79
            • loc: {...}
              • start: {...}
                • line: 3
                • column: 1
                }
              • end: {...}
                • line: 3
                • column: 28
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 56
                • end: 78
                • loc: {...}
                  • start: {...}
                    • line: 3
                    • column: 5
                    }
                  • end: {...}
                    • line: 3
                    • column: 27
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 56
                  • end: 63
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 5
                      }
                    • end: {...}
                      • line: 3
                      • column: 12
                      }
                    }
                  • name: "visible"
                  }
                • init: CallExpression {...}
                  • type: "CallExpression"
                  • start: 66
                  • end: 78
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 15
                      }
                    • end: {...}
                      • line: 3
                      • column: 27
                      }
                    }
                  • callee: Identifier {...}
                    • type: "Identifier"
                    • start: 66
                    • end: 72
                    • loc: {...}
                      • start: {...}
                        • line: 3
                        • column: 15
                        }
                      • end: {...}
                        • line: 3
                        • column: 21
                        }
                      }
                    • name: "$state"
                    }
                  • arguments: [...] (1)
                    • Literal {...}
                      • type: "Literal"
                      • start: 73
                      • end: 77
                      • 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
Adding parameters • Playground • Svelte