1. Compiler
  2. Parse

Compiler

Parse

        ast: object = svelte.parse(
	source: string,
	options?: {
		filename?: string,
		customElement?: boolean
	}
)

      

The parse function parses a component, returning only its abstract syntax tree. Unlike compiling with the generate: false option, this will not perform any validation or other analysis of the component beyond parsing it. Note that the returned AST is not considered public API, so breaking changes could occur at any point in time.

        const svelte = require('svelte/compiler');

const ast = svelte.parse(source, { filename: 'App.svelte' });