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
<style>
h1 {
color: rebeccapurple;
}
</style>
<h1>Hello World</h1>
bundling esm-env
import 'svelte/internal/disclose-version';
import 'svelte/internal/flags/legacy';
import * as $ from 'svelte/internal/client';

var root = $.template(`<h1 class="svelte-1qq4xcd">Hello World</h1>`);

export default function App($$anchor) {
var h1 = root();

$.append($$anchor, h1);
}
result = svelte.compile(source, {
generate: ,
});

h1.svelte-1qq4xcd {
color: rebeccapurple;
}

		
			
				
  • Root {
    • css: StyleSheet {...}
      • type: "StyleSheet"
      • start: 0
      • end: 53
      • attributes: []
      • children: [...] (1)
        • Rule {...}
          • type: "Rule"
          • prelude: SelectorList {...}
            • type: "SelectorList"
            • start: 10
            • end: 12
            • children: [...] (1)
              • ComplexSelector {...}
                • type: "ComplexSelector"
                • start: 10
                • end: 12
                • children: [...] (1)
                  • RelativeSelector {...}
                    • type: "RelativeSelector"
                    • combinator: null
                    • selectors: [...] (1)
                      • TypeSelector {...}
                        • type: "TypeSelector"
                        • name: "h1"
                        • start: 10
                        • end: 12
                        }
                      ]
                    • start: 10
                    • end: 12
                    }
                  ]
                }
              ]
            }
          • block: Block {...}
            • type: "Block"
            • start: 13
            • end: 44
            • children: [...] (1)
              • Declaration {...}
                • type: "Declaration"
                • start: 19
                • end: 39
                • property: "color"
                • value: "rebeccapurple"
                }
              ]
            }
          • start: 10
          • end: 44
          }
        ]
      • content: {...}
        • start: 7
        • end: 45
        • styles: "\n h1 {\n color: rebeccapurple;\n }\n"
        • comment: null
        }
      }
    • js: []
    • start: 54
    • end: 74
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (2)
        • Text {...}
          • type: "Text"
          • start: 53
          • end: 54
          • raw: "\n"
          • data: "\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 54
          • end: 74
          • name: "h1"
          • attributes: [...] (1)
            • Attribute {...}
              • type: "Attribute"
              • start: -1
              • end: -1
              • name: "class"
              • value: [...] (1)
                • Text {...}
                  • type: "Text"
                  • data: ""
                  • raw: ""
                  • start: -1
                  • end: -1
                  }
                ]
              }
            ]
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (1)
              • Text {...}
                • type: "Text"
                • start: 58
                • end: 69
                • raw: "Hello World"
                • data: "Hello World"
                }
              ]
            }
          }
        ]
      }
    • options: null
    }
The AST is not public API and may change at any point in time
Compile Svelte in your Head - Hello World with styles • Playground • Svelte