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
Button.svelte
<script>
import Button from "./Button.svelte";
let name = 'world';
</script>

<h1>Hello {name}!</h1>
<Button />
resolving https://unpkg.com/svelte@5.20.4/src/store/utils.js
import 'svelte/internal/disclose-version';
import 'svelte/internal/flags/legacy';
import * as $ from 'svelte/internal/client';
import Button from "./Button.svelte";

var root = $.template(`<h1></h1> <!>`, 1);

export default function App($$anchor) {
let name = 'world';
var fragment = root();
var h1 = $.first_child(fragment);

h1.textContent = `Hello ${name ?? ''}!`;

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

Button(node, {});
$.append($$anchor, fragment);
}
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • Root {
    • css: null
    • js: []
    • start: 80
    • end: 113
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (4)
        • Text {...}
          • type: "Text"
          • start: 78
          • end: 80
          • raw: "\n\n"
          • data: "\n\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 80
          • end: 102
          • name: "h1"
          • attributes: []
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (3)
              • Text {...}
                • type: "Text"
                • start: 84
                • end: 90
                • raw: "Hello "
                • data: "Hello "
                }
              • ExpressionTag {...}
                • type: "ExpressionTag"
                • start: 90
                • end: 96
                • expression: Identifier {...}
                  • type: "Identifier"
                  • start: 91
                  • end: 95
                  • loc: {...}
                    • start: {...}
                      • line: 6
                      • column: 11
                      }
                    • end: {...}
                      • line: 6
                      • column: 15
                      }
                    }
                  • name: "name"
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 96
                • end: 97
                • raw: "!"
                • data: "!"
                }
              ]
            }
          }
        • Text {...}
          • type: "Text"
          • start: 102
          • end: 103
          • raw: " "
          • data: " "
          }
        • Component {...}
          • type: "Component"
          • start: 103
          • end: 113
          • name: "Button"
          • attributes: []
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: []
            }
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 78
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 69
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 4
            • column: 0
            }
          }
        • body: [...] (2)
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 10
            • end: 47
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 38
                }
              }
            • specifiers: [...] (1)
              • ImportDefaultSpecifier {...}
                • type: "ImportDefaultSpecifier"
                • start: 17
                • end: 23
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 8
                    }
                  • end: {...}
                    • line: 2
                    • column: 14
                    }
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 17
                  • end: 23
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 8
                      }
                    • end: {...}
                      • line: 2
                      • column: 14
                      }
                    }
                  • name: "Button"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 29
              • end: 46
              • loc: {...}
                • start: {...}
                  • line: 2
                  • column: 20
                  }
                • end: {...}
                  • line: 2
                  • column: 37
                  }
                }
              • value: "./Button.svelte"
              • raw: "\"./Button.svelte\""
              }
            }
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 49
            • end: 68
            • loc: {...}
              • start: {...}
                • line: 3
                • column: 1
                }
              • end: {...}
                • line: 3
                • column: 20
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 53
                • end: 67
                • loc: {...}
                  • start: {...}
                    • line: 3
                    • column: 5
                    }
                  • end: {...}
                    • line: 3
                    • column: 19
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 53
                  • end: 57
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 5
                      }
                    • end: {...}
                      • line: 3
                      • column: 9
                      }
                    }
                  • name: "name"
                  }
                • init: Literal {...}
                  • type: "Literal"
                  • start: 60
                  • end: 67
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 12
                      }
                    • end: {...}
                      • line: 3
                      • column: 19
                      }
                    }
                  • value: "world"
                  • raw: "'world'"
                  }
                }
              ]
            • kind: "let"
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
Hello world • Playground • Svelte