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

<main>
<Header />
<Hero />
<About />
</main>
bundling https://unpkg.com/svelte@5.20.4/src/internal/shared/warnings.js
import 'svelte/internal/disclose-version';
import 'svelte/internal/flags/legacy';
import * as $ from 'svelte/internal/client';
import Header from "./Header.svelte";
import Hero from "./Hero.svelte";
import About from "./About.svelte";

var root = $.template(`<main><!> <!> <!></main>`);

export default function App($$anchor) {
let name = 'world';
var main = root();
var node = $.child(main);

Header(node, {});

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

Hero(node_1, {});

var node_2 = $.sibling(node_1, 2);

About(node_2, {});
$.reset(main);
$.append($$anchor, main);
}
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • Root {
    • css: null
    • js: []
    • start: 152
    • end: 199
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (2)
        • Text {...}
          • type: "Text"
          • start: 150
          • end: 152
          • raw: "\n\n"
          • data: "\n\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 152
          • end: 199
          • name: "main"
          • attributes: []
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (7)
              • Text {...}
                • type: "Text"
                • start: 158
                • end: 160
                • raw: "\n\t"
                • data: "\n\t"
                }
              • Component {...}
                • type: "Component"
                • start: 160
                • end: 170
                • name: "Header"
                • attributes: []
                • fragment: Fragment {...}
                  • type: "Fragment"
                  • nodes: []
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 170
                • end: 172
                • raw: " "
                • data: " "
                }
              • Component {...}
                • type: "Component"
                • start: 172
                • end: 180
                • name: "Hero"
                • attributes: []
                • fragment: Fragment {...}
                  • type: "Fragment"
                  • nodes: []
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 180
                • end: 182
                • raw: " "
                • data: " "
                }
              • Component {...}
                • type: "Component"
                • start: 182
                • end: 191
                • name: "About"
                • attributes: []
                • fragment: Fragment {...}
                  • type: "Fragment"
                  • nodes: []
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 191
                • end: 192
                • raw: "\n"
                • data: "\n"
                }
              ]
            }
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 150
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 141
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 6
            • column: 0
            }
          }
        • body: [...] (4)
          • 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: "Header"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 29
              • end: 46
              • loc: {...}
                • start: {...}
                  • line: 2
                  • column: 20
                  }
                • end: {...}
                  • line: 2
                  • column: 37
                  }
                }
              • value: "./Header.svelte"
              • raw: "\"./Header.svelte\""
              }
            }
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 49
            • end: 82
            • loc: {...}
              • start: {...}
                • line: 3
                • column: 1
                }
              • end: {...}
                • line: 3
                • column: 34
                }
              }
            • specifiers: [...] (1)
              • ImportDefaultSpecifier {...}
                • type: "ImportDefaultSpecifier"
                • start: 56
                • end: 60
                • loc: {...}
                  • start: {...}
                    • line: 3
                    • column: 8
                    }
                  • end: {...}
                    • line: 3
                    • column: 12
                    }
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 56
                  • end: 60
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 8
                      }
                    • end: {...}
                      • line: 3
                      • column: 12
                      }
                    }
                  • name: "Hero"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 66
              • end: 81
              • loc: {...}
                • start: {...}
                  • line: 3
                  • column: 18
                  }
                • end: {...}
                  • line: 3
                  • column: 33
                  }
                }
              • value: "./Hero.svelte"
              • raw: "\"./Hero.svelte\""
              }
            }
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 84
            • end: 119
            • loc: {...}
              • start: {...}
                • line: 4
                • column: 1
                }
              • end: {...}
                • line: 4
                • column: 36
                }
              }
            • specifiers: [...] (1)
              • ImportDefaultSpecifier {...}
                • type: "ImportDefaultSpecifier"
                • start: 91
                • end: 96
                • loc: {...}
                  • start: {...}
                    • line: 4
                    • column: 8
                    }
                  • end: {...}
                    • line: 4
                    • column: 13
                    }
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 91
                  • end: 96
                  • loc: {...}
                    • start: {...}
                      • line: 4
                      • column: 8
                      }
                    • end: {...}
                      • line: 4
                      • column: 13
                      }
                    }
                  • name: "About"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 102
              • end: 118
              • loc: {...}
                • start: {...}
                  • line: 4
                  • column: 19
                  }
                • end: {...}
                  • line: 4
                  • column: 35
                  }
                }
              • value: "./About.svelte"
              • raw: "\"./About.svelte\""
              }
            }
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 121
            • end: 140
            • loc: {...}
              • start: {...}
                • line: 5
                • column: 1
                }
              • end: {...}
                • line: 5
                • column: 20
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 125
                • end: 139
                • loc: {...}
                  • start: {...}
                    • line: 5
                    • column: 5
                    }
                  • end: {...}
                    • line: 5
                    • column: 19
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 125
                  • end: 129
                  • loc: {...}
                    • start: {...}
                      • line: 5
                      • column: 5
                      }
                    • end: {...}
                      • line: 5
                      • column: 9
                      }
                    }
                  • name: "name"
                  }
                • init: Literal {...}
                  • type: "Literal"
                  • start: 132
                  • end: 139
                  • loc: {...}
                    • start: {...}
                      • line: 5
                      • column: 12
                      }
                    • end: {...}
                      • line: 5
                      • 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
Interactive site • Playground • Svelte