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 count = 0;
$: doubled = count * 2;
</script>
{ count } x 2 = { doubled }
resolving https://unpkg.com/svelte@5.20.5/src/internal/client/dev/console-log.js
import 'svelte/internal/disclose-version';
import 'svelte/internal/flags/legacy';
import * as $ from 'svelte/internal/client';

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

const doubled = $.mutable_state();
let count = 0;

$.legacy_pre_effect(() => {}, () => {
$.set(doubled, count * 2);
});

$.legacy_pre_effect_reset();
$.next();

var text = $.text();

$.template_effect(() => $.set_text(text, `${count ?? ''} x 2 = ${$.get(doubled) ?? ''}`));
$.append($$anchor, text);
$.pop();
}
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • Root {
    • css: null
    • js: []
    • start: 60
    • end: 87
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (4)
        • Text {...}
          • type: "Text"
          • start: 59
          • end: 60
          • raw: "\n"
          • data: "\n"
          }
        • ExpressionTag {...}
          • type: "ExpressionTag"
          • start: 60
          • end: 69
          • expression: Identifier {...}
            • type: "Identifier"
            • start: 62
            • end: 67
            • loc: {...}
              • start: {...}
                • line: 5
                • column: 2
                }
              • end: {...}
                • line: 5
                • column: 7
                }
              }
            • name: "count"
            }
          }
        • Text {...}
          • type: "Text"
          • start: 69
          • end: 76
          • raw: " x 2 = "
          • data: " x 2 = "
          }
        • ExpressionTag {...}
          • type: "ExpressionTag"
          • start: 76
          • end: 87
          • expression: Identifier {...}
            • type: "Identifier"
            • start: 78
            • end: 85
            • loc: {...}
              • start: {...}
                • line: 5
                • column: 18
                }
              • end: {...}
                • line: 5
                • column: 25
                }
              }
            • name: "doubled"
            }
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 59
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 50
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 4
            • column: 0
            }
          }
        • body: [...] (2)
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 10
            • end: 24
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 15
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 14
                • end: 23
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 5
                    }
                  • end: {...}
                    • line: 2
                    • column: 14
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 14
                  • end: 19
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 5
                      }
                    • end: {...}
                      • line: 2
                      • column: 10
                      }
                    }
                  • name: "count"
                  }
                • init: Literal {...}
                  • type: "Literal"
                  • start: 22
                  • end: 23
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 13
                      }
                    • end: {...}
                      • line: 2
                      • column: 14
                      }
                    }
                  • value: 0
                  • raw: "0"
                  }
                }
              ]
            • kind: "let"
            }
          • LabeledStatement {...}
            • type: "LabeledStatement"
            • start: 26
            • end: 49
            • loc: {...}
              • start: {...}
                • line: 3
                • column: 1
                }
              • end: {...}
                • line: 3
                • column: 24
                }
              }
            • body: ExpressionStatement {...}
              • type: "ExpressionStatement"
              • start: 29
              • end: 49
              • loc: {...}
                • start: {...}
                  • line: 3
                  • column: 4
                  }
                • end: {...}
                  • line: 3
                  • column: 24
                  }
                }
              • expression: AssignmentExpression {...}
                • type: "AssignmentExpression"
                • start: 29
                • end: 48
                • loc: {...}
                  • start: {...}
                    • line: 3
                    • column: 4
                    }
                  • end: {...}
                    • line: 3
                    • column: 23
                    }
                  }
                • operator: "="
                • left: Identifier {...}
                  • type: "Identifier"
                  • start: 29
                  • end: 36
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 4
                      }
                    • end: {...}
                      • line: 3
                      • column: 11
                      }
                    }
                  • name: "doubled"
                  }
                • right: BinaryExpression {...}
                  • type: "BinaryExpression"
                  • start: 39
                  • end: 48
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 14
                      }
                    • end: {...}
                      • line: 3
                      • column: 23
                      }
                    }
                  • left: Identifier {...}
                    • type: "Identifier"
                    • start: 39
                    • end: 44
                    • loc: {...}
                      • start: {...}
                        • line: 3
                        • column: 14
                        }
                      • end: {...}
                        • line: 3
                        • column: 19
                        }
                      }
                    • name: "count"
                    }
                  • operator: "*"
                  • right: Literal {...}
                    • type: "Literal"
                    • start: 47
                    • end: 48
                    • loc: {...}
                      • start: {...}
                        • line: 3
                        • column: 22
                        }
                      • end: {...}
                        • line: 3
                        • column: 23
                        }
                      }
                    • value: 2
                    • raw: "2"
                    }
                  }
                }
              }
            • label: Identifier {...}
              • type: "Identifier"
              • start: 26
              • end: 27
              • loc: {...}
                • start: {...}
                  • line: 3
                  • column: 1
                  }
                • end: {...}
                  • line: 3
                  • column: 2
                  }
                }
              • name: "$"
              }
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
Compile Svelte in your Head - Reactive declaration not reactive • Playground • Svelte